Skip to main content

Hi, 

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?

Thanks,

Zulfan

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.


Hi Marcel @Marcel Hunting

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

uniform(0.5,1.5)*UnitTransportCost(p,c);

then the solution will change some times.


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


Hello @zulfan.adiputra 

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.

Cheers,


Thanks @luispinto . This particular exercise is local. But, we’ll do real projects in cloud. 

Thanks


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator