This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Linear Programming and Mixed-Integer Linear Programming

Solve linear programming problems with continuous and integer variables

There are two approaches to linear programming and mixed-integer linear programming. This table helps you choose the best approach. Examples appear toward the bottom of the page.

ApproachesCharacteristics
Problem-Based Optimization SetupEasier to create and debug
Only for linear or quadratic problems with linear or integer constraints
Represent the objective and constraints symbolically
Solution time is longer because of translation time from problem form to matrix form
See the steps in Problem-Based Workflow
Basic example: Mixed-Integer Linear Programming Basics: Problem-Based or the video Solve a Mixed-Integer Linear Programming Problem using Optimization Modeling
Solver-Based Optimization Problem SetupHarder to create and debug
Represent the objective and constraints as functions or matrices
Solution time is shorter because there is no translation time to matrix form
To save memory in large problems, allows use of Hessian multiply function or Jacobian multiply function. See Quadratic Minimization with Dense, Structured Hessian or Jacobian Multiply Function with Linear Least Squares.
See the steps in Solver-Based Optimization Problem Setup
Basic example: Mixed-Integer Linear Programming Basics: Solver-Based

For the problem-based approach, create problem variables, and then represent the objective function and constraints in terms of these symbolic variables. For the problem-based steps to take, see Problem-Based Workflow. To solve the resulting problem, use solve.

For the solver-based steps to take, including defining the objective function and constraints, and choosing the appropriate solver, see Solver-Based Optimization Problem Setup. To solve the resulting problem, use intlinprog when there are integer constraints, or use linprog when there are no integer constraints.

Functions

expand all

evaluateEvaluate optimization expression
findindexFind numeric index equivalents of named index variables
infeasibilityConstraint violation at a point
prob2structConvert optimization problem to solver form
solveSolve optimization problem
intlinprogMixed-integer linear programming (MILP)
linprogSolve linear programming problems
mpsreadRead MPS file for LP and MILP optimization data

Topics

Problem-Based Mixed-Integer Linear Programming Applications

Mixed-Integer Linear Programming Basics: Problem-Based

Simple example of mixed-integer linear programming.

Factory, Warehouse, Sales Allocation Model: Problem-Based

This example shows how to set up and solve a mixed-integer linear programming problem.

Traveling Salesman Problem: Problem-Based

This example shows how to use binary integer programming to solve the classic traveling salesman problem.

Optimal Dispatch of Power Generators: Problem-Based

This example shows how to schedule two gas-fired electric generators optimally, meaning to get the most revenue minus cost.

Office Assignments by Binary Integer Programming: Problem-Based

This example shows how to solve an assignment problem by binary integer programming using the optimization problem approach.

Mixed-Integer Quadratic Programming Portfolio Optimization: Problem-Based

This example shows how to solve a Mixed-Integer Quadratic Programming (MIQP) portfolio optimization problem using the problem-based approach.

Cutting Stock Problem: Problem-Based

This example shows how to solve a cutting stock problem using linear programming with an integer linear programming subroutine.

Solve Sudoku Puzzles Via Integer Programming: Problem-Based

This example shows how to solve a Sudoku puzzle using binary integer programming.

Solver-Based Mixed-Integer Linear Programming Applications

Mixed-Integer Linear Programming Basics: Solver-Based

Simple example of mixed-integer linear programming.

Factory, Warehouse, Sales Allocation Model: Solver-Based

Example of optimizing logistics in a small supply chain.

Traveling Salesman Problem: Solver-Based

The classic traveling salesman problem, with setup and solution.

Optimal Dispatch of Power Generators: Solver-Based

Example showing how to schedule power generation when there is a cost for activation.

Office Assignments by Binary Integer Programming: Solver-Based

Solve an assignment problem using binary integer programming.

Mixed-Integer Quadratic Programming Portfolio Optimization: Solver-Based

Example showing how to optimize a portfolio, a quadratic programming problem, with integer and other constraints.

Cutting Stock Problem: Solver-Based

Solve a cutting stock problem using linear programming with an integer programming subroutine.

Solve Sudoku Puzzles Via Integer Programming: Solver-Based

Sudoku is a type of puzzle that you can solve using integer linear programming.

Problem-Based Linear Programming Applications

Set Up a Linear Program, Problem-Based

Linear problem formulation using the problem-based approach.

Maximize Long-Term Investments Using Linear Programming: Problem-Based

This example shows how to use the problem-based approach to solve an investment problem with deterministic returns over a fixed number of years T.

Create Multiperiod Inventory Model in Problem-Based Framework

This example shows how to create a multiperiod inventory model in the problem-based framework.

Solver-Based Linear Programming Applications

Set Up a Linear Program, Solver-Based

Problem formulation using the solver-based approach.

Typical Linear Programming Problem

This example shows the solution of a typical linear programming problem.

Maximize Long-Term Investments Using Linear Programming: Solver-Based

Optimize a deterministic multiperiod investment problem using linear programming.

Problem-Based Algorithms

Problem-Based Optimization Algorithms

How the optimization functions and objects solve optimization problems.

Supported Operations on Optimization Variables and Expressions

Lists all available mathematical and indexing operations on optimization variables and expressions.

Solver-Based Algorithms and Options

Linear Programming Algorithms

Minimizing a linear objective function in n dimensions with only linear and bound constraints.

Mixed-Integer Linear Programming Algorithms

The algorithms used for solution of mixed-integer linear programs.

Optimization Options Reference

Describes optimization options.

Tuning Integer Linear Programming

Steps for improving solutions or solution time.

intlinprog Output Functions and Plot Functions

How to monitor the progress of the intlinprog solution process.