Urgent Help Needed: New GAMS user

Dear All,

I am new user of GAMS. I modeled my optimization formulation in GAMS but could not achieve expected results. I earnestly request you if kindly checked my code to see if there is any error and suggest accordingly. It is difficult for me write down the formulations with this email. For this reason, I am attaching my formulation in a powerpoint file. please find the attached powerpoint file. I am also copied my code here:

set i ‘section’ /
A
B
C
D
E
F
G
H
I
J

/;

set t ‘years in the planning horizon’ /
year1*year5
/;
alias(t,j);

set p(t) /year1*year4/;



set m ‘maintenance strategies’ /
NN
PM
LR
MR
HR
/;

set m1(m)‘rehabilitation’/LR, MR, HR/;
set m2(m)‘preventive maintenance’/PM/;
parameter yn(t) ‘year number’;
yn(t) = ord(t);




parameter l(i)‘length of section i miles’/
A 1.0
B 1.0
C 1.0
D 1.0
E 1.0
F 1.0
G 1.0
H 1.0
I 1.0
J 1.0

/;

table u(i,m)‘unit cost of maintenance strategy m on section i in 1000$/mile’

NN PM LR MR HR
A 0 34 202 277 516

B 0 34 202 277 516

C 0 34 202 277 516

D 0 34 202 277 516

E 0 34 202 277 516

F 0 34 202 277 516

G 0 34 202 277 516

H 0 34 202 277 516

I 0 34 202 277 516

J 0 34 202 277 516


;

parameter r(i) ‘section deterioration rate’ /

A 0.05
B 0.05
C 0.05
D 0.05
E 0.05
F 0.05
G 0.05
H 0.05
I 0.05
J 0.05


/;

table pi(i, m) ‘deterioration rate’

NN PM LR MR HR
A 0.05 .03 .02 .01 .005

B 0.05 .03 .02 .01 .005

C 0.05 .03 .02 .01 .005

D 0.05 .03 .02 .01 .005

E 0.05 .03 .02 .01 .005

F 0.05 .03 .02 .01 .005

G 0.05 .03 .02 .01 .005

H 0.05 .03 .02 .01 .005

I 0.05 .03 .02 .01 .005

J 0.05 .03 .02 .01 .005


;

Parameter CSNet /80/;

parameter Co(i) ‘initial condition score of section i’ /

A 65
B 75
C 85
D 65
E 55
F 75
G 70
H 90
I 65
J 95

/;

table e(i,m)‘improvement in condition score for section i receiving treatment m’

NN PM LR MR HR
A 0 3 15 25 40

B 0 3 15 25 40

C 0 3 15 25 40

D 0 3 15 25 40

E 0 3 15 25 40

F 0 3 15 25 40

G 0 3 15 25 40

H 0 3 15 25 40

I 0 3 15 25 40

J 0 3 15 25 40


;
parameter lambda ‘weight on objective function’
/0.7/;
parameter q1 ‘minimum condition score requirement for each road section’
/60/;

parameter q2 ‘maximum possible road condition score’ /100/;
parameter Q ‘minimum network condition score’ /74/;
parameter g ‘maximum number of maintenance allowed for each road section over the design period’
/5/;

parameter meanbudget(t) ‘mean budget for year t in thousands $’ /

year1 690
year2 370
year3 700
year4 350
year5 500
/;





variables
C(i,t)‘road condition score for section i at year t’
CS(t) ‘average network condition score at year t’
x(i,t,m)‘decision variable’
obj ‘objective’
Cpos(t)‘part of deviation’
Cneg(t)‘n part of deviation’;

binary variable x;

equations
objective ‘objective function’
budget(t) ‘budget constraint’
condition(i,t) ‘condition score’
mincondition(i,t) ‘minimum condition score’
maxcondition(i,t) ‘maximum condition’
mincondnet(t) ‘minimum network condition’
maxtreatment(i) ‘maximum number of treatment allowed’
avgcondition(t)‘average network condition score’
deviation(t) ‘constraint for deviation’
Cpositive(t) ‘cpos greater than zero’
Cnegative(t) ‘cneg greater than zero’
rehab(i) ‘rehabilitation allowed’
pm(i)‘preventive maintenance allowed’
var(i,t) ‘varible constraint’ ;

objective … obj =e= (lambda*(sum(t,CS(t))/(card(t)))+(1-lambda)*(-sum(t, (Cpos(t)+Cneg(t)))));
budget(t) … sum((i,m), l(i)*u(i,m)x(i,t,m)) =l= (meanbudget(t));
condition(i,t) … C(i,t) =e= Co(i)
((1-r(i))yn(t)) + sum((j,m)$(ord(j)le ord(t)), x(i,j,m)e(i,m)((1-pi(i,m))((yn(t)- ord(j)))));
mincondition(i,t) … C(i,t) =g= q1;
maxcondition(i,t) … C(i,t) =l= q2;
avgcondition(t)… CS(t) =e=(sum(i,C(i,t)*l(i)))/(sum(i,l(i)));
mincondnet(t) … CS(t)=g= Q;
maxtreatment(i) … sum((t,m), x(i,t,m)) =l= g;
deviation(t)… Cpos(t) - Cneg(t)+ CS(t) =e= CS(t+1);
Cpositive(t)… Cpos(t)=g=0;
Cnegative(t)… Cneg(t)=g=0;
rehab(i)…sum((t,m1),x(i,t,m1))=l=1;
pm(i)…sum((t,m2),x(i,t,m2))=l=2;

var(i,t) … sum(m, x(i,t,m)) =e= 1;

model thesisdeterministic /all/;
solve thesisdeterministic maximizing obj using mip;
display x.l, x.m;
display C.l, C.m;

I know it time consuming to help me. I hope there is anyone who can help me out.

Thanks,

Al Amin
PhD Student
University of Texas at Austin


GAMS_HELP_FORMULATION.pptx (637 KB)

Hi,

Good news is that your model compiles and actually produced a feasible solution. So you have a very good starting point. Now you need to debug your model so it produces the correct results. You say you don’t “achieve expected results”. This can be many things. For example, you get an optimal solution with objective x, but you have a solution with objective y with y>x which suggests your optimization did not produce the optimum (=maximum). In this case, I suggest to add the option “option optcr=0;” to your code, which sets the optimality tolerance to 0, default is 0.1, so you might get suboptimal solutions in default mode. If after this step the objective xx is still smaller than y you should check your solution that produces y and see why GAMS (or better the solver) thinks the solution is no good. For that you set the variables level (e.g. x.l(i,t,m) = …:wink: to the solution values in the optimal solution. Since you have only 192 variable, you will find some way doing this even if you need to do this all by hand. Next you turn on “option limrow=99999;”. This produces a complete equation listing of all constraints in the listing file and that tells you about the violated constraints (search for INFES):

---- condition =E= condition score
condition(A,year1)… C(A,year1) - 3x(A,year1,PM) - 15x(A,year1,LR)

  • 25x(A,year1,MR) - 40x(A,year1,HR) =E= 61.75 ;
    (LHS = -18, INFES = 79.75 ****)

Either your solution y is indeed not feasible or your implementation of that constraint is incorrect.

If the solution from the GAMS optimization has objective x actually bigger than the known optimum solution y (x>y) and you trust the y, you need to independently check the solution that produced x for correctness. Since you have a algebra (in your power point) you can check which constraint is violated and you need to go back to your GAMS implementation of this constraint.

If your solution shows unwanted properties which you think you have addressed by some constraint you need to investigate the constraint that address the unwanted property and why the solution does not violate this constraint.

I am pretty sure you will find some help in this list if you prepare your issue in this way and get stuck along the way.

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator


On Wednesday, October 1, 2014 2:43:37 PM UTC-4, Al - Amin wrote:

Dear All,

I am new user of GAMS. I modeled my optimization formulation in GAMS but could not achieve expected results. I earnestly request you if kindly checked my code to see if there is any error and suggest accordingly. It is difficult for me write down the formulations with this email. For this reason, I am attaching my formulation in a powerpoint file. please find the attached powerpoint file. I am also copied my code here:

set i ‘section’ /
A
B
C
D
E
F
G
H
I
J

/;

set t ‘years in the planning horizon’ /
year1*year5
/;
alias(t,j);

set p(t) /year1*year4/;



set m ‘maintenance strategies’ /
NN
PM
LR
MR
HR
/;

set m1(m)‘rehabilitation’/LR, MR, HR/;
set m2(m)‘preventive maintenance’/PM/;
parameter yn(t) ‘year number’;
yn(t) = ord(t);




parameter l(i)‘length of section i miles’/
A 1.0
B 1.0
C 1.0
D 1.0
E 1.0
F 1.0
G 1.0
H 1.0
I 1.0
J 1.0

/;

table u(i,m)‘unit cost of maintenance strategy m on section i in 1000$/mile’

NN PM LR MR HR
A 0 34 202 277 516

B 0 34 202 277 516

C 0 34 202 277 516

D 0 34 202 277 516

E 0 34 202 277 516

F 0 34 202 277 516

G 0 34 202 277 516

H 0 34 202 277 516

I 0 34 202 277 516

J 0 34 202 277 516


;

parameter r(i) ‘section deterioration rate’ /

A 0.05
B 0.05
C 0.05
D 0.05
E 0.05
F 0.05
G 0.05
H 0.05
I 0.05
J 0.05


/;

table pi(i, m) ‘deterioration rate’

NN PM LR MR HR
A 0.05 .03 .02 .01 .005

B 0.05 .03 .02 .01 .005

C 0.05 .03 .02 .01 .005

D 0.05 .03 .02 .01 .005

E 0.05 .03 .02 .01 .005

F 0.05 .03 .02 .01 .005

G 0.05 .03 .02 .01 .005

H 0.05 .03 .02 .01 .005

I 0.05 .03 .02 .01 .005

J 0.05 .03 .02 .01 .005


;

Parameter CSNet /80/;

parameter Co(i) ‘initial condition score of section i’ /

A 65
B 75
C 85
D 65
E 55
F 75
G 70
H 90
I 65
J 95

/;

table e(i,m)‘improvement in condition score for section i receiving treatment m’

NN PM LR MR HR
A 0 3 15 25 40

B 0 3 15 25 40

C 0 3 15 25 40

D 0 3 15 25 40

E 0 3 15 25 40

F 0 3 15 25 40

G 0 3 15 25 40

H 0 3 15 25 40

I 0 3 15 25 40

J 0 3 15 25 40


;
parameter lambda ‘weight on objective function’
/0.7/;
parameter q1 ‘minimum condition score requirement for each road section’
/60/;

parameter q2 ‘maximum possible road condition score’ /100/;
parameter Q ‘minimum network condition score’ /74/;
parameter g ‘maximum number of maintenance allowed for each road section over the design period’
/5/;

parameter meanbudget(t) ‘mean budget for year t in thousands $’ /

year1 690
year2 370
year3 700
year4 350
year5 500
/;





variables
C(i,t)‘road condition score for section i at year t’
CS(t) ‘average network condition score at year t’
x(i,t,m)‘decision variable’
obj ‘objective’
Cpos(t)‘part of deviation’
Cneg(t)‘n part of deviation’;

binary variable x;

equations
objective ‘objective function’
budget(t) ‘budget constraint’
condition(i,t) ‘condition score’
mincondition(i,t) ‘minimum condition score’
maxcondition(i,t) ‘maximum condition’
mincondnet(t) ‘minimum network condition’
maxtreatment(i) ‘maximum number of treatment allowed’
avgcondition(t)‘average network condition score’
deviation(t) ‘constraint for deviation’
Cpositive(t) ‘cpos greater than zero’
Cnegative(t) ‘cneg greater than zero’
rehab(i) ‘rehabilitation allowed’
pm(i)‘preventive maintenance allowed’
var(i,t) ‘varible constraint’ ;

objective … obj =e= (lambda*(sum(t,CS(t))/(card(t)))+(1-lambda)*(-sum(t, (Cpos(t)+Cneg(t)))));
budget(t) … sum((i,m), l(i)*u(i,m)x(i,t,m)) =l= (meanbudget(t));
condition(i,t) … C(i,t) =e= Co(i)
((1-r(i))yn(t)) + sum((j,m)$(ord(j)le ord(t)), x(i,j,m)e(i,m)((1-pi(i,m))((yn(t)- ord(j)))));
mincondition(i,t) … C(i,t) =g= q1;
maxcondition(i,t) … C(i,t) =l= q2;
avgcondition(t)… CS(t) =e=(sum(i,C(i,t)*l(i)))/(sum(i,l(i)));
mincondnet(t) … CS(t)=g= Q;
maxtreatment(i) … sum((t,m), x(i,t,m)) =l= g;
deviation(t)… Cpos(t) - Cneg(t)+ CS(t) =e= CS(t+1);
Cpositive(t)… Cpos(t)=g=0;
Cnegative(t)… Cneg(t)=g=0;
rehab(i)…sum((t,m1),x(i,t,m1))=l=1;
pm(i)…sum((t,m2),x(i,t,m2))=l=2;

var(i,t) … sum(m, x(i,t,m)) =e= 1;

model thesisdeterministic /all/;
solve thesisdeterministic maximizing obj using mip;
display x.l, x.m;
display C.l, C.m;

I know it time consuming to help me. I hope there is anyone who can help me out.

Thanks,

Al Amin
PhD Student
University of Texas at Austin


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Dear all,
Can any one give some gams code examples for power system expansion planning.I m new to GAMS so i need some help.

On Thu, Oct 2, 2014 at 6:45 PM, Savitsky Andre wrote:




HI



This is strange but there are no errors

I received optimal solution from You model

Are this what You expect or not this another question

But OPTIMAL SOLUTION was found and there are no errors in model code (look at attachment)

all the best

P.S. You can find Daene Makkiney from civil engineering in University and he has nice book GAMS for BEGINER (he is author)


\

Dear All,

I am new user of GAMS. I modeled my optimization formulation in GAMS but could not achieve expected results. I earnestly request you if kindly checked my code to see if there is any error and suggest accordingly. It is difficult for me write down the formulations with this email. For this reason, I am attaching my formulation in a powerpoint file. please find the attached powerpoint file. I am also copied my code here:

set i ‘section’ /
A
B
C
D
E
F
G
H
I
J

/;

set t ‘years in the planning horizon’ /
year1*year5
/;
alias(t,j);

set p(t) /year1*year4/;

set m ‘maintenance strategies’ /
NN
PM
LR
MR
HR
/;

set m1(m)‘rehabilitation’/LR, MR, HR/;
set m2(m)‘preventive maintenance’/PM/;
parameter yn(t) ‘year number’;
yn(t) = ord(t);

parameter l(i)‘length of section i miles’/
A 1.0
B 1.0
C 1.0
D 1.0
E 1.0
F 1.0
G 1.0
H 1.0
I 1.0
J 1.0

/;

table u(i,m)‘unit cost of maintenance strategy m on section i in 1000$/mile’

NN PM LR MR HR
A 0 34 202 277 516

B 0 34 202 277 516

C 0 34 202 277 516

D 0 34 202 277 516

E 0 34 202 277 516

F 0 34 202 277 516

G 0 34 202 277 516

H 0 34 202 277 516

I 0 34 202 277 516

J 0 34 202 277 516

;

parameter r(i) ‘section deterioration rate’ /

A 0.05
B 0.05
C 0.05
D 0.05
E 0.05
F 0.05
G 0.05
H 0.05
I 0.05
J 0.05

/;

table pi(i, m) ‘deterioration rate’

NN PM LR MR HR
A 0.05 .03 .02 .01 .005

B 0.05 .03 .02 .01 .005

C 0.05 .03 .02 .01 .005

D 0.05 .03 .02 .01 .005

E 0.05 .03 .02 .01 .005

F 0.05 .03 .02 .01 .005

G 0.05 .03 .02 .01 .005

H 0.05 .03 .02 .01 .005

I 0.05 .03 .02 .01 .005

J 0.05 .03 .02 .01 .005

;

Parameter CSNet /80/;

parameter Co(i) ‘initial condition score of section i’ /

A 65
B 75
C 85
D 65
E 55
F 75
G 70
H 90
I 65
J 95

/;

table e(i,m)‘improvement in condition score for section i receiving treatment m’

NN PM LR MR HR
A 0 3 15 25 40

B 0 3 15 25 40

C 0 3 15 25 40

D 0 3 15 25 40

E 0 3 15 25 40

F 0 3 15 25 40

G 0 3 15 25 40

H 0 3 15 25 40

I 0 3 15 25 40

J 0 3 15 25 40

;
parameter lambda ‘weight on objective function’
/0.7/;
parameter q1 ‘minimum condition score requirement for each road section’
/60/;

parameter q2 ‘maximum possible road condition score’ /100/;
parameter Q ‘minimum network condition score’ /74/;
parameter g ‘maximum number of maintenance allowed for each road section over the design period’
/5/;

parameter meanbudget(t) ‘mean budget for year t in thousands $’ /

year1 690
year2 370
year3 700
year4 350
year5 500
/;

variables
C(i,t)‘road condition score for section i at year t’
CS(t) ‘average network condition score at year t’
x(i,t,m)‘decision variable’
obj ‘objective’
Cpos(t)‘part of deviation’
Cneg(t)‘n part of deviation’;

binary variable x;

equations
objective ‘objective function’
budget(t) ‘budget constraint’
condition(i,t) ‘condition score’
mincondition(i,t) ‘minimum condition score’
maxcondition(i,t) ‘maximum condition’
mincondnet(t) ‘minimum network condition’
maxtreatment(i) ‘maximum number of treatment allowed’
avgcondition(t)‘average network condition score’
deviation(t) ‘constraint for deviation’
Cpositive(t) ‘cpos greater than zero’
Cnegative(t) ‘cneg greater than zero’
rehab(i) ‘rehabilitation allowed’
pm(i)‘preventive maintenance allowed’
var(i,t) ‘varible constraint’ ;

objective … obj =e= (lambda*(sum(t,CS(t))/(card(t)))+(1-lambda)*(-sum(t, (Cpos(t)+Cneg(t)))));
budget(t) … sum((i,m), l(i)*u(i,m)x(i,t,m)) =l= (meanbudget(t));
condition(i,t) … C(i,t) =e= Co(i)
((1-r(i))yn(t)) + sum((j,m)$(ord(j)le ord(t)), x(i,j,m)e(i,m)((1-pi(i,m))((yn(t)- ord(j)))));
mincondition(i,t) … C(i,t) =g= q1;
maxcondition(i,t) … C(i,t) =l= q2;
avgcondition(t)… CS(t) =e=(sum(i,C(i,t)*l(i)))/(sum(i,l(i)));
mincondnet(t) … CS(t)=g= Q;
maxtreatment(i) … sum((t,m), x(i,t,m)) =l= g;
deviation(t)… Cpos(t) - Cneg(t)+ CS(t) =e= CS(t+1);
Cpositive(t)… Cpos(t)=g=0;
Cnegative(t)… Cneg(t)=g=0;
rehab(i)…sum((t,m1),x(i,t,m1))=l=1;
pm(i)…sum((t,m2),x(i,t,m2))=l=2;

var(i,t) … sum(m, x(i,t,m)) =e= 1;

model thesisdeterministic /all/;
solve thesisdeterministic maximizing obj using mip;
display x.l, x.m;
display C.l, C.m;

I know it time consuming to help me. I hope there is anyone who can help me out.

Thanks,

Al Amin
PhD Student
University of Texas at Austin

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.

To post to this group, send email to gamsworld@googlegroups.com.

Visit this group at http://groups.google.com/group/gamsworld.

For more options, visit https://groups.google.com/d/optout.

With kindly regards!
Andre Savitsky
E-mail:andresavit@yandex.ru
andre_savit@yahoo.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Reply-to: gamsworld@googlegroups.com

Thank you Savitsky Andre.

On Thursday, October 2, 2014 11:06:13 AM UTC-5, Savitsky Andre wrote:




HI



This is strange but there are no errors

I received optimal solution from You model

Are this what You expect or not this another question

But OPTIMAL SOLUTION was found and there are no errors in model code (look at attachment)

all the best

P.S. You can find Daene Makkiney from civil engineering in University and he has nice book GAMS for BEGINER (he is author)


\

Dear All,

I am new user of GAMS. I modeled my optimization formulation in GAMS but could not achieve expected results. I earnestly request you if kindly checked my code to see if there is any error and suggest accordingly. It is difficult for me write down the formulations with this email. For this reason, I am attaching my formulation in a powerpoint file. please find the attached powerpoint file. I am also copied my code here:

set i ‘section’ /
A
B
C
D
E
F
G
H
I
J

/;

set t ‘years in the planning horizon’ /
year1*year5
/;
alias(t,j);

set p(t) /year1*year4/;

set m ‘maintenance strategies’ /
NN
PM
LR
MR
HR
/;

set m1(m)‘rehabilitation’/LR, MR, HR/;
set m2(m)‘preventive maintenance’/PM/;
parameter yn(t) ‘year number’;
yn(t) = ord(t);

parameter l(i)‘length of section i miles’/
A 1.0
B 1.0
C 1.0
D 1.0
E 1.0
F 1.0
G 1.0
H 1.0
I 1.0
J 1.0

/;

table u(i,m)‘unit cost of maintenance strategy m on section i in 1000$/mile’

NN PM LR MR HR
A 0 34 202 277 516

B 0 34 202 277 516

C 0 34 202 277 516

D 0 34 202 277 516

E 0 34 202 277 516

F 0 34 202 277 516

G 0 34 202 277 516

H 0 34 202 277 516

I 0 34 202 277 516

J 0 34 202 277 516

;

parameter r(i) ‘section deterioration rate’ /

A 0.05
B 0.05
C 0.05
D 0.05
E 0.05
F 0.05
G 0.05
H 0.05
I 0.05
J 0.05

/;

table pi(i, m) ‘deterioration rate’

NN PM LR MR HR
A 0.05 .03 .02 .01 .005

B 0.05 .03 .02 .01 .005

C 0.05 .03 .02 .01 .005

D 0.05 .03 .02 .01 .005

E 0.05 .03 .02 .01 .005

F 0.05 .03 .02 .01 .005

G 0.05 .03 .02 .01 .005

H 0.05 .03 .02 .01 .005

I 0.05 .03 .02 .01 .005

J 0.05 .03 .02 .01 .005

;

Parameter CSNet /80/;

parameter Co(i) ‘initial condition score of section i’ /

A 65
B 75
C 85
D 65
E 55
F 75
G 70
H 90
I 65
J 95

/;

table e(i,m)‘improvement in condition score for section i receiving treatment m’

NN PM LR MR HR
A 0 3 15 25 40

B 0 3 15 25 40

C 0 3 15 25 40

D 0 3 15 25 40

E 0 3 15 25 40

F 0 3 15 25 40

G 0 3 15 25 40

H 0 3 15 25 40

I 0 3 15 25 40

J 0 3 15 25 40

;
parameter lambda ‘weight on objective function’
/0.7/;
parameter q1 ‘minimum condition score requirement for each road section’
/60/;

parameter q2 ‘maximum possible road condition score’ /100/;
parameter Q ‘minimum network condition score’ /74/;
parameter g ‘maximum number of maintenance allowed for each road section over the design period’
/5/;

parameter meanbudget(t) ‘mean budget for year t in thousands $’ /

year1 690
year2 370
year3 700
year4 350
year5 500
/;

variables
C(i,t)‘road condition score for section i at year t’
CS(t) ‘average network condition score at year t’
x(i,t,m)‘decision variable’
obj ‘objective’
Cpos(t)‘part of deviation’
Cneg(t)‘n part of deviation’;

binary variable x;

equations
objective ‘objective function’
budget(t) ‘budget constraint’
condition(i,t) ‘condition score’
mincondition(i,t) ‘minimum condition score’
maxcondition(i,t) ‘maximum condition’
mincondnet(t) ‘minimum network condition’
maxtreatment(i) ‘maximum number of treatment allowed’
avgcondition(t)‘average network condition score’
deviation(t) ‘constraint for deviation’
Cpositive(t) ‘cpos greater than zero’
Cnegative(t) ‘cneg greater than zero’
rehab(i) ‘rehabilitation allowed’
pm(i)‘preventive maintenance allowed’
var(i,t) ‘varible constraint’ ;

objective … obj =e= (lambda*(sum(t,CS(t))/(card(t)))+(1-lambda)*(-sum(t, (Cpos(t)+Cneg(t)))));
budget(t) … sum((i,m), l(i)*u(i,m)x(i,t,m)) =l= (meanbudget(t));
condition(i,t) … C(i,t) =e= Co(i)
((1-r(i))yn(t)) + sum((j,m)$(ord(j)le ord(t)), x(i,j,m)e(i,m)((1-pi(i,m))((yn(t)- ord(j)))));
mincondition(i,t) … C(i,t) =g= q1;
maxcondition(i,t) … C(i,t) =l= q2;
avgcondition(t)… CS(t) =e=(sum(i,C(i,t)*l(i)))/(sum(i,l(i)));
mincondnet(t) … CS(t)=g= Q;
maxtreatment(i) … sum((t,m), x(i,t,m)) =l= g;
deviation(t)… Cpos(t) - Cneg(t)+ CS(t) =e= CS(t+1);
Cpositive(t)… Cpos(t)=g=0;
Cnegative(t)… Cneg(t)=g=0;
rehab(i)…sum((t,m1),x(i,t,m1))=l=1;
pm(i)…sum((t,m2),x(i,t,m2))=l=2;

var(i,t) … sum(m, x(i,t,m)) =e= 1;

model thesisdeterministic /all/;
solve thesisdeterministic maximizing obj using mip;
display x.l, x.m;
display C.l, C.m;

I know it time consuming to help me. I hope there is anyone who can help me out.

Thanks,

Al Amin
PhD Student
University of Texas at Austin

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.

To post to this group, send email to gams...@googlegroups.com.

Visit this group at http://groups.google.com/group/gamsworld.

For more options, visit https://groups.google.com/d/optout.

With kindly regards!
Andre Savitsky
E-mail:a...@yandex.ru
andre...@yahoo.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Thank you Michael.

On Thursday, October 2, 2014 1:17:55 AM UTC-5, Michael Bussieck wrote:

Hi,

Good news is that your model compiles and actually produced a feasible solution. So you have a very good starting point. Now you need to debug your model so it produces the correct results. You say you don’t “achieve expected results”. This can be many things. For example, you get an optimal solution with objective x, but you have a solution with objective y with y>x which suggests your optimization did not produce the optimum (=maximum). In this case, I suggest to add the option “option optcr=0;” to your code, which sets the optimality tolerance to 0, default is 0.1, so you might get suboptimal solutions in default mode. If after this step the objective xx is still smaller than y you should check your solution that produces y and see why GAMS (or better the solver) thinks the solution is no good. For that you set the variables level (e.g. x.l(i,t,m) = …:wink: to the solution values in the optimal solution. Since you have only 192 variable, you will find some way doing this even if you need to do this all by hand. Next you turn on “option limrow=99999;”. This produces a complete equation listing of all constraints in the listing file and that tells you about the violated constraints (search for INFES):

---- condition =E= condition score
condition(A,year1)… C(A,year1) - 3x(A,year1,PM) - 15x(A,year1,LR)

  • 25x(A,year1,MR) - 40x(A,year1,HR) =E= 61.75 ;
    (LHS = -18, INFES = 79.75 ****)

Either your solution y is indeed not feasible or your implementation of that constraint is incorrect.

If the solution from the GAMS optimization has objective x actually bigger than the known optimum solution y (x>y) and you trust the y, you need to independently check the solution that produced x for correctness. Since you have a algebra (in your power point) you can check which constraint is violated and you need to go back to your GAMS implementation of this constraint.

If your solution shows unwanted properties which you think you have addressed by some constraint you need to investigate the constraint that address the unwanted property and why the solution does not violate this constraint.

I am pretty sure you will find some help in this list if you prepare your issue in this way and get stuck along the way.

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator


On Wednesday, October 1, 2014 2:43:37 PM UTC-4, Al - Amin wrote:

Dear All,

I am new user of GAMS. I modeled my optimization formulation in GAMS but could not achieve expected results. I earnestly request you if kindly checked my code to see if there is any error and suggest accordingly. It is difficult for me write down the formulations with this email. For this reason, I am attaching my formulation in a powerpoint file. please find the attached powerpoint file. I am also copied my code here:

set i ‘section’ /
A
B
C
D
E
F
G
H
I
J

/;

set t ‘years in the planning horizon’ /
year1*year5
/;
alias(t,j);

set p(t) /year1*year4/;



set m ‘maintenance strategies’ /
NN
PM
LR
MR
HR
/;

set m1(m)‘rehabilitation’/LR, MR, HR/;
set m2(m)‘preventive maintenance’/PM/;
parameter yn(t) ‘year number’;
yn(t) = ord(t);




parameter l(i)‘length of section i miles’/
A 1.0
B 1.0
C 1.0
D 1.0
E 1.0
F 1.0
G 1.0
H 1.0
I 1.0
J 1.0

/;

table u(i,m)‘unit cost of maintenance strategy m on section i in 1000$/mile’

NN PM LR MR HR
A 0 34 202 277 516

B 0 34 202 277 516

C 0 34 202 277 516

D 0 34 202 277 516

E 0 34 202 277 516

F 0 34 202 277 516

G 0 34 202 277 516

H 0 34 202 277 516

I 0 34 202 277 516

J 0 34 202 277 516


;

parameter r(i) ‘section deterioration rate’ /

A 0.05
B 0.05
C 0.05
D 0.05
E 0.05
F 0.05
G 0.05
H 0.05
I 0.05
J 0.05


/;

table pi(i, m) ‘deterioration rate’

NN PM LR MR HR
A 0.05 .03 .02 .01 .005

B 0.05 .03 .02 .01 .005

C 0.05 .03 .02 .01 .005

D 0.05 .03 .02 .01 .005

E 0.05 .03 .02 .01 .005

F 0.05 .03 .02 .01 .005

G 0.05 .03 .02 .01 .005

H 0.05 .03 .02 .01 .005

I 0.05 .03 .02 .01 .005

J 0.05 .03 .02 .01 .005


;

Parameter CSNet /80/;

parameter Co(i) ‘initial condition score of section i’ /

A 65
B 75
C 85
D 65
E 55
F 75
G 70
H 90
I 65
J 95

/;

table e(i,m)‘improvement in condition score for section i receiving treatment m’

NN PM LR MR HR
A 0 3 15 25 40

B 0 3 15 25 40

C 0 3 15 25 40

D 0 3 15 25 40

E 0 3 15 25 40

F 0 3 15 25 40

G 0 3 15 25 40

H 0 3 15 25 40

I 0 3 15 25 40

J 0 3 15 25 40


;
parameter lambda ‘weight on objective function’
/0.7/;
parameter q1 ‘minimum condition score requirement for each road section’
/60/;

parameter q2 ‘maximum possible road condition score’ /100/;
parameter Q ‘minimum network condition score’ /74/;
parameter g ‘maximum number of maintenance allowed for each road section over the design period’
/5/;

parameter meanbudget(t) ‘mean budget for year t in thousands $’ /

year1 690
year2 370
year3 700
year4 350
year5 500
/;





variables
C(i,t)‘road condition score for section i at year t’
CS(t) ‘average network condition score at year t’
x(i,t,m)‘decision variable’
obj ‘objective’
Cpos(t)‘part of deviation’
Cneg(t)‘n part of deviation’;

binary variable x;

equations
objective ‘objective function’
budget(t) ‘budget constraint’
condition(i,t) ‘condition score’
mincondition(i,t) ‘minimum condition score’
maxcondition(i,t) ‘maximum condition’
mincondnet(t) ‘minimum network condition’
maxtreatment(i) ‘maximum number of treatment allowed’
avgcondition(t)‘average network condition score’
deviation(t) ‘constraint for deviation’
Cpositive(t) ‘cpos greater than zero’
Cnegative(t) ‘cneg greater than zero’
rehab(i) ‘rehabilitation allowed’
pm(i)‘preventive maintenance allowed’
var(i,t) ‘varible constraint’ ;

objective … obj =e= (lambda*(sum(t,CS(t))/(card(t)))+(1-lambda)*(-sum(t, (Cpos(t)+Cneg(t)))));
budget(t) … sum((i,m), l(i)*u(i,m)x(i,t,m)) =l= (meanbudget(t));
condition(i,t) … C(i,t) =e= Co(i)
((1-r(i))yn(t)) + sum((j,m)$(ord(j)le ord(t)), x(i,j,m)e(i,m)((1-pi(i,m))((yn(t)- ord(j)))));
mincondition(i,t) … C(i,t) =g= q1;
maxcondition(i,t) … C(i,t) =l= q2;
avgcondition(t)… CS(t) =e=(sum(i,C(i,t)*l(i)))/(sum(i,l(i)));
mincondnet(t) … CS(t)=g= Q;
maxtreatment(i) … sum((t,m), x(i,t,m)) =l= g;
deviation(t)… Cpos(t) - Cneg(t)+ CS(t) =e= CS(t+1);
Cpositive(t)… Cpos(t)=g=0;
Cnegative(t)… Cneg(t)=g=0;
rehab(i)…sum((t,m1),x(i,t,m1))=l=1;
pm(i)…sum((t,m2),x(i,t,m2))=l=2;

var(i,t) … sum(m, x(i,t,m)) =e= 1;

model thesisdeterministic /all/;
solve thesisdeterministic maximizing obj using mip;
display x.l, x.m;
display C.l, C.m;

I know it time consuming to help me. I hope there is anyone who can help me out.

Thanks,

Al Amin
PhD Student
University of Texas at Austin


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.