## Search found 204 matches

- 1 day ago
- Forum: Syntax
- Topic: random arrays in a table
- Replies:
**2** - Views:
**30**

### Re: random arrays in a table

Hi Here is a small example with uniformly distributed random date set i /r1*r3/, j /c1*c3/, iter /1*3/; parameter randval(i,j) Random values, randvalloop(iter, i,j) Store the random values; * Set uniform random values between 1 and 10 * and set the seed so we can reproduce the results $set seed 1234...

- 1 day ago
- Forum: Modeling
- Topic: MPSGE Soluition
- Replies:
**1** - Views:
**18**

### Re: MPSGE Soluition

Hi You use the wrong index for investments: in your table, it is indexed by "SI", and in your model by "S-I". - You should force GAMS to check your table on errors like these by defining SAM over the set of all SAM elements. E.g.: set ac All SAM elements /a_min, apetroil, a_ael, ane c_min, ... and t...

- 1 day ago
- Forum: Syntax
- Topic: put command
- Replies:
**5** - Views:
**71**

### Re: put command

Hi I only use the f loop because you use K(i,t) in an equation with the additional index f. i and t are on both sides of the assignment but f is missing on the right: loop(f, eq_net9("K", i,f,t) = K.L(i,t); ); If K was also defined over f, you don't have to use a loop to assign values and this would...

- 2 days ago
- Forum: Syntax
- Topic: Urgent HELP! , GDX output in a loop uses old variable values
- Replies:
**1** - Views:
**31**

### Re: Urgent HELP! , GDX output in a loop uses old variable values

Hi You defined the variables over i, j and t, so if you solve the model for a smaller subset, the variables that are not part of the subset aren't changed and keep the values of the previous solve. If you add some lines where you initialize all the variable with EPS loop(... loop(... loop(.. x.L ( i...

- 2 days ago
- Forum: Syntax
- Topic: put command
- Replies:
**5** - Views:
**71**

### Re: put command

just redefine the parameter as
and adjust the export command as follows:
This will correct the order and you will have the output according to equations.

CHeers

Renger

Code: Select all

```
eq_net9(i,f,t, *)
```

Code: Select all

`execute 'gdxxrw results.gdx par=eq_net9 rng=eq_net9!a1 Rdim=3 Cdim=1`

CHeers

Renger

- 3 days ago
- Forum: Syntax
- Topic: put command
- Replies:
**5** - Views:
**71**

### Re: put command

Hi Why use the put command to write to Excel. The best tool for doing this is gdxxrw: Net9(i,f,t)$(Ainc(i,f)=1) .. K(i,t) =e= sum(j$(Ainc(j,f)=-1),K(j,t)) + 2*((R(f)/Zbase)*(P_line(f,t)/Sbase) + (X(f)/Zbase)*(Q_line(f,t)/Sbase)); parameter eq_net9(*,i,f,t); loop(f, eq_net9("K", i,f,t) = K.L(i,t); eq...

- 4 days ago
- Forum: Syntax
- Topic: Loop for objective function
- Replies:
**3** - Views:
**103**

### Re: Loop for objective function

Hi You should rewrite the set j from your model and treat the variables and parameters independent of j. Here an example: set j /1*2/; parameter p(j) Parameter defined over j, pj Scalar to be used in the loop to replace p; p(j) = ord(j); variable OBJ,X; equation objective, eq1; objective.. OBJ =E= x...

- 4 days ago
- Forum: Syntax
- Topic: FORMULATION
- Replies:
**1** - Views:
**58**

### Re: FORMULATION

Hi

How about this:

Cheers

Renger

How about this:

Code: Select all

```
alias(i,j);
equations
eq1(i,k)
eq2(i,k);
eq1(i,k)..
sum(j, x(i,j,k)) =E= sum(j, x(j,i,k));
eq2(i,k)..
sum(j, x(i,j,k)) =E= y(i,k);
```

Renger

- 4 days ago
- Forum: Syntax
- Topic: writing equation problem
- Replies:
**1** - Views:
**57**

### Re: writing equation problem

Hi

If the 1 in your equation is a set element, you should quote it (set elements that are numbers are treated as strings). Futhermore, the equal sign in equations is =E=.

X(i,"1") =E= 0;

Cheers

Renger

If the 1 in your equation is a set element, you should quote it (set elements that are numbers are treated as strings). Futhermore, the equal sign in equations is =E=.

X(i,"1") =E= 0;

Cheers

Renger

- 5 days ago
- Forum: Syntax
- Topic: Loop for objective function
- Replies:
**3** - Views:
**103**

### Re: Loop for objective function

Hi Just remove the index from the objective and save the results in a parameter Set j/1*52/ obj.. z=e= L('1') other constraints.. ( some of them still runs for every j) parameter results(j,*); MODEL test_data /ALL/ ; loop(j, SOLVE test_data USING NLP MINIMIZING z; results(j,"Objective") = z.L; DISPL...