-1

I have a linear program that represent a time series of actions (the variables are ordered). The objective function is MIN. For every variable I have the constraint Xi <= max_value.

I want the constraint to represent the real world more precisely, so I need to change that constrain as follow:

if sum(X1,...,Xi-1) > some_value then Xi <= max_value_1, else Xi <= max_value_2.

Is there a way to make it linear? If not, is there a ready made solver (like ortools) for this?

Thanks

2 Answers2

0

Provided your variable are integral, or can be scaled up to be integral, you can use CP-SAT for this.

This is explained in the section of the documentation.

Laurent Perron
  • 8,594
  • 1
  • 8
  • 22
0

if sum(X1,...,Xi-1) > some_value then Xi <= max_value_1, else Xi <= max_value_2.

 y(i) = sum(X(1),...,X(i-1))
 y(i) <= (1-δ(i))*some_value + δ(i)*M
 y(i) >= δ(i)*(some_value+0.00001) - (1-δ(i))*M
 X(i) <= max_value_1*δ(i) + max_value_2*(1-δ(i))

 δ(i) ∈ {0,1}

Here M is a large enough constant, and y is an extra continuous variable.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39