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:
Variable_Result(run, param1, param2) := Variable(param1,param2);
It’s in the procedure “RunMonteCarlo” in the attached file.
But, it doesn’t work. Any idea?
Best answer by Marcel HuntingView original
@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.
@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:
If you change the definition of UnitTransportCostMC to
then the solution will change some times.
@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
Not sure if you are working on this locally or on cloud, but if the later, I suggest you read:
About breaking up into smaller jobs, which I imagine you do in a MC simulation.
@luispinto . This particular exercise is local. But, we’ll do real projects in cloud.