Search found 108 matches
- 7 years ago
- Forum: Syntax
- Topic: how to write the condition (A or B) and C
- Replies: 0
- Views: 4896
Re: how to write the condition (A or B) and C
If you are talking about constraints in the optimization sense (equations + inequations), this is called disjunctive programming, it is kind of a large subtopic of optimization. Some tools: LogMIP: https://www.gams.com/latest/docs/userguides/mccarl/logmip.htm EMP: https://www.gams.com/latest/docs/us...
- 7 years ago
- Forum: Syntax
- Topic: how to get any element from a set
- Replies: 4
- Views: 12621
Re: how to get any element from a set
True. It does not.Does GAMS not distinguish capital and lower letters?
To "populate" a set:
Code: Select all
set A /a1,a2/;
set B(A);
B(A)=YES$(ord(A)=2);
display B;
- 7 years ago
- Forum: Modeling
- Topic: how to control the number of variables
- Replies: 1
- Views: 3937
Re: how to control the number of variables
For more detail: You don't need to declare the domain of the variable (as in variable P(A,B)). You can just write variable p; Then, if the variable appears in the constraints, it will be part of the model. Check out this example: sets A /1*5/ A1(A) /2,3/ variable d,t; equation Q,dummy; Q(A1).. d(a1)...
- 7 years ago
- Forum: Syntax
- Topic: how to update a set
- Replies: 0
- Views: 5107
Re: how to update a set
I adapted the text at https://www.gams.com/latest/docs/userguides/userguide/_u_g__dynamic_sets.html#UG_DynamicSets_SetComplement to your sets "The membership of B4 is set equal to all those in Bi but not in B0. The operation above is equivalent to the following longer way of representation, B4(...
- 7 years ago
- Forum: Syntax
- Topic: loop over two sets
- Replies: 2
- Views: 5522
Re: loop over two sets
this is the correct way:
A(Year)$(ord(Year)<card(Year)) = (card(Year)-1)*card(dset) - (ord(Year)-1)*card(dset);
A(Year)$(ord(Year)<card(Year)) = (card(Year)-1)*card(dset) - (ord(Year)-1)*card(dset);
- 7 years ago
- Forum: Syntax
- Topic: loop over two sets
- Replies: 2
- Views: 5522
Re: loop over two sets
Besides: the loop is actually unnecesary.
C(A,A1) =ceil(B(A, A1)/2);
will just do the trick
C(A,A1) =ceil(B(A, A1)/2);
will just do the trick
- 7 years ago
- Forum: Syntax
- Topic: how to dynamically update a set
- Replies: 0
- Views: 4435
Re: how to dynamically update a set
This is GAMS code to accomplish that:
sets A,B(A);
parameter C(A);
B(A)=YES$(C(A)>0);
sets A,B(A);
parameter C(A);
B(A)=YES$(C(A)>0);
- 7 years ago
- Forum: Syntax
- Topic: how to check if a set is empty
- Replies: 0
- Views: 5344
Re: how to check if a set is empty
Q(A)$A.. is very redundant. Just with Q(A).. Equation Q will be written one time for each member of A. If A is empty, it will never be written. Remember that you can only have empty sets if you choose option $Onempty, indicate dimension and have empty bars. Take this example: $Onempty set A(*) / /; ...
- 7 years ago
- Forum: Syntax
- Topic: loop over two sets
- Replies: 2
- Views: 5522
Re: loop over two sets
Loop part is correct, declarations are not. I took the code to correct syntax (other ways are also possible):
sets
A /a,b,c/
A1 /a1,b1/;
parameter
B(A, A1) /
a.a1 1
a.b1 1
b.a1 2
b.b1 3
c.a1 2
c.b1 3/;
parameter
C(A,A1)
;
loop((A,A1),
C(A,A1) =ceil(B(A, A1)/2);
);
Display C;
sets
A /a,b,c/
A1 /a1,b1/;
parameter
B(A, A1) /
a.a1 1
a.b1 1
b.a1 2
b.b1 3
c.a1 2
c.b1 3/;
parameter
C(A,A1)
;
loop((A,A1),
C(A,A1) =ceil(B(A, A1)/2);
);
Display C;
- 7 years ago
- Forum: Modeling
- Topic: endogenous relational operations require model type dnlp
- Replies: 0
- Views: 7814
Re: endogenous relational operations require model type dnlp
Most likely you have unwillingly introduced a syntax or conceptual error using conditionals involving Variables. (Perhaps a parameter which changed to a variable ?) These are situations (I can tell from the top of my head, they may be more) where you would be prompted to switch the model to DNLP. Th...