I was trying to play around with Monte Carlo simulation in AIMMS. I can save the results from MP.Objective for every run. But, how can I save the solution for every run? I tried to use something like below for every run:
It’s in the procedure “RunMonteCarlo” in the attached file.
But, it doesn’t work. Any idea?
Thanks,
Zulfan
Best answer by Marcel Hunting
Hi @zulfan.adiputra . It seems that the solution is always the same, expect for the objective variable and the (superfluous) variable TotalCostMC. You can check this by printing the constraint listing plus the variables values by setting the following Solvers General options:
'Constraint Listing' to 'At every solve' (or 'At first solve')
'Constraint Listing Variable Values' to 'Print variable values'
If you change the definition of UnitTransportCostMC to
Hi @zulfan.adiputra , if Variable_Result is a variable then it will be emptied before the next solve (because you defined AllVariables as the set of variables for the mathematical program LeastCostTransportPlan, which includes Variable_Result). There are ways to work around that but better would be to make Variable_Result a parameter.
Thanks for this. Indeed, the “Variable_Result” is a parameter. I wrote it wrongly here. So, for every run, I write: Parameter_Result(run, param1, param2) := Variable(param1, param2).
What’s recorded in the Parameter_Result is only the latest solution from the Variable (repeated for all runs). I was hoping to capture the solutions for each solution.
Hi @zulfan.adiputra . It seems that the solution is always the same, expect for the objective variable and the (superfluous) variable TotalCostMC. You can check this by printing the constraint listing plus the variables values by setting the following Solvers General options:
'Constraint Listing' to 'At every solve' (or 'At first solve')
'Constraint Listing Variable Values' to 'Print variable values'
If you change the definition of UnitTransportCostMC to
Hi @Marcel Hunting , so basically what you’re saying is that there is nothing wrong in the code. It’s just the solution is the same for all scenarios. Why didn’t I think of that, hahahaha… thanks a lot