Glpk java 输出
Glpk java output
如何在我的控制台或文件上打印 java-glpk 中所有已解决的问题?
像这样:
(此输出来自 gusek)
------ ------------ ------------- ------------- -------------
1 x[1] * 1 0 1
2 x[2] * 1 0 1
3 x[3] * 0 0 1
4 x[4] * 1 0 1
5 x[5] * 1 0 1
6 x[6] * 1 0 1
我的 java 代码中的听众(GlpkCallback.addListener(this) 和 GlpkTerminal.addListener(this))只是 return this:
GLPK Integer Optimizer, v4.55
3 rows, 15440 columns, 46320 non-zeros
15440 integer variables, all of which are binary
Preprocessing...
1 row, 15440 columns, 15440 non-zeros
15440 integer variables, all of which are binary
Scaling...
A: min|aij| = 5.718e+001 max|aij| = 2.719e+005 ratio = 4.755e+003
GM: min|aij| = 1.000e+000 max|aij| = 1.000e+000 ratio = 1.000e+000
EQ: min|aij| = 1.000e+000 max|aij| = 1.000e+000 ratio = 1.000e+000
2N: min|aij| = 6.701e-001 max|aij| = 1.330e+000 ratio = 1.985e+000
Constructing initial basis...
Size of triangular part is 1
Solving LP relaxation...
GLPK Simplex Optimizer, v4.55
1 row, 15440 columns, 15440 non-zeros
* 0: obj = 1.584183802e+007 infeas = 0.000e+000 (0)
* 500: obj = 1.190189187e+007 infeas = 0.000e+000 (0)
* 1000: obj = 1.142465659e+007 infeas = 0.000e+000 (0)
* 1500: obj = 1.122247777e+007 infeas = 0.000e+000 (0)
* 1615: obj = 1.121676854e+007 infeas = 0.000e+000 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
+ 1615: mip = not found yet >= -inf (1; 0)
+ 1615: >>>>> 1.121676854e+007 >= 1.121676854e+007 0.0% (1; 0)
Better solution found
+ 1615: mip = 1.121676854e+007 >= tree is empty 0.0% (0; 1)
INTEGER OPTIMAL SOLUTION FOUND
希望有人能提供帮助。
这是我的 java 代码:
https://jsfiddle.net/ilucasrds/enok1h5k/3/
在示例中,您展示了两种不同的东西。
一方面,听众的输出包含求解器 运行 时提供的所有信息。另一方面,gusek 示例在求解器完成后提供了解决方案。
根据您想要的解决方案的信息类型,API 有四种不同的例程供您选择:
int glp_print_sol(glp_prob *P, const char *fname);
int glp_print_ipt(glp_prob *P, const char *fname);
int glp_print_mip(glp_prob *P, const char *fname);
对于 KKT-Conditions(simplex/interiorpoint) 和整数可行性报告。
int glp_print_ranges(glp prob *P, int len, const int list[], int flags,
const char *fname);
写敏感度分析报告,与gusek输出相当。使用附加的 len 和 list[] 属性,可以定义一组更具体的 rows/cols 到 analyse/output。如果 len 为零,则分析每个 row/col。
对于解决方案的进一步代码处理,也可以使用
double glp_get_obj_coef(glp_prob *P, int j);
这将 return 定义列的 objective 系数
如何在我的控制台或文件上打印 java-glpk 中所有已解决的问题?
像这样: (此输出来自 gusek)
------ ------------ ------------- ------------- -------------
1 x[1] * 1 0 1
2 x[2] * 1 0 1
3 x[3] * 0 0 1
4 x[4] * 1 0 1
5 x[5] * 1 0 1
6 x[6] * 1 0 1
我的 java 代码中的听众(GlpkCallback.addListener(this) 和 GlpkTerminal.addListener(this))只是 return this:
GLPK Integer Optimizer, v4.55
3 rows, 15440 columns, 46320 non-zeros
15440 integer variables, all of which are binary
Preprocessing...
1 row, 15440 columns, 15440 non-zeros
15440 integer variables, all of which are binary
Scaling...
A: min|aij| = 5.718e+001 max|aij| = 2.719e+005 ratio = 4.755e+003
GM: min|aij| = 1.000e+000 max|aij| = 1.000e+000 ratio = 1.000e+000
EQ: min|aij| = 1.000e+000 max|aij| = 1.000e+000 ratio = 1.000e+000
2N: min|aij| = 6.701e-001 max|aij| = 1.330e+000 ratio = 1.985e+000
Constructing initial basis...
Size of triangular part is 1
Solving LP relaxation...
GLPK Simplex Optimizer, v4.55
1 row, 15440 columns, 15440 non-zeros
* 0: obj = 1.584183802e+007 infeas = 0.000e+000 (0)
* 500: obj = 1.190189187e+007 infeas = 0.000e+000 (0)
* 1000: obj = 1.142465659e+007 infeas = 0.000e+000 (0)
* 1500: obj = 1.122247777e+007 infeas = 0.000e+000 (0)
* 1615: obj = 1.121676854e+007 infeas = 0.000e+000 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
+ 1615: mip = not found yet >= -inf (1; 0)
+ 1615: >>>>> 1.121676854e+007 >= 1.121676854e+007 0.0% (1; 0)
Better solution found
+ 1615: mip = 1.121676854e+007 >= tree is empty 0.0% (0; 1)
INTEGER OPTIMAL SOLUTION FOUND
希望有人能提供帮助。
这是我的 java 代码: https://jsfiddle.net/ilucasrds/enok1h5k/3/
在示例中,您展示了两种不同的东西。 一方面,听众的输出包含求解器 运行 时提供的所有信息。另一方面,gusek 示例在求解器完成后提供了解决方案。
根据您想要的解决方案的信息类型,API 有四种不同的例程供您选择:
int glp_print_sol(glp_prob *P, const char *fname);
int glp_print_ipt(glp_prob *P, const char *fname);
int glp_print_mip(glp_prob *P, const char *fname);
对于 KKT-Conditions(simplex/interiorpoint) 和整数可行性报告。
int glp_print_ranges(glp prob *P, int len, const int list[], int flags,
const char *fname);
写敏感度分析报告,与gusek输出相当。使用附加的 len 和 list[] 属性,可以定义一组更具体的 rows/cols 到 analyse/output。如果 len 为零,则分析每个 row/col。
对于解决方案的进一步代码处理,也可以使用
double glp_get_obj_coef(glp_prob *P, int j);
这将 return 定义列的 objective 系数