How to prevent objective function from becoming negative with the linprog solver (i.e minimum should be 0)

11 ビュー (過去 30 日間)
John
John 2013 年 12 月 9 日
回答済み: Alan Weiss 2013 年 12 月 9 日
Hi there,
I am using the linprog solver to find two decision variables (x1 and x2) in order to minimize an objective function. The objective function is the cost of a process, for example:
Cost = x1*constant + x2*constant
My question is how can I prevent the solver from computing a negative objective function (i.e a negative cost). Logically the minimum cost is 0 but the solver is finding the optimal value for x1 and x2 such that cost is negative which doesn't make sense.
I would appreciate any help
Sincerely
John

回答 (1 件)

Alan Weiss
Alan Weiss 2013 年 12 月 9 日
You can add a constraint that the cost must be positive. This is a linear constraint:
-x1*constant1 -x2*constant2 <= 0
Alan Weiss
MATLAB mathematical toolbox documentation

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by