<< fot_intquadprog FOSSEE_Optimization_Toolbox fot_lsqlin >>

FOSSEE_Optimization_Toolbox >> FOSSEE_Optimization_Toolbox > fot_linprog

fot_linprog

Solves a linear optimization problem.

Calling Sequence

xopt = fot_linprog(c,A,b)
xopt = fot_linprog(c,A,b,Aeq,beq)
xopt = fot_linprog(c,A,b,Aeq,beq,lb,ub)
xopt = fot_linprog(c,A,b,Aeq,beq,lb,ub,param)
xopt = fot_linprog(file)
xopt = fot_linprog(file,param)
[xopt,fopt,exitflag,output,lambda] = fot_linprog( ... )

Input Parameters

c :

A vector of doubles, containing the coefficients of the variables in the objective function.

A :

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.

b :

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).

Aeq :

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.

beq :

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).

lb :

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.

ub :

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.

options :

A list, containing the option for user to specify. See below for details.

file :

A string describing the path to the mps file.

Outputs

xopt :

A vector of doubles, containing the computed solution of the optimization problem.

fopt :

A double, containing the the function value at x.

exitflaf :

An integer, containing the flag which denotes the reason for termination of algorithm. See below for details.

output :

A structure, containing the information about the optimization. See below for details.

lambda :

A structure, containing the Lagrange multipliers of lower bound, upper bound and constraints at the optimized point. See below for details.

Description

Search the minimum of a constrained linear programming problem specified by :

\begin{eqnarray}
\hspace{10pt} &\mbox{min}_{x}
\hspace{10pt} & c^T⋅x  \\
\hspace{10pt} & \text{Subjected to:} & A⋅x \leq b \\
\end{eqnarray}\\
\begin{eqnarray}
\hspace{115pt} & Aeq⋅x = beq \\
\hspace{115pt} & lb \leq x \leq ub \\
\end{eqnarray}

OSI-CLP, an optimization library written in C++, is used for solving the linear programming problems.

Options

The options allow the user to set various parameters of the Optimization problem. The syntax for the options is given by:

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 fot_linprog have been provided below. You will find a series of problems and the appropriate code snippets to solve them.

Example

Here we solve a simple objective function, subjected to six linear inequality constraints.

Find x in R^2 such that it minimizes:

\begin{eqnarray}
\mbox{min}_{x}\ f(x) = -x_{1} - \dfrac{x_{2}}{3} \\
\end{eqnarray}
\text{Subjected to:}\\
\begin{eqnarray}
\hspace{1pt} &x_{1} + x_{2}&\leq 2\\ 
\hspace{1pt} &x_{1} + \dfrac{x_{2}}{4}&\leq 1\\
\hspace{1pt} &x_{1} - x_{2}&\leq 2\\
\hspace{1pt} &-\dfrac{x_{1}}{4} - x_{2}&\leq 1\\
\hspace{1pt} &-x_{1} - x_{2}&\leq -1\\
\hspace{1pt} &-x_{1} + x_{2}&\leq 2\\
\end{eqnarray}

//Example 1: Linear program, linear inequality constraints
c=[-1,-1/3]'
A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
b=[2,1,2,1,-1,2]
[xopt,fopt,exitflag,output,lambda]=fot_linprog(c, A, b)
// Press ENTER to continue

Example

Here we build up on the previous example by adding linear equality constraints. We add the following constraints to the problem specified above:

\begin{eqnarray}
\hspace{1pt} &x_{1} + \dfrac{x_{2}}{4}&= 1/2 
\end{eqnarray}

//Example 2: Linear program with Linear Inequalities and Equalities`
c=[-1,-1/3]'
A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
b=[2,1,2,1,-1,2]
Aeq=[1,1/4]
beq=[1/2]
[xopt,fopt,exitflag,output,lambda]=fot_linprog(c, A, b, Aeq, beq)
// Press ENTER to continue

Example

In this example, we proceed to add the upper and lower bounds to the objective function.

\begin{eqnarray}
-1 &\leq x_{1} &\leq 1.5\\
-0.5 &\leq x_{2} &\leq 1.25
\end{eqnarray}

//Example 3: Linear program with all constraint types
c=[-1,-1/3]'
A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
b=[2,1,2,1,-1,2]
Aeq=[1,1/4]
beq=[1/2]
lb=[-1,-0.5]
ub=[1.5,1.25]
[xopt,fopt,exitflag,output,lambda]=fot_linprog(c, A, b, Aeq, beq, lb, ub)
// Press ENTER to continue

Example

Primal Infeasible Problems: Find x in R^3 such that it minimizes:

\begin{eqnarray}
mbox{min}_{x}\ f(x) = x_{1} - x_{2}  \- x_{3}\\
\end{eqnarray}
\\\text{Subjected to:}\\
\begin{eqnarray}
\hspace{70pt} &x_{1} + 2x_{2} - x{3}&\leq -4\\
\hspace{70pt} &x_{1} + 4x_{2} + 3x{3}&= 10\\
\hspace{70pt} &x_{1} + x_{2}&= 100\\
\end{eqnarray}
\\
\begin{eqnarray}
\hspace{135pt}0 &\leq x_{1} &\leq \infty\\
\hspace{135pt}0 &\leq x_{2} &\leq \infty\\
\hspace{135pt}0 &\leq x_{3} &\leq \infty
\end{eqnarray}

//Example 4: Primal Infeasible Problem
c=[-1,-1,-1]'
A=[1,2,-1]
b=[-4]
Aeq=[1,5,3;1,1,0]
beq=[10,100]
lb=[0,0,0]
ub=[%inf,%inf,%inf]
[xopt,fopt,exitflag,output,lambda]= fot_linprog(c,A,b,Aeq,beq,lb,ub)
// Press ENTER to continue

Example

Unbounded Problems: Find x in R^3 such that it minimizes:

\begin{eqnarray}
mbox{min}_{x}\ f(x) = x_{1} - x_{2}  \- x_{3}\\
\end{eqnarray}
\\\text{Subjected to:}\\
\begin{eqnarray}
\hspace{70pt} &-x_{1} - x_{2} + 4x{3}&\leq -8\\
\hspace{70pt} &x_{1} + x_{2} + 4x{3}&\leq 5\\
\end{eqnarray}
\\
\begin{eqnarray}
\hspace{115pt}-\infty &\leq x_{1} &\leq \infty\\
\hspace{115pt}-\infty &\leq x_{2} &\leq \infty\\
\hspace{115pt}-\infty &\leq x_{3} &\leq \infty
\end{eqnarray}

//Example 5: Unbounded Problem
c=[3,5,-7]'
A=[-1,-1,4;1,1,4]
b=[-8,5]
Aeq=[]
beq=[]
lb=[-%inf,-%inf,-%inf]
ub=[%inf,%inf,%inf]
[xopt,fopt,exitflag,output,lambda]= fot_linprog(c,A,b,Aeq,beq,lb,ub)
// Press ENTER to continue

Example

//This example will work only in the toolbox base directory
filepath = "./demos/";
filepath = filepath + "exmip1.mps"
[xopt,fopt,exitflag,output,lambda] =fot_linprog(filepath)

Authors


Report an issue
<< fot_intquadprog FOSSEE_Optimization_Toolbox fot_lsqlin >>