Solved

# Constraint for Variable constancy

• 55 views

First question:

How do you make a variable have a consistent value across time?

How to make a constraint that will make a variable equal to a previous value like

var(n,t) = var(n,t-1)

Second Question:

How can you model differently the 9 and 10th constraint?

The main function of those constraint are a switch-like event. The constraints ensure that the binary variables for both set will be open, run for a number of time, and then stop.

The main difference between the two are for the letter set, the binary variable should be open right from the start which means the binary variable must be equal to 1 at  time = 1.

How can you model this differently?

Regarding your first question, you can do this pretty much exactly how you put it there in your example:

You can either create a constraint that is indexed over (n,t) and then use as definition of the constraint

v(n,t) = var(n,t-1)

Or you can create a variable with a definition. You would define a variable indexed over (n,t) and in the definition of this variable you would say var(n,t-1)  ( and add something like + what is added in period t - everything what was moved away in period t)

For the (n,t) combinations where t is the first element, t-1 would refer to a non existing element and AIMMS would automatically use the value 0 instead of the variable value var(n,t-1)

Regarding your second question, you can use if-then-else contraints inside constraints. If you want to keep a linear model make sure you do NOT put the variables in the if condition, but you can change the behavior of the constraint for certain elements.

A standard example of this would be a balance of inventory constraint:

inventory(t) = if ord(t) > 1 then inventory(t-1) else starting_inventory endif +  produced(t) - delivered(t)

So for the first t (ordinal value of 1) we will not use the previous time period variable, but we will use the starting inventory value. For all other time periods, we will use the previous time period variable value.

If you need to model a binary decision that switches on something and that must stay on for some minimum time periods, you should not use if-conditions on the binary variable, but use modelling formulations for this. The AIMMS modeling guide (https://documentation.aimms.com/aimms_modeling.html) and the AIMMS academy (https://academy.aimms.com/) would be good starting points to learn more about this part