0

Here is precisely my case: Let's assume a variable x[t] which is a NonNegativeInteger smaller or equal than 3.

So x[t] can be {0,1,2,3}. It's indexed by a time serie.

I would like to prevent x[t] from alternating. Means I would like to disallow

x[0] = 0
x[1] = 1
x[2] = 0

but also

x[0] = 1
x[1] = 2
x[2] = 1

and

x[0] = 2
x[1] = 3
x[2] = 2

I am looking for a constraint to disallow this. Three time steps must be involved in that constraint.

I've tried a couple of constraints. I am not sure if this is even possible with a simple constraint.

Maybe I have to add a variable to make this work. Do you have any experience with that kind of problem?

Thank you in advance!

1 Answer 1

0

You can ensure increasing or decreasing order with below constraints:

x[t] + M(y-1) <= x[t+1]

x[t] + My >= x[t+1]

y:Binary variable (same y is used at all equations)

M:Big number (bigger than possible the biggest value)

Sign up to request clarification or add additional context in comments.

4 Comments

Sorry, maybe I didn’t explain my problem clearly. I want to prevent it from alternating. I don’t want to ensure increasing. So 0,1,0 should be prevented, but 0,1,1,0 should be possible.
I think that if "t" is {0,1,2,3}, using different binary varible (y) for last equation set will be enough.
Can you tell me how?
Actually, if being increasing or decreasing order of the first three variable is enough for you, write the equation set for t = 0 and t=1 and make free x[3]. Because there is not relation between x[2] and x[3]. This allows 0,1, 1,0 or 1, 0, 0, 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.