Linprog doesn't satisfy b constraints when it contains negative coefficients?
Mostra commenti meno recenti
I'm trying to maximize an objective function using linprog. A simplified version (of an assignment problem) is to maximize:
-2062595m_10 + 4854093m_01 + 7911803m_11 subject to:
m_10 + m_11 <= 2
m_01 + m_11 <= 1
m_10>=0, m_01>=0,m_11>=0
The intuition being there are 2 "resources" and 1 "task". The correct solution should assign one resource to the task (7911803 (m_11==1)) and -2062595 (m_10==1) to account for the other unassigned resource. m_01==0 if the task is not assigned to either resource.
I code this in Matlab as:
f=[-2062595;4854093;7911803];
A=[1 0 1; 0 1 1];
b=[2; 1];
lb=zeros(length(A),1);
Then I solve it using:
options = optimset('LargeScale', 'off', 'Simplex', 'on');
[x,fval,exitflag,output,lambda] = linprog(-f,A,b,[],[],lb,[],[], options);
The output for x is:
x =
0
0
1.00
But it should be:
x =
1.00
0
1.00
In other words, it should pick x(1) given my b vector of constraints and sum to the number of resources (2 in this case). The problem only occurs when there are negative coefficients in the f vector. If I optimize instead using:
f=[2062595;4854093;7911803];
Then I get the desired x vector (above). My questions are:
Question 1. Why won't it solve when I include negative constraints?
Question 2. How does Matlab choose lambda.eqlin? I get (for the positive coefficients case):
lambda.ineqlin
ans =
2062595.81
5849207.54
Your help is very much appreciated.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Solver Outputs and Iterative Display in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!