Why does the the f vector in a linear equation always consist of negative values?

1 view (last 30 days)
A simultaneous linear equation usually will consist of two types of equation(I will be using a fundraiser event as an example), which are the parameters(budget, deadlines, location) and a value to be maximized(i.e. the money raised). Normally we would solve these types of equations in MATLAB using the command simlp. From what I understand, simlp requires three different vectors to use. A and b, which represents the parameters for the problem, and f, represents the function of the maximized value. Now my question is, why are the values in vector f always negative, while some values of vector A and b still can remain positive? Attached below is a sample question.
We let w, x, y, and z, denote the number of residences canvassed in the four cities Gotham, Metropolis, Oz, and River City, respectively.
Then the linear inequalities specified by the given data are as follows:
Nonnegative data: w ≥ 0, x ≥ 0, y ≥ 0, z ≥ 0;
Pamphlets: w + x + y + z ≤ 50,000; T
ravel cost: 0.5w + 0.5x + y + 2z ≤ 40,000;
Time available: 2w + 3x + y + 4z ≤ 18,000;
Preferences: w ≤ x, x + y ≤ z; 282
Contributions: w + 0.25x + 0.5y + 3z ≥ 10,000.
The quantity to be maximized is: Voter support: 0.6w + 0.6x + 0.5y + 0.3z.
The vector form is as follows:
f = [-0.6 -0.6 -0.5 -0.3];
A = [1 1 1 1; 0.5 0.5 1 2; 2 3 1 4; 1 -1 0 0; 0 1 1 -1; -1...
-0.25 -0.5 -3; -1 0 0 0; 0 -1 0 0; 0 0 -1 0; 0 0 0 -1];
b = [50000; 40000; 18000; 0; 0; -10000; 0; 0; 0; 0];

Accepted Answer

Matt J
Matt J on 12 Sep 2020
Edited: Matt J on 12 Sep 2020
Well, I've never heard of simlp, but many solvers, such as linprog() will only solve minimization problems, so if you have an objective function that you want to maximize, you need to multiply f by -1 in order to recast the maximization as a minimization.
Note however, that if you have R2017 or higher, you can use the problem-based optimization framwork, which will let you specify explicitly that the objective is to be maximized. Your example problem above could therefore be implemented without a sign flip as follows:
w=optimvar('w',1,'LowerBound',0);
x=optimvar('x',1,'LowerBound',0);
y=optimvar('y',1,'LowerBound',0);
z=optimvar('z',1,'LowerBound',0);
prob=optimproblem('ObjectiveSense','maximize', 'Objective', 0.6*w+0.6*x+0.5*y*0.3*z);
prob.Constraints.Pamphlets= w + x + y + z <=50,000;
prob.Constraints.TravelCost= 0.5*w + 0.5*x + y + 2*z<= 40,000;
prob.Constraints.TimeAvailable= 2*w + 3*x + y + 4*z <= 18,000;
prob.Constraints.Pref1= w <= x;
prob.Constraints.Pref2= x + y <=z;
prob.Constraints.Contributions= w + 0.25*x + 0.5*y + 3*z >= 10,000;
sol=solve(prob);
  1 Comment
Kevin Juan
Kevin Juan on 12 Sep 2020
"you need to multiply f by -1 in order to recast the maximization as a minimization." Exactly what I need. Just noticed that the parametric functions are searching for maximum values, while the objective function f searches for the minimum. Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!