LP modelling with Monte Carlo simulation

Problems with modeling
Post Reply
philmax96
User
User
Posts: 3
Joined: 1 year ago

LP modelling with Monte Carlo simulation

Post by philmax96 »

Hello everyone,

I hope you've had a good start to the week!
I want to incorporate a Monte Carlo Simulation in my linear programming model. Based on the minimum, maximum, alpha and beta values I have created 100 random values for my parameters (A, B, C) in an excel datasheet.
However, I am now struggling to specify the parameters with the 100 random values to subsequently run (loop) the model over 100 iterations (with the different random values for the parameters).

Thank you very much in advance I am thankful for any kind of suggestions!

Enclosed:
- GAMS file Test_model (an
DATA_model.xlsx
(26.42 KiB) Downloaded 145 times
LP model for explanatory reasons)
- Excel file with the 100 random values for parameters A,B,C

Thank you very much!

Best wishes,
Philip
TEST_LP.gms
(604 Bytes) Downloaded 150 times
User avatar
bussieck
Moderator
Moderator
Posts: 1042
Joined: 7 years ago

Re: LP modelling with Monte Carlo simulation

Post by bussieck »

You need to work with scalars in the equation algebra and copy the content of A(iter), etc into the scalars. Also this is not an LP. E*F*G is clearly non-linear. For all iterations the optimal solution is 0, but that's besides the point. You asked for the technique. I have attached the modified model.

-Michael
TEST_LP.gms
(851 Bytes) Downloaded 150 times
philmax96
User
User
Posts: 3
Joined: 1 year ago

Re: LP modelling with Monte Carlo simulation

Post by philmax96 »

Dear Michael,

Thank you very much for your help! It's well appreciated! Yes, indeed the model was rubbish :D and more for the purpose to understand how to do it. I've tried to implement the technique in an actual LP model but now I run into the problem of getting error messages concerning the indices in the loop statement (as now variables are also controlled by sets). I don't know how to specify for example land within the loop in a way I don't receive the error code 148.

Code: Select all

rep(iter,'land') = land.l;
Thank you very much in advance!
allocation of land to crops_test.gms
(2.77 KiB) Downloaded 133 times
The Excel input file stays the same.

Best wishes,
Philip
User avatar
bussieck
Moderator
Moderator
Posts: 1042
Joined: 7 years ago

Re: LP modelling with Monte Carlo simulation

Post by bussieck »

land is an indexed variable, i.e. land(i), so you either make a secondary report that is indexed with i, i.e. repi(iter,'land',i) = land.l(i) or add an index to the current rep, i.e. rep(iter,'land',i) = land.l(i) and rep(iter,'prof','') = prof.l;

-Michael
philmax96
User
User
Posts: 3
Joined: 1 year ago

Re: LP modelling with Monte Carlo simulation

Post by philmax96 »

Dear Michael,

Thank you very much for your suggestions! The issues with the indices in the loop file are gone now. However, I am stuck now assigning the random values for each iteration to the parameters. I assume they are not loaded correctly as the GDX file looks alright to me (enclosed) but when displaying the parameter A,B,C they are all zero.
grafik.png

Also when I use the
$loaddc
I get the error message 649 domain violation when loading from gdx file. Do you have an idea of how to fix that?

Thank you again for your help!

Best wishes,
Philip
DATA_model.xlsx
(24.44 KiB) Downloaded 128 times
DATA_model.gdx
(4.14 KiB) Downloaded 130 times
TEST_LP.gms
(911 Bytes) Downloaded 134 times
Post Reply