Matlab linprog为有界模型产生无限结果

时间:2017-02-05 05:35:32

标签: matlab linear-programming

clear
A=[-1 0 -1 0; 0 -1 0 -1; 1 1 0 0; 0 0 1 1];
b=[-50 -70 80 45];
f=[0.5; 0.6; 0.4; 0.55];
options = optimoptions('linprog','Algorithm','dual-simplex');
[x,fval,exitflag,output] = linprog(f,A,b,[],[],[],[],options);

上面显示的代码产生一个无界结果Problem is unbounded,其中Lindo和Excel Solver找到最佳目标函数值62.5

2 个答案:

答案 0 :(得分:0)

当我运行时:

clear
A=[-1 0 -1 0; 0 -1 0 -1; 1 1 0 0; 0 0 1 1];
b=[-50 -70 80 45];
f=[0.5; 0.6; 0.4; 0.55];
options = optimoptions('linprog','Algorithm','simplex','display','iter');
x0=[0 0 0 0]'
[x,fval,exitflag,output] = linprog(f,A,b,[],[],[],[],x0,options);

我明白了:

Phase 1: Compute initial basic feasible point.
      Iter            Infeasibility
       0                      120
       1                       70
       2                       40
       3                       -0

Phase 2: Minimize using simplex.
      Iter            Objective              Dual Infeasibility 
                        f'*x                   A'*y+z-w-f
       0                   63                    0.111803
       1                 62.5                        0.05
Exiting: The problem is unbounded; the constraints are not restrictive enough.

与你提到的解决方案相同。

但是没有什么能阻止求解器增加x

答案 1 :(得分:0)

这是正确的行为考虑了matlab的linprog正在做什么。

观察的原因如下:

  • linprog假设变量免费(( - inf,inf),如果没有给出约束),就像你的情况一样

你的解决方案(用Lindo观察)就是那个解决方案 - 向量被限制为非负的

这可以通过约束或使用边界来表达。文档给出了以下示例:

Example: To specify that all x-components are positive, lb = zeros(size(f))
    # personal opinion: this should be called "nonnegative"   

我不是Matlab用户,但使用我的工具,我可以验证:

  • 没有非负性约束的问题/或表达相同的界限是无界的
  • 约束/边界的问题有 62.5
  • 的解决方案

备注:许多数学编程框架/求解器假设解决方案向量默认为非负,这与linprog正在做的不同。前者是潜在算法理论的结果。