Search found 639 matches

by Renger
3 years ago
Forum: Modeling
Topic: Loop issue
Replies: 10
Views: 40586

Re: Loop issue

Hi

If you define f over q as a dynamic set (and not an alias), I think you can do it as follows:

Code: Select all

set f(q)  dynamic set;

...

additionalrestriction.. sum(f, K(f))=e=0;
...
loop (q,

solve Model9 MAXIMIZING z using MIP;
	if (z.l gt 0,
    		f(q)$k.l(q) = yes;
	);
);

...
Hope this helps
Renger
by Renger
3 years ago
Forum: Syntax
Topic: Weighted sum method with three objectives
Replies: 4
Views: 3257

Re: Weighted sum method with three objectives

Hi According to me, you will have 55 combinations of weights. I used this code (there might be a more subtle way to do this): set ln1 /1*10/; set cnt /1*110/ Counter; parameter w, w1, w2, w3, delta; parameter counter; * Set the first value (as not calculated in the loop) w("1","1"...
by Renger
3 years ago
Forum: Syntax
Topic: Weighted sum method with three objectives
Replies: 4
Views: 3257

Re: Weighted sum method with three objectives

Hi Kaidr Why don't you use the random number generator and generate a set of random weights? Something like this: set u /1*11/; Option Seed=12 parameter w1(u), w2(u), w3(u), delta(u); w1(u) = uniformInt(0,10); w2(u) = uniformInt(0,10); w3(u) = uniformInt(0,10); delta(u) = w1(u) + w2(u) + w3(u); w1(u...
by Renger
3 years ago
Forum: Modeling
Topic: Adjusting the Table/parameter
Replies: 6
Views: 10359

Re: Adjusting the Table/parameter

Hi It is never a good idea to copy-paste stuff. If you change your table, you have to do it again, and again. I would suggest that you use gdxxrw to read the table in your code directly. If that is not an option, you can save your table from excel into a csv-file and read it with csv2gdx. Cheers Ren...
by Renger
3 years ago
Forum: Modeling
Topic: Loop issue
Replies: 10
Views: 40586

Re: Loop issue

Hi If I look at your code, it looks like you want to achieve the following: - You want to solve your model multiple times - As soon as the variable K is equal to 1, you want to make sure, that it stays zero. In your code you could easily achieve that, by not defining K over your loop and set an if-c...
by Renger
3 years ago
Forum: Syntax
Topic: EXIT CODE =3 , the equation is infes
Replies: 11
Views: 8687

Re: EXIT CODE =3 , the equation is infes

Hi Douglas An MCP model assumes that either the equation binds (is zero) or if this is not the case the complementary variable should be zero. (if the zero-profit condition is not met and there is a negative profit, the quantity produced should be zero). If you bound a variable away from zero, the v...
by Renger
3 years ago
Forum: Modeling
Topic: modelling facility location problem
Replies: 1
Views: 1630

Re: modelling facility location problem

Hi
A table, as Gams tells you, should contain numerical values, not set elements.
I suggest you have a look at the examples in the Gams library on network and facility location problems to learn how to model this kind of problems.
Cheers
Renger
by Renger
3 years ago
Forum: Syntax
Topic: EXIT CODE =3 , the equation is infes
Replies: 11
Views: 8687

Re: EXIT CODE =3 , the equation is infes

Hi Douglas If you don't have an infeasible problem when you fix all variables, then there is a mismatch between your initializated (.L) and your fixed values (.fx). You probably forgot to initialize some of the variables. (if you replace the .fx in your code by .l, you will see that the only infeasi...
by Renger
3 years ago
Forum: Syntax
Topic: EXIT CODE =3 , the equation is infes
Replies: 11
Views: 8687

Re: EXIT CODE =3 , the equation is infes

Hi Douglas If I run your model, I get: ---- QINTfn =E= QINTfn(comagr,secagr).. - 0.404883820662826*QINTA(secagr) + QINT(comagr,secagr) =E= 0 ; (LHS = 0) QINTfn(comagr,seccoa).. QINT(comagr,seccoa) =E= 0 ; (LHS = 0) QINTfn(comagr,secfoo).. - 0.462571849766541*QINTA(secfoo) + QINT(comagr,secfoo) =E= 0...
by Renger
3 years ago
Forum: Syntax
Topic: Error 148 - Dimension Different
Replies: 3
Views: 2608

Re: Error 148 - Dimension Different

Hi k is not interpreted by Gams as an integer (it is a string), so you have to use k.val to get the value. Check the parenthesis very carefully. Build an expression like this in two steps. Write it first without the second sum. Run your code (without solving the model). If that is fine, do the same ...