can the variables be negative ?

i have maximize the function below
z=0.75x1+0.91x2+0.98x3;
subject to
150x1+275x2+310x3<=1000
3.75x1+4.55x2+4.90x3<=1000
150x1+275x2<=500
i tried to find out the value using linpro() function
[x opt]=ling(-c,A,b)
x1= 775.7752
x2=-421.3319
opt=-200

2 Comments

linpro()? But you used ling().
[x opt]=ling(-c,A,b)
If course if there are no bounds specified (as there weren't)
Keep reading the documentation for all the variations -- you need the one at least with
x = linprog(f,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on the design variables, x, so that the solution is always in the range lb ≤ x ≤ ub. Set Aeq = [] and beq = [] if no equalities exist.
to specify the lb array.
Your sample code above is full of typos and missing variables; I didn't try to fix it to be able to run it...

Sign in to comment.

Answers (0)

Categories

Asked:

on 9 Jan 2022

Commented:

dpb
on 9 Jan 2022

Community Treasure Hunt

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

Start Hunting!