Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixed-Integer Nearest Optimal Solution in Matlab

Is it possible to find the nearest solution to optimal for a mixed-integer problem? For example I would want the simplified problem below:

f = [1;1;1];
intcon = 1:3;

Aeq = [0.99,0.97,0.15];
beq = 0.16;
lb = zeros(3,1);
ub = [1;1;1]; 

x = intlinprog(f,intcon,[],[],Aeq,beq,lb,ub)

to return x=[0;0;1] as this is the nearest integer solution to the objective value of 0.16. Instead currently it returns

Intlinprog stopped because no point satisfies the constraints.

Does not necessarily have to run intlinprog. Would ideally need to also work if beq is low, for example 0.14.

like image 361
Mary Avatar asked Jun 23 '17 15:06

Mary


People also ask

What does Intcon mean in Matlab?

intcon is a vector of positive integers that contains the x components that are integer-valued. For example, if you want to restrict x(2) and x(10) to be integers, set intcon to [2,10] . The surrogateopt solver also accepts integer constraints.

What is MILP solver?

The mixed-integer linear programming (MILP) solver in the OPTMODEL procedure enables you to solve mixed integer linear programming problems. A standard mixed-integer linear program has the formulation. where. is the vector of structural variables. is the matrix of technological coefficients.

What is MILP algorithm?

Mixed-integer linear programming (MILP) is often used for system analysis and optimization as it presents a flexible and powerful method for solving large, complex problems such as the case with industrial symbiosis and process integration.

Does simplex always give optimal solution?

If you solve an ILP problem using the simplex method, then (1) the constraints WILL be satisfied, and (2) the objective function WILL be maxed. So, the answer will be optimal.


1 Answers

You can introduce some slack variables to allow some constraint violation when needed as follows:

largeValue = 100; % choose some large value to penalise the constraint violation
f_ = [f; largeValue; largeValue]; % penalise both slack variables
Aeq_ = [Aeq, 1, -1]; % add a positive and negative slack variable to the constraint
beq_ = beq;
lb_ = [lb; 0; 0]; % limit the constraint to a positive number
ub_ = [ub; inf; inf];

x_ = intlinprog(f_,intcon,[],[],Aeq_,beq_,lb_,ub_); % solve the adapted problem
x = x_(1:3) % extract the solution of the original problem

Remarks

  • I added two (positive) slack variables, one for a positive constraint violation and another one for a negative constraint violation.

  • You should penalise the slack variables with a large value, otherwise it is beneficial to violate your constraints more than strictly necessary. A more general approach would be to determine a good penalisation value based on the values in f and Aeq, for example

    largeValue = 2*max(abs(f))/min(abs(Aeq(Aeq ~= 0)))
    
like image 104
m7913d Avatar answered Nov 15 '22 18:11

m7913d