Solves a linear programming problem.
xopt = linprog(c,A,b) xopt = linprog(c,A,b,Aeq,beq) xopt = linprog(c,A,b,Aeq,beq,lb,ub) xopt = linprog(c,A,b,Aeq,beq,lb,ub,param) xopt = linprog(file) xopt = linprog(file,param) [xopt,fopt,exitflag,output,lambda] = linprog( ... )
A vector of doubles, containing the coefficients of the variables in the objective function.
A matrix of doubles, containing the coefficients of linear inequality constraints of size (m X n) where 'm' is the number of linear inequality constraints.
A vector of doubles, related to 'A' and containing the the Right hand side equation of the linear inequality constraints of size (m X 1).
A matrix of doubles, containing the coefficients of linear equality constraints of size (m1 X n) where 'm1' is the number of linear equality constraints.
A vector of doubles, related to 'Aeq' and containing the the Right hand side equation of the linear equality constraints of size (m1 X 1).
A vector of doubles, containing the lower bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of variables.
A vector of doubles, containing the upper bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of variables.
A list, containing the option for user to specify. See below for details.
A string describing the path to the mps file.
A vector of doubles, containing the computed solution of the optimization problem.
A double, containing the the function value at x.
An integer, containing the flag which denotes the reason for termination of algorithm. See below for details.
A structure, containing the information about the optimization. See below for details.
A structure, containing the Lagrange multipliers of lower bound, upper bound and constraints at the optimized point. See below for details.
Search the minimum of a constrained linear programming problem specified by :
OSI-CLP, an optimization library written in C++, is used for solving the linear programming problems.
options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "Hessian", ---, "GradCon", ---);
The options should be defined as type "list" and consist of the following fields:
The default values for the various items are given as:
options = list("MaxIter", [3000], "CpuTime", [600]);
The exitflag allows the user to know the status of the optimization which is returned by Ipopt. The values it can take and what they indicate is described below:
The output data structure contains detailed information about the optimization process. It is of type "struct" and contains the following fields.
The lambda data structure contains the Lagrange multipliers at the end of optimization. In the current version the values are returned only when the the solution is optimal. It has type "struct" and contains the following fields.
A few examples displaying the various functionalities of linprog have been provided below. You will find a series of problems and the appropriate code snippets to solve them.
Here we solve a simple objective function, subjected to six linear inequality constraints.
Find x in R^2 such that it minimizes:
Here we build up on the previous example by adding linear equality constraints. We add the following constraints to the problem specified above:
In this example, we proceed to add the upper and lower bounds to the objective function.
Primal Infeasible Problems: Find x in R^3 such that it minimizes:
Unbounded Problems: Find x in R^3 such that it minimizes:
filepath = get_absolute_file_path('linprog.dem.sce'); filepath = filepath + "exmip1.mps" [xopt,fopt,exitflag,output,lambda] =linprog(filepath) | ![]() | ![]() |