intlinprog
Mixedinteger linear programming (MILP)
Syntax
Description
Mixedinteger linear programming solver.
Finds the minimum of a problem specified by
$$\underset{x}{\mathrm{min}}{f}^{T}x\text{subjectto}\{\begin{array}{l}x(\text{intcon})\text{areintegers}\hfill \\ A\cdot x\le b\hfill \\ Aeq\cdot x=beq\hfill \\ lb\le x\le ub.\hfill \end{array}$$
f, x, intcon, b, beq, lb, and ub are vectors, and A and Aeq are matrices.
You can specify f, intcon, lb, and ub as vectors or arrays. See Matrix Arguments.
Note
intlinprog
applies only to the solverbased approach. For a discussion
of the two optimization approaches, see First Choose ProblemBased or SolverBased Approach.
uses a
x
= intlinprog(problem
)problem
structure to encapsulate all solver inputs. You
can import a problem
structure from an MPS file using
mpsread
. You can also create a
problem
structure from an
OptimizationProblem
object by using prob2struct
.
Examples
Solve an MILP with Linear Inequalities
Solve the problem
$$\underset{x}{\mathrm{min}}8{x}_{1}+{x}_{2}\phantom{\rule{0.5em}{0ex}}subject\phantom{\rule{0.5em}{0ex}}to\phantom{\rule{0.5em}{0ex}}\{\begin{array}{l}{x}_{2}\phantom{\rule{0.5em}{0ex}}is\phantom{\rule{0.5em}{0ex}}an\phantom{\rule{0.5em}{0ex}}integer\\ {x}_{1}+2{x}_{2}\ge 14\\ 4{x}_{1}{x}_{2}\le 33\\ 2{x}_{1}+{x}_{2}\le 20.\end{array}$$
Write the objective function vector and vector of integer variables.
f = [8;1]; intcon = 2;
Convert all inequalities into the form A*x <= b
by multiplying “greater than” inequalities by 1
.
A = [1,2; 4,1; 2,1]; b = [14;33;20];
Call intlinprog
.
x = intlinprog(f,intcon,A,b)
LP: Optimal objective value is 59.000000. Optimal solution found. Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e05 (the default value).
x = 2×1
6.5000
7.0000
Solve an MILP with All Types of Constraints
Solve the problem
$$\underset{x}{\mathrm{min}}\left(3{x}_{1}2{x}_{2}{x}_{3}\right)\phantom{\rule{0.5em}{0ex}}subject\phantom{\rule{0.5em}{0ex}}to\{\begin{array}{l}{x}_{3}\phantom{\rule{0.5em}{0ex}}binary\\ {x}_{1},{x}_{2}\ge 0\\ {x}_{1}+{x}_{2}+{x}_{3}\le 7\\ 4{x}_{1}+2{x}_{2}+{x}_{3}=12.\end{array}$$
Write the objective function vector and vector of integer variables.
f = [3;2;1]; intcon = 3;
Write the linear inequality constraints.
A = [1,1,1]; b = 7;
Write the linear equality constraints.
Aeq = [4,2,1]; beq = 12;
Write the bound constraints.
lb = zeros(3,1);
ub = [Inf;Inf;1]; % Enforces x(3) is binary
Call intlinprog
.
x = intlinprog(f,intcon,A,b,Aeq,beq,lb,ub)
LP: Optimal objective value is 12.000000. Optimal solution found. Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e05 (the default value).
x = 3×1
0
5.5000
1.0000
Use Initial Point
Compare the number of steps to solve an integer programming problem both with and without an initial feasible point. The problem has eight variables, four linear equality constraints, and has all variables restricted to be positive.
Define the linear equality constraint matrix and vector.
Aeq = [22 13 26 33 21 3 14 26 39 16 22 28 26 30 23 24 18 14 29 27 30 38 26 26 41 26 28 36 18 38 16 26]; beq = [ 7872 10466 11322 12058];
Set lower bounds that restrict all variables to be nonnegative.
N = 8; lb = zeros(N,1);
Specify that all variables are integervalued.
intcon = 1:N;
Set the objective function vector f
.
f = [2 10 13 17 7 5 7 3];
Solve the problem without using an initial point, and examine the display to see the number of branchandbound nodes.
[x1,fval1,exitflag1,output1] = intlinprog(f,intcon,[],[],Aeq,beq,lb);
LP: Optimal objective value is 1554.047531. Cut Generation: Applied 8 strong CG cuts. Lower bound is 1591.000000. Branch and Bound: nodes total num int integer relative explored time (s) solution fval gap (%) 10000 0.40 0   18025 0.69 1 2.906000e+03 4.509804e+01 21857 0.87 2 2.073000e+03 2.270974e+01 23544 0.94 3 1.854000e+03 1.180593e+01 24097 0.97 3 1.854000e+03 1.617251e+00 24293 0.98 3 1.854000e+03 0.000000e+00 Optimal solution found. Intlinprog stopped because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e05 (the default value).
For comparison, find the solution using an initial feasible point.
x0 = [8 62 23 103 53 84 46 34]; [x2,fval2,exitflag2,output2] = intlinprog(f,intcon,[],[],Aeq,beq,lb,[],x0);
LP: Optimal objective value is 1554.047531. Cut Generation: Applied 8 strong CG cuts. Lower bound is 1591.000000. Relative gap is 59.20%. Branch and Bound: nodes total num int integer relative explored time (s) solution fval gap (%) 3627 0.20 2 2.154000e+03 2.593968e+01 5844 0.30 3 1.854000e+03 1.180593e+01 6204 0.31 3 1.854000e+03 1.455526e+00 6400 0.32 3 1.854000e+03 0.000000e+00 Optimal solution found. Intlinprog stopped because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e05 (the default value).
Without an initial point,
intlinprog
took about 30,000 branchandbound steps.Using an initial point,
intlinprog
took about 5,000 steps.
Giving an initial point does not always help. For this problem, giving an initial point saves time and computational steps. However, for some problems, giving an initial point can cause intlinprog
to take more steps.
Solve an MILP with Nondefault Options
Solve the problem
$$\underset{x}{\mathrm{min}}\left(3{x}_{1}2{x}_{2}{x}_{3}\right)\phantom{\rule{0.5em}{0ex}}subject\phantom{\rule{0.5em}{0ex}}to\{\begin{array}{l}{x}_{3}\phantom{\rule{0.5em}{0ex}}binary\\ {x}_{1},{x}_{2}\ge 0\\ {x}_{1}+{x}_{2}+{x}_{3}\le 7\\ 4{x}_{1}+2{x}_{2}+{x}_{3}=12\end{array}$$
without showing iterative display.
Specify the solver inputs.
f = [3;2;1];
intcon = 3;
A = [1,1,1];
b = 7;
Aeq = [4,2,1];
beq = 12;
lb = zeros(3,1);
ub = [Inf;Inf;1]; % enforces x(3) is binary
x0 = [];
Specify no display.
options = optimoptions('intlinprog','Display','off');
Run the solver.
x = intlinprog(f,intcon,A,b,Aeq,beq,lb,ub,x0,options)
x = 3×1
0
5.5000
1.0000
Solve MILP Using ProblemBased Approach
This example shows how to set up a problem using the problembased approach and then solve it using the solverbased approach. The problem is
$$\underset{x}{\mathrm{min}}\left(3{x}_{1}2{x}_{2}{x}_{3}\right)\phantom{\rule{0.5em}{0ex}}subject\phantom{\rule{0.5em}{0ex}}to\phantom{\rule{0.5em}{0ex}}\{\begin{array}{l}{x}_{3}\phantom{\rule{0.5em}{0ex}}binary\\ {x}_{1},{x}_{2}\ge 0\\ {x}_{1}+{x}_{2}+{x}_{3}\le 7\\ 4{x}_{1}+2{x}_{2}+{x}_{3}=12\end{array}$$
Create an OptimizationProblem
object named prob
to represent this problem. To specify a binary variable, create an optimization variable with integer type, a lower bound of 0, and an upper bound of 1.
x = optimvar('x',2,'LowerBound',0); xb = optimvar('xb','LowerBound',0,'UpperBound',1,'Type','integer'); prob = optimproblem('Objective',3*x(1)2*x(2)xb); cons1 = sum(x) + xb <= 7; cons2 = 4*x(1) + 2*x(2) + xb == 12; prob.Constraints.cons1 = cons1; prob.Constraints.cons2 = cons2;
Convert the problem object to a problem structure.
problem = prob2struct(prob);
Solve the resulting problem structure.
[sol,fval,exitflag,output] = intlinprog(problem)
LP: Optimal objective value is 12.000000. Optimal solution found. Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e05 (the default value).
sol = 3×1
0
5.5000
1.0000
fval = 12
exitflag = 1
output = struct with fields:
relativegap: 0
absolutegap: 0
numfeaspoints: 1
numnodes: 0
constrviolation: 0
message: 'Optimal solution found....'
Both sol(1)
and sol(3)
are binaryvalued. Which value corresponds to the binary optimization variable xb
?
prob.Variables
ans = struct with fields:
x: [2x1 optim.problemdef.OptimizationVariable]
xb: [1x1 optim.problemdef.OptimizationVariable]
The variable xb
appears last in the Variables
display, so xb
corresponds to sol(3) = 1
. See Algorithms.
Examine the MILP Solution and Process
Call intlinprog
with more outputs to see solution details and process.
The goal is to solve the problem
$$\underset{x}{\mathrm{min}}\left(3{x}_{1}2{x}_{2}{x}_{3}\right)\phantom{\rule{0.5em}{0ex}}subject\phantom{\rule{0.5em}{0ex}}to\{\begin{array}{l}{x}_{3}\phantom{\rule{0.5em}{0ex}}binary\\ {x}_{1},{x}_{2}\ge 0\\ {x}_{1}+{x}_{2}+{x}_{3}\le 7\\ 4{x}_{1}+2{x}_{2}+{x}_{3}=12.\end{array}$$
Specify the solver inputs.
f = [3;2;1];
intcon = 3;
A = [1,1,1];
b = 7;
Aeq = [4,2,1];
beq = 12;
lb = zeros(3,1);
ub = [Inf;Inf;1]; % enforces x(3) is binary
Call intlinprog
with all outputs.
[x,fval,exitflag,output] = intlinprog(f,intcon,A,b,Aeq,beq,lb,ub)
LP: Optimal objective value is 12.000000. Optimal solution found. Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e05 (the default value).
x = 3×1
0
5.5000
1.0000
fval = 12
exitflag = 1
output = struct with fields:
relativegap: 0
absolutegap: 0
numfeaspoints: 1
numnodes: 0
constrviolation: 0
message: 'Optimal solution found....'
The output structure shows numnodes
is 0
. This means intlinprog
solved the problem before branching. This is one indication that the result is reliable. Also, the absolutegap
and relativegap
fields are 0
. This is another indication that the result is reliable.
Input Arguments
f
— Coefficient vector
real vector  real array
Coefficient vector, specified as a real vector or real array.
The coefficient vector represents the objective function f'*x
.
The notation assumes that f
is a column vector,
but you are free to use a row vector or array. Internally, linprog
converts f
to
the column vector f(:)
.
If you specify f = []
, intlinprog
tries
to find a feasible point without trying to minimize an objective function.
Example: f = [4;2;1.7];
Data Types: double
intcon
— Vector of integer constraints
vector of integers
Vector of integer constraints, specified as a vector of positive
integers. The values in intcon
indicate the components
of the decision variable x
that are integervalued. intcon
has
values from 1
through numel(f)
.
intcon
can also be an array. Internally, intlinprog
converts
an array intcon
to the vector intcon(:)
.
Example: intcon = [1,2,7]
means x(1)
, x(2)
,
and x(7)
take only integer values.
Data Types: double
A
— Linear inequality constraints
real matrix
Linear inequality constraints, specified as a real matrix. A
is an M
byN
matrix, where M
is the number of inequalities, and N
is the number of variables (length of f
). For large problems, pass A
as a sparse matrix.
A
encodes the M
linear inequalities
A*x <= b
,
where x
is the column vector of N
variables x(:)
, and b
is a column vector with M
elements.
For example, consider these inequalities:
x_{1} +
2x_{2} ≤
10
3x_{1} +
4x_{2} ≤
20
5x_{1} +
6x_{2} ≤ 30.
Specify the inequalities by entering the following constraints.
A = [1,2;3,4;5,6]; b = [10;20;30];
Example: To specify that the xcomponents add up to 1 or less, take A =
ones(1,N)
and b = 1
.
Data Types: double
b
— Linear inequality constraints
real vector
Linear inequality constraints, specified as a real vector. b
is
an M
element vector related to the A
matrix.
If you pass b
as a row vector, solvers internally
convert b
to the column vector b(:)
.
For large problems, pass b
as a sparse vector.
b
encodes the M
linear
inequalities
A*x <= b
,
where x
is the column vector of N
variables x(:)
,
and A
is a matrix of size M
byN
.
For example, consider these inequalities:
x_{1}
+ 2x_{2} ≤
10
3x_{1}
+ 4x_{2} ≤
20
5x_{1}
+ 6x_{2} ≤
30.
Specify the inequalities by entering the following constraints.
A = [1,2;3,4;5,6]; b = [10;20;30];
Example: To specify that the x components sum to 1 or less, use A =
ones(1,N)
and b = 1
.
Data Types: double
Aeq
— Linear equality constraints
real matrix
Linear equality constraints, specified as a real matrix. Aeq
is an Me
byN
matrix, where Me
is the number of equalities, and N
is the number of variables (length of f
). For large problems, pass Aeq
as a sparse matrix.
Aeq
encodes the Me
linear equalities
Aeq*x = beq
,
where x
is the column vector of N
variables x(:)
, and beq
is a column vector with Me
elements.
For example, consider these equalities:
x_{1} +
2x_{2} +
3x_{3} =
10
2x_{1} +
4x_{2} +
x_{3} = 20.
Specify the equalities by entering the following constraints.
Aeq = [1,2,3;2,4,1]; beq = [10;20];
Example: To specify that the xcomponents sum to 1, take Aeq = ones(1,N)
and
beq = 1
.
Data Types: double
beq
— Linear equality constraints
real vector
Linear equality constraints, specified as a real vector. beq
is
an Me
element vector related to the Aeq
matrix.
If you pass beq
as a row vector, solvers internally
convert beq
to the column vector beq(:)
.
For large problems, pass beq
as a sparse vector.
beq
encodes the Me
linear
equalities
Aeq*x = beq
,
where x
is the column vector of N
variables
x(:)
, and Aeq
is a matrix of size
Me
byN
.
For example, consider these equalities:
x_{1}
+ 2x_{2} +
3x_{3} =
10
2x_{1}
+ 4x_{2} +
x_{3} =
20.
Specify the equalities by entering the following constraints.
Aeq = [1,2,3;2,4,1]; beq = [10;20];
Example: To specify that the x components sum to 1, use Aeq = ones(1,N)
and
beq = 1
.
Data Types: double
lb
— Lower bounds
[]
(default)  real vector or array
Lower bounds, specified as a vector or array of doubles. lb
represents
the lower bounds elementwise in lb
≤ x
≤ ub
.
Internally, intlinprog
converts an array lb
to
the vector lb(:)
.
Example: lb = [0;Inf;4]
means x(1)
≥ 0
, x(3) ≥ 4
.
Data Types: double
ub
— Upper bounds
[]
(default)  real vector or array
Upper bounds, specified as a vector or array of doubles. ub
represents
the upper bounds elementwise in lb
≤ x
≤ ub
.
Internally, intlinprog
converts an array ub
to
the vector ub(:)
.
Example: ub = [Inf;4;10]
means x(2)
≤ 4
, x(3) ≤ 10
.
Data Types: double
x0
— Initial point
[]
(default)  real array
Initial point, specified as a real array. The number of elements in
x0
is the same as the number of elements of
f
, when f
exists.
Otherwise, the number is the same as the number of columns of
A
or Aeq
. Internally, the
solver converts an array x0
into a vector
x0(:)
.
Providing x0
can change the amount of time
intlinprog
takes to converge. It is difficult
to predict how x0
affects the solver. For
suggestions on using appropriate Heuristics
with
x0
, see Tips.
x0
must be feasible with respect to all
constraints. If x0
is not feasible, the solver
errors. If you do not have a feasible x0
, set
x0 = []
.
Example: x0 = 100*rand(size(f))
Data Types: double
options
— Options for intlinprog
options created using optimoptions
Options for intlinprog
,
specified as the output of optimoptions
.
Some options are absent from the
optimoptions
display. These options appear in italics in the following
table. For details, see View Options.
Option  Description  Default 

AbsoluteGapTolerance 
Nonnegative real.
 0 
BranchRule 
Rule for choosing the component for branching:
 'reliability' 
ConstraintTolerance  Real from 1e9 through 1e3 that
is the maximum discrepancy that linear constraints can have and still
be considered satisfied. ConstraintTolerance is
not a stopping criterion.  1e4 
CutGeneration 
Level of cut generation (see Cut Generation):
 'basic' 
CutMaxIterations  Number of passes through all cut generation methods before
entering the branchandbound phase, an integer from 1 through 50 .
Disable cut generation by setting the CutGeneration option
to 'none' .  10 
Display 
Level of display (see Iterative Display):
 'iter' 
Heuristics 
Algorithm for searching for feasible points (see Heuristics for Finding Feasible Solutions):
 'basic' 
HeuristicsMaxNodes  Strictly positive integer that bounds the number of nodes intlinprog can
explore in its branchandbound search for feasible points. Applies
only to 'rss' and 'rins' . See Heuristics for Finding Feasible Solutions.  50 
IntegerPreprocess 
Types of integer preprocessing (see MixedInteger Program Preprocessing):
 'basic' 
IntegerTolerance  Real from 1e6 through 1e3 ,
where the maximum deviation from integer that a component of the solution x can
have and still be considered an integer. IntegerTolerance is
not a stopping criterion.  1e5 
LPMaxIterations  Strictly positive integer, the maximum number of simplex algorithm iterations per node during the branchandbound process. 
In this
expression, 
LPOptimalityTolerance  Nonnegative real where reduced costs must exceed LPOptimalityTolerance for
a variable to be taken into the basis.  1e7 
LPPreprocess 
Type of preprocessing for the solution to the relaxed linear program (see Linear Program Preprocessing):
 'basic' 
MaxNodes  Strictly positive integer that is the maximum number of nodes intlinprog explores
in its branchandbound process.  1e7 
MaxFeasiblePoints  Strictly positive integer. intlinprog stops
if it finds MaxFeasiblePoints integer feasible
points.  Inf 
MaxTime  Positive real that is the maximum time in seconds that intlinprog runs.  7200 
NodeSelection 
Choose the node to explore next.
 'simplebestproj' 
ObjectiveCutOff  Real greater than Inf . During the branchandbound
calculation, intlinprog discards any node where
the linear programming solution has an objective value exceeding ObjectiveCutOff .  Inf 
ObjectiveImprovementThreshold  Nonnegative real. intlinprog changes the current feasible solution only
when it locates another with an objective function
value that is at least
ObjectiveImprovementThreshold
lower: (fold – fnew)/(1 + fold) >
ObjectiveImprovementThreshold.  0 
OutputFcn  One or more functions that an optimization function calls at events. Specify as
For information on writing a custom output function, see intlinprog Output Function and Plot Function Syntax.  [] 
PlotFcn  Plots various measures of progress while the algorithm executes; select from predefined
plots or write your own. Pass
For information on writing a custom plot function, see intlinprog Output Function and Plot Function Syntax.  [] 
RelativeGapTolerance  Real from
Note Although you specify  1e4 
RootLPAlgorithm 
Algorithm for solving linear programs:
 'dualsimplex' 
RootLPMaxIterations  Nonnegative integer that is the maximum number of simplex algorithm iterations to solve the initial linear programming problem. 
In this
expression, 
Example: options = optimoptions('intlinprog','MaxTime',120)
problem
— Structure encapsulating inputs and options
structure
Structure encapsulating the inputs and options, specified with the following fields.
f  Vector representing objective f'*x (required) 
intcon  Vector indicating variables that take integer values (required) 
Aineq  Matrix in linear inequality constraints Aineq*x ≤ bineq 
 Vector in linear inequality constraints Aineq*x ≤ bineq 
 Matrix in linear equality constraints Aeq*x = beq 
 Vector in linear equality constraints Aeq*x = beq 
lb  Vector of lower bounds 
ub  Vector of upper bounds 
x0  Initial feasible point 
solver  'intlinprog' (required) 
 Options created using optimoptions (required) 
You must specify at least these fields in the problem structure. Other fields are optional:
f
intcon
solver
options
Example: problem.f = [1,2,3];
problem.intcon
= [2,3];
problem.options = optimoptions('intlinprog');
problem.Aineq = [3,2,1];
problem.bineq
= 20;
problem.lb = [6.1,1.2,7.3];
problem.solver
= 'intlinprog';
Data Types: struct
Output Arguments
x
— Solution
real vector
Solution, returned as a vector that minimizes f'*x
subject
to all bounds, integer constraints, and linear constraints.
When a problem is infeasible or unbounded, x
is []
.
fval
— Objective value
real scalar
Objective value, returned as the scalar value f'*x
at
the solution x
.
When a problem is infeasible or unbounded, fval
is []
.
exitflag
— Algorithm stopping condition
integer
Algorithm stopping condition, returned as an integer identifying
the reason the algorithm stopped. The following lists the values of exitflag
and
the corresponding reasons intlinprog
stopped.
 The solution is
feasible with respect to the relative









 No feasible point found. 
 Root LP problem is unbounded. 
 Solver lost feasibility. 
The exit message can give more detailed information on the reason intlinprog
stopped,
such as exceeding a tolerance.
Exitflags 3
and 9
relate
to solutions that have large infeasibilities. These usually arise from linear constraint
matrices that have large condition number, or problems that have large solution components. To
correct these issues, try to scale the coefficient matrices, eliminate redundant linear
constraints, or give tighter bounds on the variables.
output
— Solution process summary
structure
Solution process summary, returned as a structure containing information about the optimization process.
 Relative percentage difference
between upper (
If Note Although you specify 
 Difference between upper and lower
bounds of the objective function that If 
 Number of integer feasible points found. If 
 Number of nodes in branchandbound
algorithm. If the solution was found during preprocessing or during
the initial cuts, If 
 Constraint violation that is positive for violated constraints.

 Exit message. 
Limitations
Often, some supposedly integervalued components of the solution
x(intCon)
are not precisely integers.intlinprog
deems as integers all solution values withinIntegerTolerance
of an integer.To round all supposed integers to be exactly integers, use the
round
function.x(intcon) = round(x(intcon));
Caution
Rounding solutions can cause the solution to become infeasible. Check feasibility after rounding:
max(A*x  b) % See if entries are not too positive, so have small infeasibility max(abs(Aeq*x  beq)) % See if entries are near enough to zero max(x  ub) % Positive entries are violated bounds max(lb  x) % Positive entries are violated bounds
intlinprog
does not enforce that solution components be integervalued when their absolute values exceed2.1e9
. When your solution has such components,intlinprog
warns you. If you receive this warning, check the solution to see whether supposedly integervalued components of the solution are close to integers.intlinprog
does not allow components of the problem, such as coefficients inf
,A
, orub
, to exceed1e25
in absolute value. If you try to runintlinprog
with such a problem,intlinprog
issues an error.
Tips
To specify binary variables, set the variables to be integers in
intcon
, and give them lower bounds of0
and upper bounds of1
.Save memory by specifying sparse linear constraint matrices
A
andAeq
. However, you cannot use sparse matrices forb
andbeq
.If you include an
x0
argument,intlinprog
uses that value in the'rins'
and guided diving heuristics until it finds a better integerfeasible point. So when you providex0
, you can obtain good results by setting the'Heuristics'
option to'rinsdiving'
or another setting that uses'rins'
.To provide logical indices for integer components, meaning a binary vector with
1
indicating an integer, convert tointcon
form usingfind
. For example,logicalindices = [1,0,0,1,1,0,0]; intcon = find(logicalindices)
intcon = 1 4 5
intlinprog
replacesbintprog
. To update oldbintprog
code to useintlinprog
, make the following changes:Set
intcon
to1:numVars
, wherenumVars
is the number of variables in your problem.Set
lb
tozeros(numVars,1)
.Set
ub
toones(numVars,1)
.Update any relevant options. Use
optimoptions
to create options forintlinprog
.Change your call to
bintprog
as follows:[x,fval,exitflag,output] = bintprog(f,A,b,Aeq,Beq,x0,options) % Change your call to: [x,fval,exitflag,output] = intlinprog(f,intcon,A,b,Aeq,Beq,lb,ub,x0,options)
Alternative Functionality
App
The Optimize Live Editor task provides a visual interface for intlinprog
.
Version History
Introduced in R2014aR2019a: Default BranchRule
is
'reliability'
Behavior changed in R2019a
The default value of the BranchRule
option is
'reliability'
instead of 'maxpscost'
.
In testing, this value gave better performance on many problems, both in
solution times and in number of explored branching nodes.
On a few problems, the previous branch rule performs better. To get the
previous behavior, set the BranchRule
option to
'maxpscost'
.
See Also
linprog
 mpsread
 optimoptions
 prob2struct
 Optimize
Topics
 MixedInteger Linear Programming Basics: SolverBased
 Factory, Warehouse, Sales Allocation Model: SolverBased
 Traveling Salesman Problem: SolverBased
 Solve Sudoku Puzzles Via Integer Programming: SolverBased
 MixedInteger Quadratic Programming Portfolio Optimization: SolverBased
 Optimal Dispatch of Power Generators: SolverBased
 MixedInteger Linear Programming Algorithms
 Tuning Integer Linear Programming
 SolverBased Optimization Problem Setup
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)