%% Create and Solve Maximization Problem
% Create a linear programming problem for maximization. The problem has two positive variables and three linear inequality constraints.

prob = optimproblem('ObjectiveSense','max');

%
% Create positive variables. Include an objective function in the problem.

x = optimvar('x',2,1,'LowerBound',0);
prob.Objective = x(1) + 2*x(2);

%
% Create linear inequality constraints in the problem.

cons1 = x(1) + 5*x(2) <= 100;
cons2 = x(1) + x(2) <= 40;
cons3 = 2*x(1) + x(2)/2 <= 60;
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
prob.Constraints.cons3 = cons3;

%
% Review the problem.

show(prob)

%
% Solve the problem.

sol = solve(prob);
sol.x

%
% Copyright 2012 The MathWorks, Inc.