Page 1 of 1

### adding more constraint to gams

Posted: Wed Feb 12, 2020 4:12 am
Hi,

I look into adding some additional bounds/constraints to following MODEL (program is part of simple moral hazard situation :idea:3 equations,3 variables-
(i)U
(ii &iii) w(x) is variable while argument x takes 2 values-High Investment,Low investment) ;
r(x) has fixed value)

Code: Select all

``````[code]obj..           U =e= sum((x,y), dummy(y)*p(x,y)*(r(x) - w(x)));
pc(y)..         (sum(x,p(x,y)*sqrt(w(x)))-d(y))*dummy(y) =g= 0;
ic(v,y)..       ((sum(x,p(x,v)*sqrt(w(x)))-d(v))
-(sum(x,p(x,y)*sqrt(w(x)))-d(y)))*dummy(v) =g= 0;``````
[/code]

r(x) & w(x) are related as below;
1.3w(x) < r(x) < 1.6 w(x)
How I can put this in my program.

I can send full program if required.

THANX IN ADVANCE (please neglect any numerical twists due to present fixed numbers-I am looking for how to capture bound/constraint into Model where argument is a set)

ABRAHAM

### Re: adding more constraint to gams

Posted: Wed Feb 12, 2020 7:53 am
Hi
You could just split the constraint in:

Code: Select all

``````upperb(x)..  1.3 * w(x)  =L=r(x);
lowerb(x)..   r(x) =L= 1.6 * w(x);
``````
Cheers
Renger

### Re: adding more constraint to gams

Posted: Fri Feb 14, 2020 9:05 pm
Dear Renger,
My great thanks for that –It worked;

Code: Select all

``````obj..   	U =e= sum((x,y), dummy(y)*p(x,y)*(r(x) - w(x)));
pc(y)..	 	(sum(x,p(x,y)*sqrt(w(x)))-d(y))*dummy(y) =g= 0;
ic(v,y)..	((sum(x,p(x,v)*sqrt(w(x)))-d(v))
-(sum(x,p(x,y)*sqrt(w(x)))-d(y)))*dummy(v) =g= 0;

upperb(x).. 1.2*w(x) =l= r(x);
lowerb(x)..r(x) =l= 1.6*w(x);``````
For my program,I need to extend it to be 2-dimensions[(w(x,y),d(x,y) instead of 1-dimension[w(x),d(x)] as follows;(so variables earlier decalred as parameter-now in table)

Code: Select all

``````obj..   	U =e= sum((x,y), (dummy(y)*p(x,y)*(r(x,y) - w(x,y))));
pc(y)..	 	(sum(x,p(x,y)*(sqrt(w(x,y))-d(x,y))))*dummy(y) =g= 0;
ic(v,y)..	((sum(x,p(x,v)*(sqrt(w(x,v))-d(x,v))))
-(sum(x,p(x,y)*(sqrt(w(x,v))-d(x,y)))))*dummy(v) =g= 0;

upperb(x,y).. 1.2*w(x,y) =l= r(x,y);
lowerb(x,y)..r(x,y) =l= 1.6*w(x,y);``````
I checked it in GAMS by putting same values in tables (means like

Code: Select all

``````Table r(x,y)    agent's cost
low     high
failure 13       13
success 45       45
;``````
And checked output-it is same as before and it means it is correct-I need to change to different values later.
Do you see any logical incorrectness in this approach.
Best regards
Abraham

### Re: adding more constraint to gams

Posted: Sat Feb 15, 2020 9:51 am
looks fine.
R