【发布时间】:2017-09-08 20:03:05
【问题描述】:
我正在使用 Glpk java 来解决 LP 松弛问题。
奇怪的是,有时它可以工作,但有时 JVM 会崩溃。当它崩溃时我有这个错误:
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffedcbb4d92,
pid=16584, tid=17184
#
# JRE version: Java(TM) SE Runtime Environment (8.0_66-b18) (build 1.8.0_66 b18)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.66-b18 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [ntdll.dll+0x14d92]
有时它会无声地崩溃,当它崩溃时,它是在 glpk DLL 文件中的随机本机函数上(即 glp_simplex 和 glp_delete_prob)。
这是我的代码的一部分:
// Allocate memory
ind = GLPK.new_intArray(problem.getNbrConstraints());
val = GLPK.new_doubleArray(problem.getNbrConstraints());
// Create rows
GLPK.glp_add_rows(lp, problem.getNbrConstraints());
// Set row details
for (int i = 0; i < problem.getNbrConstraints(); i++) {
GLPK.glp_set_row_name(lp, i + 1, "c" + (i + 1));
GLPK.glp_set_row_bnds(lp, i + 1, GLPKConstants.GLP_DB, 0, problem.getB(i));
for (int j = 0; j < problem.getNbrVaribles(); j++) {
GLPK.intArray_setitem(ind, j + 1, j + 1);
GLPK.doubleArray_setitem(val, j + 1, problem.getItem(j).getRessource(i));
}
GLPK.glp_set_mat_row(lp, i + 1, problem.getNbrVaribles(), ind, val);
}
// Free memory
GLPK.delete_intArray(ind);
GLPK.delete_doubleArray(val);
// Define objective
GLPK.glp_set_obj_name(lp, "z");
GLPK.glp_set_obj_dir(lp, GLPKConstants.GLP_MAX);
for (int j = 0; j < problem.getNbrVaribles(); j++) {
GLPK.glp_set_obj_coef(lp, j + 1, problem.getItem(j).getProfit());
}
// Write model to file
GLPK.glp_write_lp(lp, null, "lp.lp");
// Solve model
parm = new glp_smcp();
GLPK.glp_init_smcp(parm);
ret = GLPK.glp_simplex(lp, parm);
// Free memory
GLPK.glp_delete_prob(lp);
有什么想法吗?
谢谢。
【问题讨论】:
-
我看到了同样的问题。就我而言,在删除问题期间引发了异常。也许添加崩溃日志会帮助其他人给你提示