## Search found 19 matches

- 1 month ago
- Forum: Syntax
- Topic: Loop over strings
- Replies:
**2** - Views:
**296**

### Re: Loop over strings

Won't work like that. The $include is a compile time statement and the loop ( ); is an execute time statement. You can load data before the loop sets i "data sets" j "model set" ; parameter data(i,j); parameter modelparameter(j) include alldata.inc loop(i, modelparameter(j)=0; modelparameter(j)=data...

- 3 months ago
- Forum: Syntax
- Topic: Domain filtering
- Replies:
**3** - Views:
**335**

### Re: Domain filtering

set time /t1*t4/;

set t(time) /t1*t3/;

Variables

A(time)

Equations

Eq1(time)$t(time).. A(time+1)-A(time) =E= 1;

set t(time) /t1*t3/;

Variables

A(time)

Equations

Eq1(time)$t(time).. A(time+1)-A(time) =E= 1;

- 3 months ago
- Forum: Solvers
- Topic: Computational time of model extremely increased
- Replies:
**9** - Views:
**1002**

### Re: Computational time of model extremely increased

$echo mipemphasis 0 > cplex.opt

modelname.optfile = 1;

The first statement writes the cplex options file

the second statement tells gams to use the cplex options file

modelname.optfile = 1;

The first statement writes the cplex options file

the second statement tells gams to use the cplex options file

### Re: LOOP

When you reach 20 the calculation is not executed so a(i+1) is equal to zero. which means it is below 20 and the process starts over again. so you will need to build in a switch that tells you, you have reached your threshold level. Something along these lines will work. Cheers, Gideon Set i /0*100/...

- 5 months ago
- Forum: Solvers
- Topic: Computational time of model extremely increased
- Replies:
**9** - Views:
**1002**

- 5 months ago
- Forum: Syntax
- Topic: how to model abs(variable) linearly
- Replies:
**20** - Views:
**1622**

### Re: how to model abs(variable) linearly

Hi Phallylka,

That's why you use the Steve and I described, so your system remains linear.

Best, Gideon

That's why you use the Steve and I described, so your system remains linear.

Best, Gideon

- 7 months ago
- Forum: Syntax
- Topic: how to model abs(variable) linearly
- Replies:
**20** - Views:
**1622**

### Re: how to model abs(variable) linearly

Yanzhiping, Thet way I initially formulated the response to your question is that you have some sort of variable Q that can be either positive or negative. I assumed you wanted to have the absolute value of Q. If this is not the case I misunderstood your question. If thgis is the case, the code I pr...

- 8 months ago
- Forum: Syntax
- Topic: how to model abs(variable) linearly
- Replies:
**20** - Views:
**1622**

### Re: how to model abs(variable) linearly

Hi Steve,

May I suggest changing equation f into:

f .. sqr(x-cx) + sqr(-y-cy) =L= 1;

This way you y will be negative and it shows better that the abs tricks work

best,

Gideon

May I suggest changing equation f into:

f .. sqr(x-cx) + sqr(-y-cy) =L= 1;

This way you y will be negative and it shows better that the abs tricks work

best,

Gideon

- 9 months ago
- Forum: Syntax
- Topic: how to model abs(variable) linearly
- Replies:
**20** - Views:
**1622**

### Re: how to model abs(variable) linearly

You are making things way to complicated, Suppose Q takes on value 10 then due to the equation Q =e= Qpos -Qneg; Qpos takes on value 10 and Qneg takes on value 0; Suppose Q takes on value -10 then Qpos takes on value 0 and Qneg talkes on value 10; in either case the objective variable Z because of Z...

- 9 months ago
- Forum: Syntax
- Topic: how to model abs(variable) linearly
- Replies:
**20** - Views:
**1622**

### Re: how to model abs(variable) linearly

If you want to define Qneg as negative variable, you have to rearrange the signs in all the equations so it makes sense. Defining both as positive variables is the common way to do this.