Search code examples
anylogic

Anylogic: Using different arrival tables for multiple runs


I set up a model with a source that generates cars to enter a parking lot. In the source block I like to use an internal database table for the arrivals based on time stamps. So far I do not have any issues. However I like to make multiple simulation runs with different arrival tables. How can I avoid adjusting the tables and starting all the runs manually (since I must make 180 runs)?

I looked already at "parameter variation experiments" but could not find a solution because there seems to be no way to define a database table as a parameter that could be used and varied in the source block.

Image1

Thanks for any help!


Solution

  • One solution that comes to mind, if you have your data in Excel format, is to use the Excel File element in AnyLogic instead of the database. I am not sure how your different tables are setup, but I am going to assume each table is in a sheet of the same excel file.

    That way, you can use the sheet number as a parameter to be used in parameter variation. One example of the syntax is as follows:

    excelFile.getCellNumericValue(sheetIndex, rowIndex, columnIndex);
    

    Now the details on how to link the excel data to the arrival of agents will require some creativity. I recommend using the inject function in a user control event. Something similar to the below (where counter is an int variable you add to your model):

    int n = excelFile.getCellNumericValue(sheetIndex, counter, 2);
    source.inject(n);
    
    double nextOccurence =
    excelFile.getCellNumericValue(sheetIndex, counter + 1, 3)
    -
    excelFile.getCellNumericValue(sheetIndex, counter, 3)
    ;
    event.restart( nextOccurence  );
    counter++;
    

    The above for sure doesn't work because I used some random assumptions (e.g. the column number of where you have the number of arrivals, the column number of where you have the dates, etc.). So you should evaluate the code carefully and tailor it to your case. Also, you may need a different code for the first arrival.

    An additional warning is that if your database is huge (i.e. 1000s of rows), using an Excel File will make your model slower.