I wrote the following code in Matlab in order to solve a problem:
% Problem design.
C = [6 ; 4 ; 7; 5];
A = [1 2 1 2 ; 6 5 3 2 ; 3 4 9 12];
B = [20 ; 100 ; 75 ];
% Our variables X are positive (thus lower bounded by zeros)
% but not upper bounded.
LB = zeros(size(C));
UB = inf(size(C));
% Solve using linprog. Use empty matrices for Aeq and beq because
% we do not have additional equality constraints.
[ X , val ] = linprog(C,A,B,[],[],LB,UB);
% Output results.
disp(X)
disp(val)
However, X becomes the LB vector and as such the solution is 0. This happens for whatever value i set the LB vector to be, the function seems to substitute X for the LB vector. Any help would be appreciated as i thought this code was fine.
You are trying to solve the problem
$$\min c^Tx $$
subject to
$$Ax \le b$$
$$x \ge l$$
where every entry of $A$ and $b$ and $c$ are nonnegative.
Hence the smaller each component of $x$ is, the more optimal is the solution.
Edit:
note that $\max c^Tx = - \min (-c)^Tx$