Formulating Equation of type x_(n-1) Domain

Hello Everyone,

I am formulating a global optimization MILP. In the formulation, I am struggling in defining indices. I need to model equation of following type:

x = x_(n-1) * t_(n) + 5;

  • where n-1 and n are subscripts.

Please guide me how to model above equation.

Regards,
ZAR

Hi

Assuming your variable is x(n), you can use

x(n) =E=  x_(n-1) * t_(n) + 5;

Although sets are not numbers the expression set_element - 1 can be used to indicat the previous set element.
Furthermore, as for n=1, you have a problem as n(-1) is not part of the model. Therefore, you define the equation as

myeq(n)$(ord(n) > 1)..
x(n) =E=  x_(n-1) * t_(n) + 5;

and fix x(n) wiht X.FX(“1”) = x0.

I hope this helps
Renger

Hi Ranger,
I think, I didn’t define the problem elaborately. Let me redefine it here:

$TITLE Piece-wise Affine Test1

SET n /1, 2, 3/
t /a, b, c, d/
;

FREE VARIABLES z0;

POSITIVE VARIABLES x, y, z1;

BINARY VARIABLES lambda(n);

Parameter P(t) 'Number of Partitions'
/a 0, b 2, c 3, d 4/;
x.LO=0;
x.UP=6;

EQUATIONS
obj, con, Eq1, Eq2(n);

obj.. z0 =E= -x - y;
con.. z1 =L= 4;

Eq1.. sum(n, lambda(n)) =E= 1;
Eq2(n).. x =G= x.LO + (x(t-1) - x.LO)*lambda(n));

MODEL PARTest1 /ALL/;
SOLVE PARTest1 USING MIP MINIMIZING z0;

The equation that I want to model is the RHS of following equation:

image.png
Please note that this not the complete code. So you will not be able to get anything by running it.

I am struggling with the formulating Eq2. The RHS of this equation has ‘t-1’ as domain of x, which is a constant, as defined in the Parameters. However, modelling this way, generates error because the equation definition ‘Eq2(n)’ does not includes ‘t’ in its domain. Now, how can I model this?

Hi

Why don’t you define the equation additonally over t? Furthermore, you use x, x(t-1) and x.lo which surely will cause errors. This should be something like:

Eq2(n,t)$(ord(t) > 1).. x(t) =G= x.LO(t) + (x(t-1) - x.LO(t))*lambda(n));

I would define a parameter xlow(t) = X.LO(t) and write the equation as follows:

Eq2(n,t)$(ord(t) > 1).. x(t) =G= xlow(t) + (x(t-1) - xlow(t))*lambda(n));

Cheers
Renger
PS. I prefer to write my variables in upper case and parameters in lowercase, so I can read my code without having to check what a variable or parameter is in my equation.

Hi,

Thank you for the answer. Another question, how will you model following attached equation?


image.png