Running multiple models in a loop

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Submitted by Enric on Thu, 06/02/2011 - 11:18 


I have a model I need to run multiple (n=25) times, each time with different 'start' values. For every model, the COST function is used to optimise the model such that the model ends when the global optimisation is complete.

At the moment, I have the start values in a .csv file in 25 columns which I can access via the Import block. However, as Vissim stops after each model is optimised, to run the multiple models I need to manually tell it which of the models it is to run which involves telling the import function which column to access.

Please could you let me know if there is a way of doing two things: 1. Running all 25 models in sequence so I don't need to keep restarting the model myself manually. 2. Exporting data in such a way that at the end of each of the 25 models it saves the data in a separate data file (ie. so I end up with 25 data files). As far as I can see, using the Export block there is no way of setting the data filename automatically.

Any guidance would be appreciated. Many thanks

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by Anders89 on Thu, 06/02/2011 - 19:15.

    To control the output file naming take a look at the example diagram under Diagrams > Examples > Applications > Data Logging > exportTimeStamp
    It uses two features of interest to you:

    1. The Blocks > Signal Producers > timeStamp block creates a formatted text string containing the current date and time and is assigned to the VisSim variable 'DAQfile'.
    2. The Blocks > Signal consumers > export block allows macro expansion in the file name field by surrounding the variable name with $(). It contains $(DAQfile) as the file name, so the $(DAQFILE) is replaced with DAQfile variable which contains the output of the timeStamp block.

    To control output file contents,use the built-in variable $lastPass to enable the export block (with External Trigger enabled). If append mode is not activated, you will get just the last value of the last iteration.

    To access a given column in a 2D matrix, use the VisSim Blocks > Nonlinear > map block (which provides 1D, 2D or 3D table lookup, and can take a .csv file as a data source). Then you can use the current experiment ID to index the column, and use your independent variable to index the row. VisSim will provide interpolation if desired.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by adeptuk on Thu, 06/02/2011 - 19:46.

    Make sure to select Perform Optimization from the System->Optimization Properties window, and select the number of runs you want to do.

    The built in variable $runCount keeps track of which run you are on. This can be used to change the input data via Case or Merge block, if this is required.