Search found 108 matches
- 6 years ago
- Forum: Syntax
- Topic: error 148 dimension different
- Replies: 1
- Views: 6997
Re: error 148 dimension different
For question 1: actualYear(yearSet) is to be able to do these type of numerical comparisons, which, as you have seen, you are not able to do on set elements directly: yearSet$[actualYear(yearSet)<2021 and actualYear(yearSet)>2019] vs Year$[Year<2021 and Year>2019] Repeating my reply: think of sets a...
- 6 years ago
- Forum: Syntax
- Topic: Using variable level in a conditional statement
- Replies: 2
- Views: 4493
Re: Using variable level in a conditional statement
Hi, to make a long story short: Having constraints that are enforced or not depending on variable values is a thick topic within optimization. It is not as straightforward as you wish, but not impossible. It usually involves reformulation of this constraints so that they are enforced or relax based ...
- 6 years ago
- Forum: Syntax
- Topic: error 148 dimension different
- Replies: 1
- Views: 6997
Re: error 148 dimension different
Hi, think of sets as just labels, you can't compare their numerical value directly. To do this, you can define a parameter. set yearSet /2018,2028,2038/; parameter Q; variable V,z; Q(yearSet)=1; parameter actualYear(yearSet) /2018 2018,2028 2028,2038 2038/; equation eq1; Eq1.. z=E= sum(yearSet$(actu...
- 6 years ago
- Forum: Syntax
- Topic: Simple question on undirected graphs
- Replies: 5
- Views: 4917
Re: Simple question on undirected graphs
Check out this example, I think it can accomodate what I saw in your code. set i nodes /i1*i10/; alias(i,j); set someSetOfNodes(i),otherSetOfNodes(i); someSetOfNodes(i)=YES$(uniform(0,1)<0.5); otherSetOfNodes(i)=YES$(uniform(0,1)<0.5); set edges(i,j),aTypeOfEdge(i,j),anotherTypeOfEdge(i,j); *connect...
- 6 years ago
- Forum: Syntax
- Topic: Simple question on undirected graphs
- Replies: 5
- Views: 4917
Re: Simple question on undirected graphs
Dear bissi, I guess I'm not following you. But that does not guarantee u(i,j)=u(j,i) without an extra equation. In the approach suggested by me, the variable is actually defined only once for each possible edge in the graph. No need to "guarantee u(i,j)=u(j,i)", because u(j,i) shouldn't ex...
- 6 years ago
- Forum: Modeling
- Topic: dependent set
- Replies: 1
- Views: 2557
Re: dependent set
Simplest approach:
If for some reason this doesn't fit your scheme, there are other things to do.
Code: Select all
set a /a1*a10/,q(a);
parameter howMany /4/;
q(a)=YES$(ord(a)<=howMany);
parameter someParameter;
someParameter(q)=1;
display a,q,someParameter;
- 6 years ago
- Forum: Syntax
- Topic: Simple question on undirected graphs
- Replies: 5
- Views: 4917
Re: Simple question on undirected graphs
A small example, based on the approach of defining edges only between a "lower order" node and a "higher order" node. set i nodes /s1*s10/; alias(i,j); set candedge(i,i),edge(i,i),i_nodes(i),connected(i); binary variable y; variable z; candedge(i,j)$(ord(i)<ord(j))=yes; i_nodes(i...
- 6 years ago
- Forum: Syntax
- Topic: understanding GAMS syntax in a mathematical way
- Replies: 1
- Views: 5017
Re: understanding GAMS syntax in a mathematical way
you mean a constraint defined ? ie
c1.. q=l=someValue;
q.up=someValue;
This would lead to models which are identical on the mathematical level, but NOT on the "software" (GAMS+solver) level.
c1.. q=l=someValue;
q.up=someValue;
This would lead to models which are identical on the mathematical level, but NOT on the "software" (GAMS+solver) level.
- 6 years ago
- Forum: Modeling
- Topic: equations in MIP model
- Replies: 2
- Views: 3273
Re: equations in MIP model
Hi Fady, If both x and y are binary variables, in practice what you are writing has the same feasible region (of course not the same relaxed feasible region) as an inclusive OR. This is usually written: x+y=g=1 Of course you have to think if there is a reason that constraint is written like that. It...
- 6 years ago
- Forum: Syntax
- Topic: understanding GAMS syntax in a mathematical way
- Replies: 1
- Views: 5017
Re: understanding GAMS syntax in a mathematical way
Hi, as you can read in https://www.gams.com/latest/docs/userguides/mccarl/fx.htm , when doing x1.fx=9 actually: ... GAMS sets the lower and upper bound to that value. This means x1.fx=9 is exactly doing x1.lo=9 and x1.up=9 in one statement. Additionaly, this kind of statements (setting variable attr...