conditional constraint using alias

Problems with modeling
Post Reply
gams_learner58
User
User
Posts: 8
Joined: 2 years ago

conditional constraint using alias

Post by gams_learner58 »

Hi everyone,

I have a set d /NYCHI, NYBOS, NYDC, CHINY, BOSNY, DCNY / which is the set of trips between original points and destinations: NYC to Chicago, NYC to Boston, NYC to DC, and their reverse directions.

I have a variable b which is the budget I need to prepare for my trip. I want to add a constraint that set the budget I need for the trip from NYC to Chicago is equal to the trip from Chicago to NYC; and so on (so basically the direction of the trip doesn't impact the budget). So I'm doing so in GAMS by using 2 parameters, origin and destination that are defined over set d, (NY is 1, Chicago is 2, Boston is 3, and DC is 4).

Code: Select all

Parameter
origin(d)  origin of trip
/NYCHI 1, NYBOS 1, NYDC 1, CHINY 2, BOSNY 3,  DCNY 4/
destination(d) /NYCHI 2, NYBOS 3, NYDC 4, CHINY 1, BOSNY 1, DCNY  1/;
So my constraint is:

Code: Select all

Alias(d,dd);

constraint1(d)$(origin(d)=destination(dd) and origin(dd)=destination(dd)).. b(d) =e= b(dd); 
But doing this I got error 149: Uncontrolled set entered as constant. What did I do wrong here? Any help is greatly appreciated! Thank you!
User avatar
dirkse
Moderator
Moderator
Posts: 215
Joined: 7 years ago
Location: Fairfax, VA

Re: conditional constraint using alias

Post by dirkse »

Hello gams_learner58,

The scheme you've chosen to represent your network seems to be a difficult one. I suggest you looks at the GAMS Tutorial:

https://www.gams.com/latest/docs/UG_Tutorial.html

This will explain many useful things about GAMS. As an added bonus, it includes a convenient and powerful way to represent a network and trips on that network.

I wish you joy in the learning.

-Steve
Post Reply