本文整理汇总了Java中org.gnu.glpk.GLPK.glp_simplex方法的典型用法代码示例。如果您正苦于以下问题:Java GLPK.glp_simplex方法的具体用法?Java GLPK.glp_simplex怎么用?Java GLPK.glp_simplex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gnu.glpk.GLPK
的用法示例。
在下文中一共展示了GLPK.glp_simplex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: solveLP
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
/**
* Solves the model using the simplex method by default.
*/
@Override
public STATUS solveLP() {
m_simplexCtrl.setMeth( GLPKConstants.GLP_PRIMAL );
m_simplexCtrl.setTm_lim( 3000 );
//GLPK.glp_write_lp(m_model, null, "C:\\kl\\tmp\\test.lp" );
GLPK.glp_simplex(m_model, m_simplexCtrl);
//TODO Rethink perturbation (see commented stuff below) later
/* if (resFlag == GLPKConstants.GLP_ETMLIM) {
//This means that the model is too hard to solve, most probably due to high
//primal degeneracy. We perturb it by relaxing lower (=0) column bounds,
//solve the perturbed version and then try to *re-optimize* the original version
m_logger.info( "LP model is too hard, we will perturb it and solve that version first" );
perturb(m_model, -1E-06);
m_simplexCtrl.setTm_lim( 300000 );
m_logger.info( "Solving perturbed instance..." );
resFlag = GLPK.glp_simplex(m_model, m_simplexCtrl);
m_logger.info( "... done, restoring the original instance" );
//saveBasis();
perturb(m_model, 0d);
//restoreBasis();
if( resFlag == 0 ) {
m_logger.info( "Solving the original instance..." );
m_simplexCtrl.setPresolve( GLPKConstants.GLP_OFF );
m_simplexCtrl.setMeth( GLPKConstants.GLP_DUAL );
resFlag = GLPK.glp_simplex( m_model, m_simplexCtrl );
m_logger.info( resFlag == 0 ? "... done!" : "... it didn't work, fail :(" );
} else m_logger.info( "Perturbed instance is no easier, fail" );
}
if (resFlag != 0) {
writeLP( "C:///kl//tmp//bad.glpk" );
//There's no hope...
throw new CPException("GLPK simplex solver returned an error: " + resFlag, null);
}*/
return getStatus();
}
示例2: search
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
protected void search(glp_iocp ctrl) {
//long ts = System.currentTimeMillis();
if (ctrl.getPresolve() == GLPKConstants.GLP_OFF) {
super.getSimplexCtrl().setPresolve( GLPKConstants.GLP_OFF );
GLPK.glp_simplex( getModel(), super.getSimplexCtrl() );
}
GLPK.glp_intopt(getModel(), ctrl);
//GLPK.glp_write_prob( getModel(), 0, "C:///kl//tmp//test.glpk" );
/*if (System.currentTimeMillis() - ts > 10000) {
GLPK.glp_write_lp( getModel(), null, "C:///kl//tmp//" + "hard_" + (System.currentTimeMillis() - ts) + ".lp" );
}*/
if (m_logger.isDebugEnabled()) {
m_logger.debug("MIP size: " + GLPK.glp_get_num_cols(getModel()) + " x " + GLPK.glp_get_num_rows(getModel()));
}
}