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
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:
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?
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:
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.