GNU Linear Programming Kit

glpk, http://en.wikipedia.org/wiki/GNU_Linear_Programming_Kit

一个最简单的例子

 1 /* decision variables */
 2 
 3 var x1 >= 0;
 4 var x2 >= 0;
 5 var x3 >= 0;
 6 var x4 >= 0;
 7 
 8 /* objective function */
 9 minimize result: x1 + x2 + x3 + x4;
10 
11 /* constraints */
12 a: -2*x1 + 8*x2 + 0*x3 + 10*x4 >= 50;
13 b: 5*x1 + 2*x2 + 0*x3 + 0*x4 >= 100;
14 c: 3*x1 - 5*x2 + 10*x3 - 2*x4 >= 25;
15 
16 solve;
17 
18 end;
View Code

求解:

glpsol -m haha.model -o result.out

posted @ 2013-06-13 23:02  qsort  阅读(261)  评论(0编辑  收藏  举报