Code: Select all

```
vn1(i)$(ord(i) = cn1) = k2;
vn2(i)$(ord(i) = cn2) = k1;
```

- 2 weeks ago
- Forum: Modeling
- Topic: exchange the elements of two sets
- Replies:
**6** - Views:
**279**

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

Renger

Code: Select all

```
vn1(i)$(ord(i) = cn1) = k2;
vn2(i)$(ord(i) = cn2) = k1;
```

- 2 weeks ago
- Forum: Modeling
- Topic: exchange the elements of two sets
- Replies:
**6** - Views:
**279**

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; vn2("3") = 4; vn2("4") = 6; vn2("5") = 8; vn2("6...

- 2 weeks ago
- Forum: Modeling
- Topic: exchange the elements of two sets
- Replies:
**6** - Views:
**279**

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):

Renger

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;
```

- 1 month ago
- Forum: Syntax
- Topic: how to write the row of sets
- Replies:
**11** - Views:
**653**

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 ...

- 1 month ago
- Forum: Syntax
- Topic: how to write the row of sets
- Replies:
**11** - Views:
**653**

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 "..". Furthermore...

- 2 months ago
- Forum: Syntax
- Topic: how to write the row of sets
- Replies:
**11** - Views:
**653**

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

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

- 2 months ago
- Forum: Syntax
- Topic: Create relationship between sets
- Replies:
**4** - Views:
**332**

Hi

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

Cheers

Renger

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);
```

Renger

- 2 months ago
- Forum: Syntax
- Topic: Enter cyclic parameters
- Replies:
**9** - Views:
**854**

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

- 2 months ago
- Forum: Syntax
- Topic: Enter cyclic parameters
- Replies:
**9** - Views:
**854**

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

- 2 months ago
- Forum: Modeling
- Topic: Linearisation of Bilinear Terms Using McCormick Envelopes
- Replies:
**1** - Views:
**269**

Hi If you sum over f in your equations, the equation can't have the index f in it. z(n,i,f) =E= q*sum(f, stream(n,i, f)); Relax1(n,i,f).. z(n,i,f) =E= q*sum(f, stream(n,i, f)) should then be variable z(n,i) equations eq3(n,i), relax1(n,i); eq3.. z(n,i) =E= q*sum(f, stream(n,i, f)); Relax1(n,i).. z(n...