Search code examples
javaanylogic

ANYLOGIC : How to get value parameters into Excel file?


I've created an agent parameter which saves travel time of lorries in my model. I would get these values (one for each lorries agent) in a Excel file. How can I do? I've uploaded a pic in which you can see on the right the focused parameter of which get value for each agent.

enter image description here


Solution

  • First of all, it is better to define these types of data as variables, not parameters.

    If you want to write the values of tempo_viaggio at the end of the simulation into an Excel file, do the following:

    Drag and drop ExcelFile object, link it to the file that you would like to write to: enter image description here

    You need to define a variable to keep the travel times information in the Main agent. As an example below: enter image description here

    In the course of the simulation, populate the variable as following inside the Tir agent:

    main.travelTime.add(this.tempo_viaggio);
    

    At the end of the simulation, write this information into an Excel File.

    for (int i=0; i<travelTime.size();i++)
    {
    
        Double z = ((Double) travelTime.get(i));
        excelFileOutput.setCellValue(z, 1, i+2, 2); //value,sheetName or number, row, column
    
    }