Random sampling problem of Stochastic Programming

Problems with modeling
Post Reply
Hefeng Zhai
User
User
Posts: 8
Joined: 6 years ago

Random sampling problem of Stochastic Programming

Post by Hefeng Zhai »

Hello, everyone
when I do a simple SP problem, when running the problem, the result show that unknown keywords sample,can anyone help?
Best regards
The code are as fllows:

variables
y objective
Cvmax valve maximum
Positive Variables
Cv valve;

Scalars P1 "inlet pressure of liquid flow rate" / 1000 /
pho "liquid dentisy" / 1000 /
H "pump head" / 1.3 /
err "tolerance for delivery pressure" / 20 /
D "Pipe diameter" / 0.0762 /
k "pressure drop in the pipe" /9.101e-6/
W "drived power" /31.2/
eff "pump efficiency" /0.5/
r "control valve range" /0.05/
P2 outlet pressure /625/
m flowrate /8.5/
;

Equations OBJ "objective to be minimized"
con1 constraint 1
con2 constraint 2
con3 constraint 3
con4 constraint 4
con5 constraint 5;

OBJ.. y =e= Cvmax;
con1.. P1*pho*sqr(Cv)+pho*H*pho*sqr(Cv)-err*pho*sqr(Cv)-sqr(m)-pho*sqr(Cv)*k*m**1.84/D**5.16-P2*pho*sqr(Cv) =l= 0;
con2.. -P1*pho*sqr(Cv)-pho*H*pho*sqr(Cv)-err*pho*sqr(Cv)+sqr(m)+pho*sqr(Cv)*k*m**1.84/D**5.16+P2*pho*sqr(Cv) =l= 0;

con3.. m*H-eff*W =l= 0;
con4.. Cv-Cvmax =l= 0;
con5.. -Cv+r*Cvmax =l= 0;

Model SP / all /;

File emp / '%emp.info%' /;
put emp '* problem %gams.i%'/;
$onput
randvar m Uniform 5 12
randvar P2 Uniform 250 1000
sample m P2 100 method1
$offput
putclose emp;

Set scen "scenarios" / s1*s100 /;
Parameter
s_m(scen) "flowrate realization by scenario"
s_Cv(scen) "Cv by scenario"
s_P2(scen) "P2 by scenario"
s_rep(scen,*) "scenario probability" / #scen.prob 0/;

Set dict / scen .scenario.''
m .randvar .s_m
P2 .randvar .s_P2
Cv .level .s_Cv
'' .opt .s_rep /;

$onecho > lindo.opt
SVR_LS_ANTITHETIC=method1
SVR_LS_MONTECARLO=method2
SVR_LS_LATINSQUARE=method3
$offecho
SP.optfile=1;

solve SP min y use EMP scenario dict;
Option emp=lindo;
Display s_m, s_P2,s_Cv, s_rep;

Display y.l ;
Mr. Hefeng Zhai
Electric Power Research Institute of China Southern Power Grid, Guangzhou 510663, Guangdong Province, China
No.11,Kexiang Road,Huangpu District,Guangzhou, PR China
Lutz
User
User
Posts: 59
Joined: 7 years ago

Re: Random sampling problem of Stochastic Programming

Post by Lutz »

Hi,

There are some smaller issues in your model (e.g. "Option emp=lindo;" should be set before your solve statement and not afterwards), but I could not reproduce that "sample" is an unknown keyword. Maybe the GAMS version you are using is too old? "Sample" as keyword was introduced with GAMS 24.1.1.

Best regards,
Lutz
Hefeng Zhai
User
User
Posts: 8
Joined: 6 years ago

Re: Random sampling problem of Stochastic Programming

Post by Hefeng Zhai »

Thanks a lot, I will try it.
Best Regards~~
Mr. Hefeng Zhai
Electric Power Research Institute of China Southern Power Grid, Guangzhou 510663, Guangdong Province, China
No.11,Kexiang Road,Huangpu District,Guangzhou, PR China
Post Reply