Welcome to the world of Optimizations

In this blog concepts of conventional and unconventional optimization techniques are discussed.

Saturday, November 13, 2010

Solving Linear and Quadratic Programming Problems by MATLAB

Introduction
Optimization is defined as Minimizing (or Maximizing) an objective function subject to some constraints .If the objective function and the all the constrains are linear it is called linear programming. If the objective function is quadratic and the all the constraints are linear, it is known as quadratic programming. Let us learn how to use the linear and quadratic programming routines of the MATLAB.
Linear programming
The command for implementing the matlab linear programming routine is ‘linprog’.
Let us consider a linear programming problem with ‘n’ variables, ‘m’ inequality constraints, ‘k’ equality constraints, and the lower ,upper bounds LB and UB.
The linear programming is defined in matlab like this
min f'*x    subject to:   A*x <= b, Aeq*x = beq ,LB≤ x ≤ UB
x-=[x1 x2 x3 ….xn]T x is a column matrix of 1 X n) to be determined.  
f=[c1 c2 c3 ….cn]  f is a vector(row matrix of n X 1)
A is the matrix of inequalities having a size of m X n
Aeq is the matrix of equalities having a size of k X n
LB-=[l1 l2 l3 ….ln]T x is a column matrix of 1 X n)
UB= [u1 u2, u3 ….un]T x is a column matrix of 1 X n)
Example
f=[10 5 12 13 20];
A= [10     6     1     0     8
     2     8     4     7     0
     6     9     8     4     7
     5     7     0     9     4
     9     2     1     5     8
     8     4     2     4     5
     5     9     2     8     7
     0     9     6     5     4
     8     4     3     2     3
     4     9     2     7     2];
b=[70    63   104    80    81    68   101    81    53    71]';
Aeq=[1 1 1 1 1]
beq=15;
LB=[0 0 0 0 0]'
UB=[20 20 20 20 20]'
X=linprog(f,A,b,Aeq,beq,LB,UB)
Solution
Optimization terminated.
X =
    2.1683
    0.0000
    9.6931
    2.8416
    0.2970
Quadratic programming
The command for implementing the matlab quadratic programming routine is ‘quadprog’.Let us consider a quadratic programming problem with ‘n’ variables, ‘m’ inequality constraints, ‘k’ equality constraints, and the lower, upper bounds LB and UB.
The quadratic programming is defined in matlab like this
   min 0.5*x'*H*x + f'*x    subject to:   A*x <= b, Aeq*x = beq ,LB≤ x ≤ UB
x-=[x1 x2 x3 ….xn]T x is a column matrix of 1 X n) to be determined.  
H= is a square matrix of n X n
f=[c1 c2 c3 ….cn]  f is a vector(row matrix of n X 1)
A is the matrix of inequalities having a size of m X n
Aeq is the matrix of equalities having a size of k X n
LB-=[l1 l2 l3 ….ln]T x is a column matrix of 1 X n)
UB= [u1 u2, u3 ….un]T x is a column matrix of 1 X n)
Example
Minimize x1^2+x1x2+x22+3x1+5x2
Subject to the constraints
x1+x2=20;
2x1+3x2≤100
[0 0]T≤x1,x2≤[50 50]T
H=[2 1;1 2];
f=[3 5];
A= [2 3];
b=[100];
Aeq=[1 1]
beq=20;
LB=[0 0 0 0 0]';
UB=[50 50]';
[X ff]=quadprog(H,f,A,b,Aeq,beq,LB,UB)
Solution
X =
   11.0000
    9.0000
ff is the objective function value
ff =  379.0000

4 comments:

Anonymous said...

Wow! Finally I got a web site from where I be capable of genuinely take valuable data
concerning my study and knowledge.

Here is my web blog - review of provillus

Anonymous said...

I'm amazed, I have to admit. Rarely do I encounter a blog that's
both educative and engaging, and let me tell you, you've hit the nail on the head. The issue is an issue that not enough folks are speaking intelligently about. I'm very happy that I stumbled across this in my search for something relating to this.


Feel free to visit my webpage :: clips.bakbanaan.net

Anonymous said...

Great post.

my web blog ... http://phen375reviews-online.blogspot.com/

Anonymous said...

Hello everyone, it's my first visit at this web page, and article is genuinely fruitful for me, keep up posting such content.

Have a look at my web page ... zetaclear reviews

Post a Comment