How to set positive lambdas in quadprog?

1 view (last 30 days)
V Maximov
V Maximov on 8 Sep 2018
Hi,
I am working on a simple solver that would maximise a function that is attached.
%%quadprog
% Initial coeffiecients
% a_bi = [3; 4; 3];
% b_bi = [9; 7; 10];
% a_si = [3; 4; 3];
% b_si = [2; 2; 1];
% The entire utility functions look like this
% u_1 = -3*x_b1^2 + 9*x_b1 - p_ 1*x_b1 + p_ 1*x_s1 - 3*x_s1 - 2*x_s1
% u_2 = -4*x_b2^2 + 7*x_b2 - p_ 2*x_b2 + p_ 2*x_s2 - 4*x_s2 - 2*x_s2
% u_3 = -3*x_b3^2 + 10*x_b3 - p_ 3*x_b3 + p_ 3*x_s3 - 3*x_s3 - 1*x_s3
% Here we change all signs to - so that we get the maximum instead of minimum
% Looks like
% -u_1 = 3*x_b1^2 - 9*x_b1 + p_ 1*x_b1 - p_ 1*x_s1 + 3*x_s1 + 2*x_s1
% x_b1 x_b2 x_b3 x_s1 x_s2 x_s3 f12 f13 f23
H = [ 3, 0, 0, 0, 0, 0, 0, 0, 0; % -a_b1
0, 4, 0, 0, 0, 0, 0, 0, 0; % -a_b2
0, 0, 3, 0, 0, 0, 0, 0, 0; % -a_b3
0, 0, 0, 3, 0, 0, 0, 0, 0; % -a_s1
0, 0, 0, 0, 4, 0, 0, 0, 0; % -a_s2
0, 0, 0, 0, 0, 3, 0, 0, 0; % -a_s3
0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0
];
% -b_b1 -b_b2 -b_b3 -b_s1 -b_s2 -b_s3 f12 f13 f23
f = [ -9; -7; -10; 2; 2; 1; 0; 0; 0];
% x_b1 x_b2 x_b3 x_s1 x_s2 x_s3 f12 f13 f23
Aeq = [-1, 0, 0, 1, 0, 0, -1, -1, 0; % x_s1 - x_b1 = f12 + f13
0, -1, 0, 0, 1, 1, 1, 0, -1; % x_s2 - x_b2 = -f12 + f23
0, 0, -1, 0, 0, 1, 0, 1, 1; % x_s3 - x_b3 = -f13 - f23
-1, -1, -1, 1, 1, 1, 0, 0, 0 % -x_b1 - x_b2 - x_b3 + x_s1 + x_s2 + x_s3 = 0
];
beq = [0; 0; 0; 0];
options = optimoptions ('quadprog', 'Algorithm', 'interior-point-convex', 'Display', 'off')
[x, fval, exitflag, output, lambda] = quadprog (H, f, A, b, Aeq, beq, [], [], [], options);
x;
In the process of optimisation I get correct values of x. However, the lambdas are negative. They are supposed to be positive because I am solving a natural problem which cannot have negative volumes or values.
I have two questions: 1. Could these negative lambdas be a consequence of minimising negative as opposed to maximising positive? If yes, how to fix it. 2. What is a way to set a constraint on lambdas to ensure that they are nonnegative?
Thank you.

Answers (0)

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!