我尝试使用GLPK实现this线性问题。当我用摇滚剪刀游戏(混合策略中有均衡x=(1/3, 1/3, 1/3)
,y=(1/3, 1/3, 1/3
)进行测试时,我已经得到了不可行的解决方案。
我回到MathProg检查它是否会成功。不幸的是它也失败了。我想这是由于-1
值,因为基本的单纯形法不允许负变量,并且需要进行一些转换才能绕过它(虽然我认为它只涉及变量而GLPK会自动执行此操作)
我已经定义了这样的问题:
玩家1的模型:
set P1S;
set P2S;
param Payoff{P1S, P2S};
var y{P1S} >= 0;
minimize GameValue: sum{i in P1S} y[i];
s.t. Condition2{j in P2S}:
sum{i in P1S} Payoff[i,j] * y[i] >= 1;
solve;
printf "Value: %s\n", GameValue;
printf "Player 1 strategies:\n";
for{i in P1S}
printf "Found %s, actual %s\n", y[i], y[i]/GameValue;
end;
数据:
data;
set P1S := r p s;
set P2S := r p s;
param Payoff
: r p s :=
r 0 -1 1
p 1 0 -1
s -1 1 0;
end;
我跑了:
$ glpsol --model rps.mod --data rps.dat
GLPSOL: GLPK LP/MIP Solver, v4.54
Parameter(s) specified in the command line:
--model rps.mod --data rps.dat
Reading model section from rps.mod...
22 lines were read
Reading data section from rps.dat...
12 lines were read
Generating GameValue...
Generating Condition2...
Model has been successfully generated
GLPK Simplex Optimizer, v4.54
4 rows, 3 columns, 9 non-zeros
Preprocessing...
3 rows, 3 columns, 6 non-zeros
Scaling...
A: min|aij| = 1.000e+00 max|aij| = 1.000e+00 ratio = 1.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 3
0: obj = 0.000000000e+00 infeas = 3.000e+00 (0)
LP HAS NO PRIMAL FEASIBLE SOLUTION
glp_simplex: unable to recover undefined or non-optimal solution
Time used: 0.0 secs
Memory used: 0.1 Mb (126428 bytes)
我猜对了,我可以应用一些简单的解决方法(例如设置一些标志)?或者是我搞砸了的其他事情(以错误的方式写下问题或忽略了某些事情)?
修改
通过常量1
增加矩阵的每个值(使所有值都为非负值)后,我获得了正确的解决方案(GameValue
也被1
移动了所以我可以通过减去它)。它是否仅在这种情况下有效,或者如果(在运行GLPK之前)我会将所有参数增加常数以使它们全部为非负值?我可以在GLPK中设置一些标志来自动完成吗?
答案 0 :(得分:0)