In the attachment, 1) constraint 12 has variable x(i,t) but how write that constraint? Do I have to specify three variables x, x1, x0? where x is amount produced.

2) constraint 15, How to write last summation part which is multiplied by M? (k=t+1) to (s-1)

Thank you.

## Equation

### Re: Equation

Hi Omi

1) Only X^0 seems to be an additional variable. X^(-1) is just 1/X.

2) just multiply it with the sum?

Cheers

Renger

BTW: You should start submitting your own code by now, so people can answer your questions more easily building on what you submit.

1) Only X^0 seems to be an additional variable. X^(-1) is just 1/X.

2) just multiply it with the sum?

Cheers

Renger

BTW: You should start submitting your own code by now, so people can answer your questions more easily building on what you submit.

____________________________________

Enjoy modeling even more: Read my blog on modeling at The lazy economist

Enjoy modeling even more: Read my blog on modeling at The lazy economist

### Re: Equation

Hello Renger,

Thank you for your response.

This is the code I tried to write for the above constraints 12 to 15.

is this correct?

x is a production amount for product j and I want to split this amount.

Thank you for your response.

This is the code I tried to write for the above constraints 12 to 15.

is this correct?

x is a production amount for product j and I want to split this amount.

Code: Select all

```
ct3(j,t)..x(j,t)=e=x1(j,t)+x0(j,t);
ct4(j,t)..x1(j,t)=l=M*z(j,t);
ct5(j,t)..x0(j,t)=g=mi*(sum((jj),U(jj,j,t)-z(j,t+1)));
ct6(j,t,s)..x0(j,t)+sum(k$(ord(k)=ord(t)+1),x1(j,k))=g=mi*sum(jj,U(jj,j,t))-M*(sum(k$(ord(k)=ord(t)+1),R(k))+1-R(s));
```

### Re: Equation

Hi Omi

It looks fine to me. If you not sure, if the equation does the right thing, you could initialize the variables in the equations to some values, and define checking parameters to see what they produce.

Here a small example:

Check should now have 4 as value. You could do the same thing with the equations of your model.

Cheers

Renger

BTW: If you sent code, make sure it runs. In order to check your equations by running the code, I had to make some assumptions and so it is hard to say if the equations are really correct.

I had to add the following to be able to run the code:

It looks fine to me. If you not sure, if the equation does the right thing, you could initialize the variables in the equations to some values, and define checking parameters to see what they produce.

Here a small example:

Code: Select all

```
set i /1*4/;
variable X(i), OBJ;
equation c1;
c1.. OBJ =E= sum(i, X(i));
* Checking the equations
X.L(i) = 1;
parameter check;
check = sum(i, X.L(i));
display check;
```

Cheers

Renger

BTW: If you sent code, make sure it runs. In order to check your equations by running the code, I had to make some assumptions and so it is hard to say if the equations are really correct.

I had to add the following to be able to run the code:

Code: Select all

```
set i /1*4/, t /1*4/, j /1*2/;
alias(k,s,t);
variables r(k), x(j,t), x1(j,t), x0(j,t), z(j,t);
parameter M /1000/, mi /199/;
parameter u(j,j,t);
alias(j,jj);
equations ct3, ct4, ct5,ct6;
```

____________________________________

Enjoy modeling even more: Read my blog on modeling at The lazy economist

Enjoy modeling even more: Read my blog on modeling at The lazy economist