Maximize z in the following linear program:

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

Look into linprog.
What have you tried yet?
I have but the problem is unbounded:
x =[]
Here is my code
A = [1 1; -1 1; 0 -1]; b = [10;10;0];
f = zeros(size(A, 2) + 1, 1); % +1 for the z variable
i = [2,3]; t = [1]
% Define the inequality constraints for cplus and cminus
A_ineq = [A(i, :); -A(t, :)];
b_ineq = [b(i); -b(t)];
% Define the upper bounds for variables (no upper bound for x, z <= 1)
lb = -Inf(size(f));
ub = ones(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);
Matt J
Matt J 2023년 9월 24일
The problem formulaton does not do anything with the matrix A. Additionally, there is a vector a that has not been defined.
Afuaab Koohg
Afuaab Koohg 2023년 9월 24일
편집: Afuaab Koohg 2023년 9월 24일
@Matt J: I have edited the question. It was a typo. I intended for A
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)
x_z = 3×1
10 1 1
exitflag = 1
@Torsten: Could you share your code becauise I get
Torsten
Torsten 2023년 9월 24일
Done.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

제품

질문:

2023년 9월 24일

댓글:

2023년 9월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by