Solving linear programming problems with MATLAB and lingo

Source: Internet
Author: User

Production plan for processed dairy products
Processing 1 barrels of milk has two processing methods, (1) Production 12 hours to get 3 kg A1, profit 24 Yuan/kg (2) Production 8 hours to get 4 kg A2,

Profit 16 Yuan/kg
Every day:
50 barrels of milk time 480 hours processing up to 100 kg A1
Develop production plans to maximize daily profit

Analysis:
Set x1 barrels milk production a1x1 barrels milk production A2
The production of A1 profit 24X3X1 production A2 profit 16x4 x2
Daily profit
Max z=72x1+64x2
Constraint conditions
Raw Material x1+x2≤50
Time 12xx1+8xx2≤480
Processing capacity 3xx1≤100
Non-negative constrained x1,x2≥0
Lingo Code

Model:
max=72*x1+64*x2;
[Milk] x1+x2<50;
[Time]
12*x1+8*x2<480;
[cpct] 3*x1<100;
End

Results

  Global optimal solution found.
  Objective value:                              3360.000
  infeasibilities:                              0.000000 Total
  solver iterations:                             2


                       Variable           Value        Reduced cost
                             X1        20.00000            0.000000
                             X2        30.00000            0.000000

                            Row    Slack or Surplus      Dual Price
                              1        3360.000            1.000000
                           MILK        0.000000            48.00000
                           time        0.000000            2.000000
                           cpct        40.00000            0.000000

MATLAB solution

f= (-1) *[72 64]; % because the maximum value is required here to take the opposite number, Linprog is to find the minimum value of
a=[1 1;12 8;3 0;-1 0;0-1];
B=[50 480 0 0];
[Xopt Fxopt]=linprog (f,a,b)
-fxopt   % and then take negative to get maximum value

Code 2

f= (-1) *[72 64]; % because the maximum value is required here to take the opposite number, Linprog is to find the minimum value of
a=[1 1;12 8;3 0];
B=[50 480];
LB=[0;0];
[Xopt Fxopt]=linprog (f,a,b,[],[],lb)
-fxopt   % and then take negative to get maximum value

Results

Optimization terminated.

xopt =

   20.0000
   30.0000


fxopt =

 -3.3600e+003


ans =

  3.3600e+003

General form of linear programming
Minf=c1x1+c2x2+...+cnxn \min F=c_1x_1+c_2x_2+...+c_nx_n
S.t.⎧⎩⎨⎪⎪⎪⎪⎪⎪⎪⎪a11x1+a12x2+...+a1nxn≤b1a21x1+a22x2+...+a2nxn≤b2..............................am1x1+a

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.