当前位置: 首页>>代码示例>>Java>>正文


Java GLPK.glp_simplex方法代码示例

本文整理汇总了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();
	}
 
开发者ID:klinovp,项目名称:pronto,代码行数:53,代码来源:GLPKLPSolverImpl.java

示例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()));
	}
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:24,代码来源:GLPKMIPSolverImpl.java


注:本文中的org.gnu.glpk.GLPK.glp_simplex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。