• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IloRange类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ilog.concert.IloRange的典型用法代码示例。如果您正苦于以下问题:Java IloRange类的具体用法?Java IloRange怎么用?Java IloRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IloRange类属于ilog.concert包,在下文中一共展示了IloRange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getConstraintList

import ilog.concert.IloRange; //导入依赖的package包/类
@Override
public List<ConditionalConstraint> getConstraintList() {
	//There's some overhead here for avoiding duplicates
	Set<ConditionalConstraint> ccSet = new HashSet<ConditionalConstraint>();
	List<ConditionalConstraint> ccList = new ArrayList<ConditionalConstraint>();
	
	for (IloRange range : getRangeList()) {
		
		ConditionalConstraint cc = m_rangeMap.get( range );
		
		if (cc != null) {
			
			if (!ccSet.contains( cc )) {
		
				ccList.add( cc );
				ccSet.add( cc );
			}
		}
	}
	
	return ccList;
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:23,代码来源:CCAwareCPLEXLPSolverImpl.java


示例2: getConflictReactions

import ilog.concert.IloRange; //导入依赖的package包/类
/**
 * returns reactions that show conflict in current lp matrix
 * 
 * @param lp
 *            current calculated model
 * @return list of conflict reactions
 * @throws IloException
 */
protected ArrayList<String> getConflictReactions() throws IloException {
	ArrayList<String> conflict = new ArrayList<String>();
	IloRange[] x = m_lp.getRanges();
	double[] p = new double[x.length];
	for (int i = 0; i < p.length; i++) {
		p[i] = 1;
	}
	m_cplex.refineConflict(x, p);
	ConflictStatus[] cs = m_cplex.getConflict(x);
	for (int i = 0; i < cs.length; i++) {
		if (cs[i] == ConflictStatus.Member) {
			String name = x[i].getName();
			if (name.startsWith(ThermoChecker.RX_PREFIX) || name.startsWith(ThermoChecker.RX_REV_PREFIX)) {
				conflict.add(name);
			}
		}
	}
	return conflict;
}
 
开发者ID:mpgerstl,项目名称:tEFMA,代码行数:28,代码来源:CplexHandler.java


示例3: convertToIloConstraints

import ilog.concert.IloRange; //导入依赖的package包/类
private List<IloRange> convertToIloConstraints(
    Iterable<Cutset<V, E>> cutsets) throws IloException {
  List<IloRange> ans = Lists.newArrayList();
  double best = 0;
  Cutset<V, E> bestCut = null;
  IloRange bestConstraint = null;
  for (Cutset<V, E> cut : cutsets) {
    IloRange constraint = makeCutsetConstraint(cut);
    if (cut.getViolation() > best) {
      bestCut = cut;
      best = cut.getViolation();
      bestConstraint = constraint;
    }
    ans.add(constraint);
  }
  // System.out.println(bestCut == null ? "0" : bestCut.getViolation());
  // return bestCut == null ? Lists.<IloConstraint>newArrayList():
  // Lists.<IloConstraint>newArrayList(bestConstraint);
  return ans;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:21,代码来源:CycleChainPackingPolytope.java


示例4: main

import ilog.concert.IloRange; //导入依赖的package包/类
@Override
protected void main() throws IloException {
  if (!this.isAfterCutLoop()) {
    return;
  }
  int time = numUserCutCallback++;
  if (time % 500 == 0 && time != 0) {
    System.err.println("completed about: " + time
        + " user cut callbacks.  MIP gap: " + this.getMIPRelativeGap());
  }
  UserCutGenerator userCutGen = polytope.makeUserCutGenerator(this);
  List<IloRange> violatedConstraints = userCutGen.quickUserCut();
  if (!solverOptions.contains(SolverOption.disableFullUserCut)
      && violatedConstraints.size() == 0 && this.getNnodes64() == 0) {
    violatedConstraints = userCutGen.fullUserCut();
  }
  for (IloRange constraint : violatedConstraints) {
    this.add(constraint);
  }
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:21,代码来源:CycleChainPackingSubtourElimination.java


示例5: main

import ilog.concert.IloRange; //导入依赖的package包/类
@Override
protected void main() throws IloException {
	int time = numLazyConstraintCallback++;
	if(time %500 == 0 && time != 0){
		System.err.println("completed about: " + time + " lazy cut callbacks.  Integrality gap: " + this.getMIPRelativeGap());
	}
	
	List<IloRange> violatedConstraints = Lists.newArrayList();
	violatedConstraints.addAll(phaseOneProblem.lazyConstraint(this));
	for(CycleChainPackingPolytope<V,E> phaseTwoProbem: phaseTwoProblems){
		violatedConstraints.addAll(phaseTwoProbem.lazyConstraint(this));
	}
	for(IloRange constraint: violatedConstraints){
		this.add(constraint);
	}
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:17,代码来源:TwoStageEdgeFailureSolver.java


示例6: addColumn

import ilog.concert.IloRange; //导入依赖的package包/类
/**
 * @param column
 * @param name
 * @return Index of the newly added column
 * @throws CPException
 */
@Override
public int addColumn(double[] column, String name) throws CPException {
	
	try {
		
		IloObjective obj = m_model.getObjective();
		IloColumn col = m_model.column( obj, column[0] );
		int index = 1;
		
		for (IloRange range : m_ranges) {
			//Install the new column at every constraint
			col = col.and( m_model.column( range, column[index++] ) );
		}
		
		addVar( m_model.numVar(col, 0.0, 1.0, name));
		m_objCoeffs = ArrayUtils.add(m_objCoeffs, column[0]);//TODO This must be damn fucking slow!
		
		return getColumnNumber() - 1 + getFirstColumnIndex();
		
	} catch( IloException e ) {

		m_logger.fatal( e );
		
		throw new CPException(e);
	}
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:33,代码来源:CPLEXLPSolverImpl.java


示例7: addRange

import ilog.concert.IloRange; //导入依赖的package包/类
protected void addRange(IloNumVar[] vars, double[] coeffs, double lb, double ub, String name) throws IloException {
	
	IloNumExpr expr = m_model.scalProd( coeffs, vars );
	IloRange range = NumberUtils.equal( lb, ub, PRECISION_THRESHOLD )
		? m_model.addEq( expr, lb, name )
		: m_model.addRange( lb, expr, ub, name );

	addRange( range );		
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:10,代码来源:CPLEXLPSolverImpl.java


示例8: removeRange

import ilog.concert.IloRange; //导入依赖的package包/类
protected void removeRange(int index) throws IloException {
	
	IloRange range = m_ranges.get( index );
	
	m_model.delete( range );
	m_ranges.remove( index );
	m_nameRangeMap.remove( range.getName() );
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:9,代码来源:CPLEXLPSolverImpl.java


示例9: removeRange

import ilog.concert.IloRange; //导入依赖的package包/类
@Override
protected void removeRange(IloRange range) throws IloException {
	
	if (range != null) {
		
		m_rangeMap.remove( range );
		super.removeRange( range );
	}
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:10,代码来源:CCAwareCPLEXLPSolverImpl.java


示例10: HeuristicConcentration

import ilog.concert.IloRange; //导入依赖的package包/类
/**
 * Creates a new <code>HeuristicConcentration</code>
 * 
 * @param instance
 */
public HeuristicConcentration(IVRPInstance instance, ISolutionFactory soluitonFactory) {
    mInstance = instance;
    mSolutionFactory = soluitonFactory;
    mCoverCtrs = new IloRange[Utilities.getMaxId(instance.getRequests()) + 1];

}
 
开发者ID:vpillac,项目名称:vroom,代码行数:12,代码来源:HeuristicConcentration.java


示例11: ChangeCoefficientsInSubModel

import ilog.concert.IloRange; //导入依赖的package包/类
public void ChangeCoefficientsInSubModel(double[] shadowPrices, PartialSolution partialSolutions, 
        double bound, double gap) throws IloException{
    double[] tmp = new double[problemInstanceSingleDevice.getNumbSlots()];
    Helpers.InitializeTo(tmp, 1.0 / problemInstanceSingleDevice.getNumbSlots(), 0, problemInstanceSingleDevice.getNumbSlots());
     
    if(ReducedCost != null) patSolver.remove(ReducedCost);
    ReducedCost = patSolver.addMaximize(patSolver.diff(patSolver.scalProd(x, shadowPrices), patSolver.scalProd(x, tmp)));
   
    //setting bound on the criterion value
    if(bound < 0){
       patSolver.setParam(IloCplex.DoubleParam.CutLo, bound);
    }
    else{
       patSolver.setParam(IloCplex.DoubleParam.CutLo, -Double.MAX_VALUE);
    }
    
    if(fixedAssignmentRequirements != null) patSolver.remove(fixedAssignmentRequirements);
    fixedAssignmentRequirements = new IloRange [problemInstanceSingleDevice.getNumbSlots()];
    
    //Processing partial solutions
    for(int j = 0; j < problemInstanceSingleDevice.getNumbSlots(); j++){
        if(partialSolutions.getPartialSolutions()[problemInstanceSingleDevice.getNumbOfDeviceInArray()][j] == 1){
            fixedAssignmentRequirements[j] = patSolver.addEq(x[j], 1);
        }

        if(partialSolutions.getPartialSolutions()[problemInstanceSingleDevice.getNumbOfDeviceInArray()][j] == 0){
            fixedAssignmentRequirements[j] = patSolver.addEq(x[j], 0);
        }
     }
    
    //sub-model does not solve it to optimum, but integrality gap should be less than "gap" value
    patSolver.setParam(IloCplex.DoubleParam.EpGap, gap);
}
 
开发者ID:CTU-IIG,项目名称:BandP_TDM,代码行数:34,代码来源:SubModel.java


示例12: addCut

import ilog.concert.IloRange; //导入依赖的package包/类
/**
 * If a violated inequality has been found add it to the master problem.
 * @param subtourInequality subtour inequality
 */
private void addCut(SubtourInequality subtourInequality){
	if(masterData.subtourInequalities.containsKey(subtourInequality))
		throw new RuntimeException("Error, duplicate subtour cut is being generated! This cut should already exist in the master problem: "+subtourInequality);
	//Create the inequality in cplex
	try {
		IloLinearNumExpr expr=masterData.cplex.linearNumExpr();
		//Register the columns with this constraint.
		for(PricingProblemByColor pricingProblem : masterData.pricingProblems){
			for(Matching matching: masterData.getColumnsForPricingProblemAsList(pricingProblem)){
				//Test how many edges in the matching enter/leave the cutSet (edges with exactly one endpoint in the cutSet)
				int crossings=0;
				for(DefaultWeightedEdge edge: matching.edges){
					if(subtourInequality.cutSet.contains(dataModel.getEdgeSource(edge)) ^ subtourInequality.cutSet.contains(dataModel.getEdgeTarget(edge)))
						crossings++;
				}
				if(crossings>0){
					IloNumVar var=masterData.getVar(pricingProblem,matching);
					expr.addTerm(crossings, var);
				}
			}
		}
		IloRange subtourConstraint = masterData.cplex.addGe(expr, 2, "subtour");
		masterData.subtourInequalities.put(subtourInequality, subtourConstraint);
	} catch (IloException e) {
		e.printStackTrace();
	}
}
 
开发者ID:coin-or,项目名称:jorlib,代码行数:32,代码来源:SubtourInequalityGenerator.java


示例13: buildModel

import ilog.concert.IloRange; //导入依赖的package包/类
/**
 * Build the cplex problem
 */
@Override
protected CuttingStockMasterData buildModel() {
	try {
		cplex =new IloCplex(); //Create cplex instance
		cplex.setOut(null); //Disable cplex output
		cplex.setParam(IloCplex.IntParam.Threads, config.MAXTHREADS); //Set number of threads that may be used by the cplex

		//Define the objective
		obj= cplex.addMinimize();

		//Define constraints
		satisfyDemandConstr=new IloRange[dataModel.nrFinals];
		for(int i=0; i< dataModel.nrFinals; i++)
			satisfyDemandConstr[i]= cplex.addRange(dataModel.demandForFinals[i], dataModel.demandForFinals[i], "satisfyDemandFinal_"+i);

		//Define a container for the variables
	} catch (IloException e) {
		e.printStackTrace();
	}

	//Define a container for the variables
	Map<PricingProblem,OrderedBiMap<CuttingPattern, IloNumVar>> varMap=new LinkedHashMap<>();
	varMap.put(pricingProblems.get(0),new OrderedBiMap<>());

	//Return a new data object which will hold data from the Master Problem. Since we are not working with inequalities in this example,
	//we can simply return the default.
	return new CuttingStockMasterData(varMap);
}
 
开发者ID:coin-or,项目名称:jorlib,代码行数:32,代码来源:Master.java


示例14: getDominatedActionExpression

import ilog.concert.IloRange; //导入依赖的package包/类
/**
 * Using dynamic programming, this method computes an expression representing the value of a given action not chosen to be made optimal. This is done by creating an expression whose value is the sum of the value of descendant information sets under the action, according to the evaulation function and strategy for the rational player
 * @param informationSetId
 * @param dominatedAction the action to compute a value expression for
 * @param dominatedActionExpressionTable dynamic programming table
 * @return expression that represents the value of the action
 * @throws IloException
 */
private IloLinearNumExpr getDominatedActionExpression(int informationSetId, Action dominatedAction, HashMap<Action,IloLinearNumExpr> dominatedActionExpressionTable) throws IloException {
	if (dominatedActionExpressionTable.containsKey(dominatedAction)) {
		return dominatedActionExpressionTable.get(dominatedAction);
	} else {
		// this expression represents the value of dominatedAction
		IloLinearNumExpr expr = cplex.linearNumExpr();
		//TIntObjectMap<IloNumVar> informationSetToVariableMap = new TIntObjectHashMap<IloNumVar>();
		TIntObjectMap<HashMap<String, IloRange>> rangeMap = new TIntObjectHashMap<HashMap<String, IloRange>>();
		IloNumVar actionValueVar = cplex.numVar(-Double.MAX_VALUE, Double.MAX_VALUE, "DomActionValue;"+Integer.toString(informationSetId) + dominatedAction.getName());
		expr.addTerm(1, actionValueVar);
		IloRange range = cplex.addGe(actionValueVar, 0, actionValueVar.getName());
		// Iterate over nodes in information set and add value of each node for dominatedAction
		TIntArrayList informationSet = game.getInformationSet(playerNotToSolveFor, informationSetId);
		for (int i = 0; i < informationSet.size(); i++) {
			Node node = game.getNodeById(informationSet.get(i));
			// we need to locate the action that corresponds to dominatedAction at the current node, so that we can pull the correct childId
			Action dominatedActionForNode = node.getActions()[0];
			for (Action action : node.getActions()) {
				if (action.getName().equals(dominatedAction.getName())) dominatedActionForNode = action;
			}

			// find the descendant information sets and add their values to the expression
			//fillDominatedActionExpr(expr, dominatedActionForNode.getChildId(), informationSetToVariableMap, exprMap, 1, Integer.toString(informationSetId) + dominatedAction.getName());
			fillDominatedActionRange(range, dominatedActionForNode.getChildId(), rangeMap, 1, Integer.toString(informationSetId) + dominatedAction.getName());
		}
		// remember the expression for future method calls
		dominatedActionExpressionTable.put(dominatedAction, expr);
		
		return expr;
	}
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:40,代码来源:LimitedLookAheadOpponentSolver.java


示例15: getDominatedActionExpression

import ilog.concert.IloRange; //导入依赖的package包/类
/**
 * Using dynamic programming, this method computes an expression representing the value of a given action not chosen to be made optimal. This is done by creating an expression whose value is the sum of the value of descendant information sets under the action, according to the evaulation function and strategy for the rational player
 * @param informationSetId
 * @param dominatedAction the action to compute a value expression for
 * @param dominatedActionExpressionTable dynamic programming table
 * @return expression that represents the value of the action
 * @throws IloException
 */
private IloLinearNumExpr getDominatedActionExpression(int informationSetId, Action dominatedAction, HashMap<Action,IloLinearNumExpr> dominatedActionExpressionTable) throws IloException {
    if (dominatedActionExpressionTable.containsKey(dominatedAction)) {
        return dominatedActionExpressionTable.get(dominatedAction);
    } else {
        // this expression represents the value of dominatedAction
        IloLinearNumExpr expr = cplex.linearNumExpr();
        //TIntObjectMap<IloNumVar> informationSetToVariableMap = new TIntObjectHashMap<IloNumVar>();
        TIntObjectMap<HashMap<String, IloRange>> rangeMap = new TIntObjectHashMap<HashMap<String, IloRange>>();
        IloNumVar actionValueVar = cplex.numVar(-Double.MAX_VALUE, Double.MAX_VALUE, "DomActionValue;"+Integer.toString(informationSetId) + dominatedAction.getName());
        expr.addTerm(1, actionValueVar);
        IloRange range = cplex.addGe(actionValueVar, 0, actionValueVar.getName());
        // Iterate over nodes in information set and add value of each node for dominatedAction
        TIntArrayList informationSet = game.getInformationSet(playerNotToSolveFor, informationSetId);
        for (int i = 0; i < informationSet.size(); i++) {
            Node node = game.getNodeById(informationSet.get(i));
            // we need to locate the action that corresponds to dominatedAction at the current node, so that we can pull the correct childId
            Action dominatedActionForNode = node.getActions()[0];
            for (Action action : node.getActions()) {
                if (action.getName().equals(dominatedAction.getName())) dominatedActionForNode = action;
            }

            // find the descendant information sets and add their values to the expression
            //fillDominatedActionExpr(expr, dominatedActionForNode.getChildId(), informationSetToVariableMap, exprMap, 1, Integer.toString(informationSetId) + dominatedAction.getName());
            fillDominatedActionRange(range, dominatedActionForNode.getChildId(), rangeMap, 1, Integer.toString(informationSetId) + dominatedAction.getName());
        }
        // remember the expression for future method calls
        dominatedActionExpressionTable.put(dominatedAction, expr);

        return expr;
    }
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:40,代码来源:LimitedLookaheadUncertaintySolver.java


示例16: addConstraint

import ilog.concert.IloRange; //导入依赖的package包/类
public static IloRange addConstraint(IloNumExpr expr,
    RelationType relationType, double rhs, IloCplex cplex)
    throws IloException {
  if (relationType.equals(RelationType.eq)) {
    return cplex.addEq(expr, rhs);
  } else if (relationType.equals(RelationType.geq)) {
    return cplex.addGe(expr, rhs);
  } else if (relationType.equals(RelationType.leq)) {
    return cplex.addLe(expr, rhs);
  } else {
    throw new RuntimeException(
        "Unidentified relation type defining equation " + relationType);
  }
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:15,代码来源:CplexUtil.java


示例17: lazyConstraint

import ilog.concert.IloRange; //导入依赖的package包/类
@Override
public List<IloRange> lazyConstraint(VariableExtractor variableExtractor)
    throws IloException {
  if (this.solverOptions.contains(SolverOption.lazyConstraintCallback)) {
    return (new LongCycleCutGenerator(variableExtractor, CplexUtil.epsilon,
        kepInstance.getMaxCycleLength() + 1)).quickUserCut();
  } else {
    return Lists.newArrayList();
  }
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:11,代码来源:EdgePolytope.java


示例18: makeCycleConstraint

import ilog.concert.IloRange; //导入依赖的package包/类
private IloRange makeCycleConstraint(CycleCut<E> cycleCut)
    throws IloException {
  DirectedSparseMultigraph<V, E> graph = kepInstance.getGraph();
  Set<E> constraintEdges = new HashSet<E>();
  for (E edge : cycleCut.getCycle().getEdgesInOrder()) {
    constraintEdges.addAll(graph.findEdgeSet(graph.getSource(edge),
        graph.getDest(edge)));
  }
  return cplex.le(edgeVariables.integerSum(constraintEdges), cycleCut
      .getCycle().size() - 1);
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:12,代码来源:EdgePolytope.java


示例19: convertToIloConstraints

import ilog.concert.IloRange; //导入依赖的package包/类
private List<IloRange> convertToIloConstraints(
    Iterable<CycleCut<E>> cycleCuts) throws IloException {
  List<IloRange> ans = Lists.newArrayList();
  for (CycleCut<E> cycleCut : cycleCuts) {
    ans.add(makeCycleConstraint(cycleCut));
  }
  return ans;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:9,代码来源:EdgePolytope.java


示例20: makeCutsetConstraint

import ilog.concert.IloRange; //导入依赖的package包/类
private IloRange makeCutsetConstraint(Cutset<V, E> cutset)
    throws IloException {
  /*
   * IloLinearIntExpr cut = edgeVariables.integerSum(cutset.getCutEdges());
   * this.flowInterface.addFlowInIntScaled(cutset.getRhs(), cut, -1); return
   * cplex.ge(cut, 0);
   */

  IloLinearIntExpr flowInRhs = cplex.linearIntExpr();
  this.flowInterface.addFlowInIntScaled(cutset.getRhs(), flowInRhs, 1);
  return (IloRange) cplex.ge(edgeVariables.integerSum(cutset.getCutEdges()),
      flowInRhs);
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:14,代码来源:CycleChainPackingPolytope.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SignatureType类代码示例发布时间:2022-05-22
下一篇:
Java VoidType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap