Reputation: 53
So I need to use MatLab to solve an optimization problem but this question doesn't have to be for a specific problem, this question is for optimization in general.
How do you get linprog()
or intlinprog()
to get the maximum solution? As far as I know, these functions only find the minimum solution to optimization problems but I need the maximum solutions.
How do I get the linear programming functions on matlab to return the maximum solution of an optimization problem?
Thanks in advance!
Upvotes: 1
Views: 4086
Reputation:
From documentation entries for the function linprog
the function is called like that
x = linprog(f, A, b)
in order to find min f'x.
If you instead call
x = linprog(-f, A, b)
you will find max f'x
Upvotes: 2
Reputation: 193
Reverse the sign of the objective function f (vector of multipliers) with a negative sign. Maximizing a function is the same as minimizing the negative of the same function.
Upvotes: 1