Titiaan Palazzi
Titiaan Palazzi

Reputation: 115

Linear programming constraints: multiplication of optimization variables

Given an optimization problem with two optimization variables (x_in(t), x_out(t)). For any time-step, when x_in is non-zero, x_out must be zero (and vice versa). Written as a constraint:

x_in(t)*x_out(t)=0

How can such a constraint be included in Matlab's linprog function?

Upvotes: 4

Views: 2999

Answers (1)

Anders Gustafsson
Anders Gustafsson

Reputation: 15981

Since the problem is not entirely linear, I do not believe you can solve it as-is using the linprog function. However, you should be able to reformulate the problem as a mixed integer linear programming problem. Then you would be able to use for example this extension from Matlab Central to solve the problem.

Assuming that x_in(t) and x_out(t) are non-negative variables with upper bounds x_in_max and x_out_max, respectively, then you can add the variables y_in(t) and y_out(t) to your optimization problem and include the following constraints:

(1) y_in(t) and y_out(t) are binary, i.e. 0 or 1
(2) x_in(t)  <= x_in_max  * y_in(t)
(3) x_out(t) <= x_out_max * y_out(t)
(4) y_in(t) + y_out(t) = 1

Given that y_in and y_out are binary variables, constraints (2) and (3) relate the x_ and y_ variables with each other and ensure that the x_ variables remain within bounds (fix bounds on the x_ variables can thus and should be removed from the problem formulation). Constraint (4) ensures that either the _in or the _out event occurs, but not both at the same time.

Upvotes: 5

Related Questions