Quiz I am trying to convert a statement into equation
3 views (last 30 days)
Show older comments
Joshua Amuga
on 26 Oct 2016
Commented: Joshua Amuga
on 1 Nov 2016
I have a question. How can create a program that can perform a task for accurate decision making. For example, I need to take a decision based on some constrains is have in a business. this are the facts. I have 75 machines that can produce two products say B=Bucket, and K=Kettle, The cost expense for electricity and materials for the production of 30 cartoons of Bucket is N210 and the profit per cartoon is N2.00 while for the kettle the cost /material expenses is N120 and the profit per cartoon is N1.30. How you are restricted by two factors N15,000 for expenses and 4000 storage capacity for the warehouse, So how can you utilize effectively the 75 machines
0 Comments
Accepted Answer
Stefano Gianoli
on 27 Oct 2016
Following the guideline contained in
you can easily solve the problem as follow:
First you need to define an objective or cost function. This function must describe a minimization problem.
Let's assume you want to maximize the profit or minimize it negate as a function of the number of Bucket x(1) and Kettle x(2).
Your cost function then is:
f'*x := f(1) * x(1) + f(2) * x(2)
hence
>> f = [-2; -1.3];
let's define the inequality constraints for the production costs
7 * x(1) + 4 * x(2) <= 15000
and for the size of the warehouse:
x(1) + x(2) <= 4000
in matrix form
>> A = [7 4; 1 1];
>> b = [15000; 4000];
also x(1) and x(2) can assume value in the range 0 <= x <= 4000, therefore the lower bound and upper bound constrains are
>> lb = [0 0];
>> ub = [4000 4000];
you don't have any equality constrains therefore
>> Aeq = [];
>> beq = [];
Now you are ready to call the LP solver:
>> options = optimoptions('linprog','Algorithm','dual-simplex');
>> [x,fval,exitflag,output] = linprog(f,A,b,Aeq,beq,lb,ub,options);
the optimal solution should be
>> x
x =
0
3750
so the maximum profit within the given cost is given by producing 3750 Kettle only. You still have 250 storage capacity available in the warehouse, so this constraint wasn't hit.
The fact that we have 75 machines to utilize effectively is irrelevant for the above solution. Perhaps additional information such the production type: continuous or batch, time scheduled for producing B or K, etc. would make this additional information necessary/useful.
More Answers (1)
Shlomo
on 26 Oct 2016
It's a unit commitment problem (and there's much literature on it). It's an integer programming problem and Matlab has a solver for this class of problems https://www.mathworks.com/help/optim/ug/intlinprog.html.
Basically you define a cost function that includes the profit from selling your items and the cost of electricity, etc. Then you feed in your constraints (max costs, storage capacity and machine capacity) and the solver will give you an optimal solution (to within some tolerance).
If you are looking to solve large-scale problems I would recommend you look into dedicated Mixed Integer Programming (MIP) solvers.
See Also
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!