Determine how much kilogram of each food item the person should consume so as to have maximum intake of vitamins by using appropriate built in function present in MATLAB

조회 수: 2 (최근 30일)
According to a dietician, a person should consume exactly 200 gm of carbohydrates,at least 175 gm of proteins and at most 150 gm of fats in a meal. The dietician also recommends to have as much amount of vitamins as possible. The three food items that the person eats has 80, 65 and 30 gm of carbohydrates per kilogram of food item. The same food items contain 10, 12, 23 gm of proteins in each kilogram. Per kilogram of the same food items comprise of 32, 56 and 42 gm of fats. Vitamins contained in per kilogram of the same food items are 70, 37 and 58 gm.
Determine how much kilogram of each food item the person should consume so as to have maximum intake of vitamins by using appropriate built in function present in MATLAB
  댓글 수: 2
Walter Roberson
Walter Roberson 2023년 9월 3일
Matrix methods cannot deal with the inequalities -- at least 175 gm of proteins, and at most 150 gm of fats . You need some kind of optimization to deal with those.

댓글을 달려면 로그인하십시오.

답변 (1개)

Abdul
Abdul 2022년 10월 19일
Problem based approach
%% In the current problem, x1 , X2 and x3 are the three decision variables
x = optimvar('x',3,'LowerBound', [0 0 0],'UpperBound', [inf inf inf]);
%% In the current problem, objective function is Maximize Z = 0.070X1 +0.037X2 + 0.058X3
obj = (0.070*x(1) + 0.037 * x(2) + 0.058 * x(3));
%% In the current problem, constraints are: 0.080X1 + 0.065X2 +0.030X3 <=0.200 and 0.010X1 +0.012X2+ 0.023X3 <=0.175
% and 0.032X1 + 0.056X2 + 0.042X3 <=0.150
A = 0.080*x(1) + 0.065*x(2) + 0.030*x(3) <= 0.200;
B = 0.010*x(1) + 0.012*x(2) + 0.023*x(3) <= 0.175;
C = 0.032*x(1) + 0.056*x(2) + 0.042*x(3) <=0.150;
prob = optimproblem('Objective',obj,'ObjectiveSense','maximize');
prob.Constraints.con_1 = A;
prob.Constraints.con_2 = B;
prob.Constraints.con_3 = C;
x0.x = [0 0 0];
[sol,fval,exitflag,output] = solve(prob,x0)
Solver Based approach
%%linprog solves the maximization linear programming problems;
%[x fval] = linprog(f,A,b,Aeq,beq,lb,ub)
f = [0.070 0.037 0.058];A = [0.080 0.065 0.030;0.010 0.012 0.023;0.032 0.056 0.042];b = [0.200;0.175;0.150];
Aeq = [];Beq = [];
lb = [0 0 0]; ub = [inf inf inf];
[x fval] = linprog(-f,A,b,Aeq,Beq,lb,ub)
Output x = 1.6250 0 2.3333
fval = 0.2491

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by