21 views (last 30 days)

hello, i am trying to do linear programming. and i am trying to find the minimum of my objective function.

i have attached the code. and my problem statement is also attached. i keep getting error for my equality constraints i tried every possible way known to me to solve. still couldn't fix it if anyone could suggest a way, it would be really helpful thank you

Matt J
on 14 Feb 2018

Edited: Matt J
on 14 Feb 2018

for that that L I need values for x(1) and x(2)...such that pv*x(1)+pw*x(2)-L=0 or atleast close to Zero

The above is a a version of what you said here with corrections added by me based on your later comments.

If the whole point is really to minimize |pv*x(1)+pw*x(2)-L| subject to bounds on x, then you should really be using lsqlin:

N=length(pv);

clear x

for i=N:-1:1

f=[pv(i) pw(i)];

[x{i} fval{i}]=lsqlin(f,l(i),[],[],[],[], [0.5,0.5],[2.5,2]);

end

Matt J
on 14 Feb 2018

yes its working now

If so, please Accept-click the answer to certify that the question has been addressed.

The set of all possible solutions will typically be an infinite set of points satisfying the inequalities,

L-optimalValue <= pv*x1+pw*x2 <= L+optimalValue

lbv<= x(1) <=ubv

lbw<= x(2) <=ubw

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 8 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535145

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535145

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535170

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535170

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535180

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535180

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535181

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535181

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535192

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535192

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535196

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535196

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535201

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535201

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535202

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/382575-linear-programming-optimization-equality-constraints#comment_535202

Sign in to comment.