Search found 639 matches

by Renger
3 years ago
Forum: Modeling
Topic: 2 models using the variable of the first as the set of the second
Replies: 8
Views: 6589

Re: 2 models using the variable of the first as the set of the second

Hi If this means that the equation mann(n,n) is also dropped, you could add a flag for this equation parameter flag(n,n) Flag for adding equation; alias(n,an); flag(n,an) = 1; ... mann(n,an)$flag(n,an).. ... solve model 1 flag(n,an)$(qr(n,an) > 0) = 1; solve model 2; I hope this is what you meant. R...
by Renger
3 years ago
Forum: Modeling
Topic: exchange the elements of two sets
Replies: 6
Views: 3600

Re: exchange the elements of two sets

just add the following two lines at the end just before the end of the loop

Code: Select all

  vn1(i)$(ord(i) = cn1) = k2;
  vn2(i)$(ord(i) = cn2) = k1;
Renger
by Renger
3 years ago
Forum: Modeling
Topic: exchange the elements of two sets
Replies: 6
Views: 3600

Re: exchange the elements of two sets

Hi Betul Here is a solution that works (it might not be the most elegant, but it works 8-) set i nodes /1*10/, is /3,5,7/, ib /1,2,4,6,8,9,10/, l /1*1000/; parameter vn1(i), vn2(i); vn1("1") = 3; vn1("2") = 5; vn1("3") = 7; vn2("1") = 1; vn2("2") = 2...
by Renger
3 years ago
Forum: Modeling
Topic: exchange the elements of two sets
Replies: 6
Views: 3600

Re: exchange the elements of two sets

Hi

You can use the uniform and round function to do stuff like this. Perhaps this helps (I am not quite sure what you want to do; an example to explain it would be better):

Code: Select all

set i /1*10/, r(i);

r(i)$(round(uniform(1,11)) = i.val) = YES;

display r;
Renger
by Renger
3 years ago
Forum: Syntax
Topic: how to write the row of sets
Replies: 11
Views: 5954

Re: remove the duplicate item

You have the same kind of problem in equation eqt: you use a lot of indices on the RHS, but z has no indices, nor has the equation itself. You should have the same number of dimensions/indices on both sides and in the equation name. Examples Eq1(j) z(j) =e= a(j)*f; Eq2.. p =e= sum(j, b(j)); Eq3.. t ...
by Renger
3 years ago
Forum: Syntax
Topic: how to write the row of sets
Replies: 11
Views: 5954

Re: remove the duplicate item

Hi Your equation should read cons10(j,n).. a0(j,n) =G= 0; Note, that you always should correct the first error that appears in your code and don't pay too much attention to the errors that follow as they are often caused by the first error. In your case, equation eqt is missing the "..". F...
by Renger
3 years ago
Forum: Syntax
Topic: how to write the row of sets
Replies: 11
Views: 5954

Re: remove the duplicate item

Hi
From your question, it is not clear for me what you are trying to do. Please submit the code that produces the error and write what you want to achieve with your equation that produces an error.
Cheers
Renger
by Renger
3 years ago
Forum: Syntax
Topic: Create relationship between sets
Replies: 4
Views: 2660

Re: Create relationship between sets

Hi
You are aware that you can write j-1 as index?

Code: Select all

set j /j1*j10/;

parameter Job(j), Previousjob(j)

PreviousJob(j) = Job(j-1);
Cheers
Renger
by Renger
3 years ago
Forum: Syntax
Topic: Enter cyclic parameters
Replies: 9
Views: 4958

Re: Enter cyclic parameters

Hi Damaskinos THis works. Sets t /1*55/ k(t) /1*24/ ; Parameter c(t),s(t); s(k) = k.val; c(t) = t.val; display s; display s; loop(t, s(t) = sum(k$(mod(t.val,24) = k.val), s(k)); if((mod(t.val,24) = 0), loop(k$(k.val = card(k)), s(t) = k.val);); ); display s; Cheers Re ger
by Renger
3 years ago
Forum: Syntax
Topic: Enter cyclic parameters
Replies: 9
Views: 4958

Re: Enter cyclic parameters

Hi Damaskinos Just go back to using 24 for the mod function, and add another loop (probably could be done in a more efficient way...): loop(t, D(t) = sum(k$(mod(t.val,24) = k.val), D(k)); if((mod(t.val,24) = 0), loop(k$(k.val = card(k)), D(t) = D(k);); ); Cheers Renger