Using linprog to minimize an objective function not consisting of constants?

5 views (last 30 days)
I usually use linprog to minimize a function where the objective function consists of constants; for example,
2*(x1) + 3*(x2) + 4*(x3)
represented as the vector
f = [2; 3; 4].
However, suppose I want to minimize the following sum of equations:
(3-2*(x1)) + (4-2*(x2)) + (2-2*(x3))
The objective function here would not consist of constants, so how can I use linprog to find an x vector that minimizes the sum of these functions? If not possible, then is there some other method?

Answers (1)

Matt J
Matt J on 12 Jun 2013
Edited: Matt J on 12 Jun 2013
The terms in your objective function can be regrouped as
f(x) = -2*x1 - 2*x2 -2*x3 +9
The +9 can be ignored because it only shifts the objective, without changing the location of minima. The problem is therefore equivalent to minimizing
f(x) = -2*x1 - 2*x2 -2*x3
which is in the usual form that LINPROG accepts.
  4 Comments
Mike Vukovich
Mike Vukovich on 12 Jun 2013
Thanks, I was also looking at fgoalattain - what's the difference? Basically, I have an optimization problem where the objective is to get as close as possible to a certain value, rather than minimization or maximization.
Matt J
Matt J on 12 Jun 2013
Edited: Matt J on 12 Jun 2013
FGOALATTAIN is for problems with a vector of objective functions and where the value reached by each of those objective functions individually (as opposed to just their sum) is important.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!