Maximize z in the following linear program:
Mostrar comentarios más antiguos
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 comentarios
Dyuman Joshi
el 24 de Sept. de 2023
What have you tried yet?
Afuaab Koohg
el 24 de Sept. de 2023
Afuaab Koohg
el 24 de Sept. de 2023
Matt J
el 24 de Sept. de 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
el 24 de Sept. de 2023
Editada: Afuaab Koohg
el 24 de Sept. de 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
el 24 de Sept. de 2023
Torsten
el 24 de Sept. de 2023
Done.
Respuestas (0)
Categorías
Más información sobre Linear Programming and Mixed-Integer Linear Programming en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
