## Search found 45 matches

- 4 weeks ago
- Forum: Syntax
- Topic: Questions about Summation
- Replies:
**1** - Views:
**116**

### Re: Questions about Summation

Hello, you have many alternatives: sets t /t1*t10/ ; (1) sum(t$(ord(t) ge 2),x(t)) (2) sum(t$(ord(t) ne 9 and ord(t) ne 10),x(t)) =e= 1 sum(t$(ord(t) ge 2 and ord(t) le 7),x(t)) =e= 1 using subsets: sets t /t1*t10/ sum1(t) /t2*t10/ sum2(t) /t1*t8/ sum3(t) /t2*t7/ ; (1) sum(t$sum1(t),x(t)) (2) sum(t$...

- 2 months ago
- Forum: Modeling
- Topic: Problem with Constraint
- Replies:
**1** - Views:
**123**

### Re: Problem with Constraint

Hi, try a Mc Cormick relaxation for bilinear product. This is a linear approximation of a product of two variables. obviously you will find a difference with the exact solution. regards!

- 3 months ago
- Forum: Syntax
- Topic: Calibration by linear interpolation
- Replies:
**3** - Views:
**301**

### Re: Calibration by linear interpolation

hi, try this: lsquaredeq.. lsquared =E= sum((t,year)$(ord(t) eq ceil(ord(year)/5)), power((MATy(year)-MAT.l(t))/MAT.l(t),2) + power((MLy(year)-ML.l(t))/ML.l(t),2) + power((MUy(year)-MU.l(t))/MU.l(t),2) + power((TATMy(year)-TATM.l(t))/TATM.l(t),2) + power((TOCEANy(year)-TOCEAN.l(t))/TOCEAN.l(t),2) );...

- 3 months ago
- Forum: Syntax
- Topic: Calibration by linear interpolation
- Replies:
**3** - Views:
**301**

### Re: Calibration by linear interpolation

Hello, according to your example I think that the final periods correspond to 45 years. A zero-time value is required to complete the 50 years. I can be wrong anyway Bye! This is an example: set t /1*10/ set year Years /1*45/; PARAMETERS E(t) /1 100 2 200 3 300 4 400 5 500 6 600 7 700 8 800 9 900 10...

- 3 months ago
- Forum: Modeling
- Topic: Maximizing the difference in the order of binary variables
- Replies:
**28** - Views:
**1355**

### Re: Maximizing the difference in the order of binary variables

Hi, I do not completely remember your model. I think this can work. eq1(t,tp).. sum(tpp$(ord(tpp) le ord(t)),x(tpp)) =l= ord(tp) + (1-xpos(tp,t))*1440; eq2(t,tp).. sum(tpp$(ord(tpp) le ord(t)),x(tpp)) =g= ord(tp) - (1-xpos(tp,t))*1440; eq3(tp).. sum(t,xpos(tp,t)) =l= 1; eq4(t,tp).. sum(tpp$(ord(tpp)...

- 3 months ago
- Forum: Modeling
- Topic: Maximizing the difference in the order of binary variables
- Replies:
**28** - Views:
**1355**

### Re: Maximizing the difference in the order of binary variables

Hi, x(tp) is the sum of the product between a binary variable and its position, so I suppose that is an integer variable (not binary). Anyway, I think it's better to define it as a continuous variable.

- 3 months ago
- Forum: Syntax
- Topic: how to display the current value of a set
- Replies:
**1** - Views:
**154**

### Re: how to display the current value of a set

Hi, you can try this..

set Yr /1*14/;

scalar YrOrd;

loop(Yr,

YrOrd=ord(Yr);

display YrOrd;

);

or

set Yr /1*14/;

parameter YrOrd(Yr);

loop(Yr,

YrOrd(Yr)=ord(Yr);

);

display YrOrd;

set Yr /1*14/;

scalar YrOrd;

loop(Yr,

YrOrd=ord(Yr);

display YrOrd;

);

or

set Yr /1*14/;

parameter YrOrd(Yr);

loop(Yr,

YrOrd(Yr)=ord(Yr);

);

display YrOrd;

- 3 months ago
- Forum: Modeling
- Topic: Maximizing the difference in the order of binary variables
- Replies:
**28** - Views:
**1355**

### Re: Maximizing the difference in the order of binary variables

Hi, I think you can try with this... eq01(tp).. x(tp) =e= sum(t,xpos(tp,t)*ord(tp)) eq02(tp).. c(tp) =e= sum(t,ypos(tp,t)*ord(tp))}); eq1(tp).. absvalue(tp) =l= x(tp) - c(tp) + (1-p(tp))*M; eq2(tp).. absvalue(tp) =g= x(tp) - c(tp) - (1-p(tp))*M; eq3(tp).. x(tp) - c(tp) =g= -(1-p(tp))*M eq4(tp).. abs...

- 4 months ago
- Forum: Modeling
- Topic: Modeling the absolute value
- Replies:
**21** - Views:
**1912**

### Re: Modeling the absolute value

Hi, the dollar command is used to manipulate the sets. For example, if the restrictions eq1, eq2, eq3 and eq4 does not apply to the last "t": eq1(n,m,t)$(ord(t) ne card(t)).. 1 - z(n,m,t) + z(n,m,t+1) + absvalue(n,m,t) =g= 1; eq2(n,m,t)$(ord(t) ne card(t)).. 1 - z(n,m,t) + 1-z(n,m,t+1) + 1-absvalue(...

- 4 months ago
- Forum: Modeling
- Topic: Modeling the absolute value
- Replies:
**21** - Views:
**1912**

### Re: Modeling the absolute value

Hi, this constraints are equivalent to "sum((n,m,t),abs(z(n,m,t) - z(n,m,t+1)) =l= 2*j" With the command "$" you must decide what happens with the last t eq1(n,m,t).. 1 - z(n,m,t) + z(n,m,t+1) + absvalue(n,m,t) =g= 1; eq2(n,m,t).. 1 - z(n,m,t) + 1-z(n,m,t+1) + 1-absvalue(n,m,t) =g= 1; eq3(n,m,t).. z...