## Search found 639 matches

2 months ago
Forum: Syntax
Topic: Loop for objective function
Replies: 33
Views: 8198

### Re: Loop for objective function

Hi The trick is to keep the loop index out of the model equations and assign values to parameters used in the equations within the loop: set t /1*5/ m /1*3/ alias(m,n); set conex(m,n) /1.2,1.3,2.3/; conex(m,n)\$(conex(n,m))=1; ; parameter a(m) /1 2,2 3/; parameter b(m) /1 5,2 4.5/; variables Pm(t),z,...
2 months ago
Forum: Syntax
Topic: Loop for objective function
Replies: 33
Views: 8198

### Re: Loop for objective function

set t /1*5/ m /1*2/; parameter a(m) /1 2,2 3/; parameter b(m) /1 5,2 4.5/; variables Pm(t),z; parameter am, bm, resultsm, resultsmt; equation o1, c1, c2; o1.. z =e= am*sum(t,Pm(t))+bm; c1(t).. Pm(t) =l= 5; c2(t).. Pm(t) =g= 0; model gg /all/; loop(m, am = a(m); bm = b(m); solve gg using lp minimiza...
2 months ago
Forum: Syntax
Topic: Loop for objective function
Replies: 33
Views: 8198

### Re: Loop for objective function

Hi
It is not clear from your post what you intend to do.
You assign the value of a variable to another variable before you solved the model (Pm(t) = P(m,t)) in a loop over m which also doesn't make sense. Pm(t) would get the value of the last m.

CHeers
Renger
3 months ago
Forum: Syntax
Topic: limited sums
Replies: 3
Views: 611

### Re: limited sums

Your question is still not clear to me. The equation is for all i,j,k. I don't understand what you mean by summing is a problem.
Cheers
Renger
3 months ago
Forum: Syntax
Topic: limited sums
Replies: 3
Views: 611

### Re: limited sums

Hi
Looks fine. However, notice that if you are at the last k and the one before that the constraint will read

Code: Select all

``````
last k
y(i,j,k)=l= 1;
* Last k - 1
y(i,j,k)+y(i,j,k+1) =l= 1;
``````
Cheers

Renger
3 months ago
Forum: Modeling
Topic: Loop issue
Replies: 10
Views: 1352

### Re: Loop issue

Hi Sorry, I overlooked something. Just put in the version I sent you the following loop (no need for the additional constraint). loop (q, solve Model9 MAXIMIZING z using MIP; if (z.l gt 0, counter = counter + 1; display "solved",counter, K.L; Eff(j)\$(K.L(j) = 1) = YES; K.FX(j)\$(K.L(j) = 1) = 0; ); )...
3 months ago
Forum: Modeling
Topic: Loop issue
Replies: 10
Views: 1352

### Re: Loop issue

Hi Mateo

I think you don't need the additional constraint. If you find a solution for a DMU, you can fix the K-Variable to zero.
I attached my solution.

CHeers
Renger
Model9 - Loop - Copia.gms
(2.79 KiB) Downloaded 34 times
3 months ago
Forum: Modeling
Topic: Adjusting the Table/parameter
Replies: 6
Views: 651

### Re: Adjusting the Table/parameter

gdxxrw
3 months ago
Forum: Modeling
Topic: Adjusting the Table/parameter
Replies: 6
Views: 651

### Re: Adjusting the Table/parameter

Hi Your tables are all two-dimensional tables, so not many options needed. Work through the examples in the GDXXR documentation (unfortunately, it starts with all options. It is better to start with the examples and if you encounter more difficult tables/problem, you can look through the settings). ...
3 months ago
Forum: Modeling
Topic: Loop issue
Replies: 10
Views: 1352

### Re: Loop issue

What is not working? Send all the files, so I can at least run your model to see what is happening.
Cheers
Renger