Maximize z in the following linear program:
Show older comments
I have a question about Linear program
Given A = [1 1; -1 1; 0 -1], b = [10;10;0]
maximize z
subject to A(i) * x + z ≤ b(i) ∀i ∈{2,3}
-A(t) * x + z ≤ -b(t) ∀t ∈{1}
z ≤ 1 \\* or any other constant
8 Comments
Dyuman Joshi
on 24 Sep 2023
What have you tried yet?
Afuaab Koohg
on 24 Sep 2023
Afuaab Koohg
on 24 Sep 2023
Matt J
on 24 Sep 2023
The problem formulaton does not do anything with the matrix A. Additionally, there is a vector a that has not been defined.
Afuaab Koohg
on 24 Sep 2023
Edited: Afuaab Koohg
on 24 Sep 2023
I get
x = [10 1]
z = 1
as solution.
A = [1 1; -1 1; 0 -1]; b = [10;10;0];
f = [0 0 -1];
i = [2,3]; t = [1];
% Define the inequality constraints for cplus and cminus
A_ineq = [A(i, :) ones(2,1); -A(t, :) ones(1,1)];
b_ineq = [b(i); -b(t)];
% Define the upper bounds for variables (no upper bound for x, z <= 1)
lb = -Inf(size(f));
ub = Inf(size(f));
ub(end) = 1; % z <= 1
% Solve the linear program using linprog
options = optimset('Display', 'off'); % Suppress solver output
[x_z, ~, exitflag] = linprog(f, A_ineq, b_ineq, [],[],lb, ub, options)
Afuaab Koohg
on 24 Sep 2023
Torsten
on 24 Sep 2023
Done.
Answers (0)
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!