Maximize z in the following linear program:
Afficher commentaires plus anciens
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 commentaires
Dyuman Joshi
le 24 Sep 2023
What have you tried yet?
Afuaab Koohg
le 24 Sep 2023
Afuaab Koohg
le 24 Sep 2023
Matt J
le 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
le 24 Sep 2023
Modifié(e) : Afuaab Koohg
le 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
le 24 Sep 2023
Torsten
le 24 Sep 2023
Done.
Réponses (0)
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
