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


Java IloException类代码示例

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


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

示例1: checkInCplex

import ilog.concert.IloException; //导入依赖的package包/类
public synchronized void checkInCplex(IloCplex cplex) {
    if (cplex == null) {
        return;
    }
    try {
        cplex.getParameterSet().clear();
        
        cplex.clearCallbacks();
        cplex.clearModel();
    } catch (IloException e) {
        logger.error("Exception clearing model: " + e.getMessage(), e);
        
        cplex.end();
        inUse.remove(cplex);
        this.notify();
        return;
    }
    inUse.remove(cplex);
    available.add(cplex);
    this.notify();
}
 
开发者ID:blubin,项目名称:JOpt,代码行数:22,代码来源:InstanceManager.java

示例2: addObjective

import ilog.concert.IloException; //导入依赖的package包/类
private void addObjective() throws IloException {

		// one binary variable per concept
		if (DEBUG) {
			String[] names = new String[this.concepts.size()];
			for (int i = 0; i < names.length; i++)
				names[i] = "c" + i;
			this.conceptVars = this.problem.boolVarArray(this.concepts.size(), names);
		} else {
			this.conceptVars = this.problem.boolVarArray(this.concepts.size());
		}

		// sum of weights of selected concepts
		IloLinearNumExpr obj = this.problem.linearNumExpr();
		for (int i = 0; i < this.conceptVars.length; i++)
			obj.addTerm(this.conceptVars[i], this.concepts.get(i).weight);
		this.problem.addMaximize(obj);

	}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:20,代码来源:SubgraphILP.java

示例3: addVariable

import ilog.concert.IloException; //导入依赖的package包/类
@Override
public void addVariable(String varName, double objWeight, double lowerBound, double upperBound, boolean override, boolean isZVar) throws ILPException
{
    try {
        IloNumVarType type = null;
        if(upperBound > 1) {
            type = IloNumVarType.Int;
        } else {
            type = IloNumVarType.Bool;
        }
        IloNumVar var = cplex.numVar(lowerBound, upperBound, type, varName);
        if(override || !variables.containsKey(varName)) {
            variables.put(varName, var);
            cplex.add(var);
            objective.put(varName, objWeight);
        }
    } catch(IloException e) {
        throw new ILPException(e.getMessage());
    }
}
 
开发者ID:jnoessner,项目名称:rockIt,代码行数:21,代码来源:CplexConnector.java

示例4: addConstraint

import ilog.concert.IloException; //导入依赖的package包/类
@Override
public void addConstraint(ArrayList<ILPVariable> lhs, ILPOperator operator, double rhs) throws ILPException
{
    try {
        IloLinearNumExpr constraint = cplex.linearNumExpr();
        for(ILPVariable var : lhs) {
            if(!variables.containsKey(var.getName())) {
                this.addVariable(var.getName(), 0d, 0d, 1d, false, var.isZVar());
            }
            constraint.addTerm(var.getValue(), variables.get(var.getName()));
        }

        switch(operator) {
            case LEQ:
                cplex.addLe(constraint, rhs);
            break;
            case GEQ:
                cplex.addGe(constraint, rhs);
            break;
            default:
            break;
        }
    } catch(IloException e) {
        throw new ILPException(e.getMessage());
    }
}
 
开发者ID:jnoessner,项目名称:rockIt,代码行数:27,代码来源:CplexConnector.java

示例5: dfs

import ilog.concert.IloException; //导入依赖的package包/类
private void dfs(Node root, Set<Node> component, boolean fake, Blocks bs, Separator separator) throws IloException {
    separator.addComponent(graph.subgraph(component), root);
    if (!fake) {
        for (Node node : component) {
            cplex.addLe(cplex.diff(y.get(node), y.get(root)), 0);
        }
    }
    for (Edge e : graph.edgesOf(root)) {
        if (!component.contains(graph.getOppositeVertex(root, e))) {
            continue;
        }
        cplex.addEq(getX(e, root), 0);
    }
    for (Node cp : bs.cutpointsOf(component)) {
        if (root != cp) {
            for (Set<Node> comp : bs.incidentBlocks(cp)) {
                if (comp != component) {
                    dfs(cp, comp, false, bs, separator);
                }
            }
        }
    }
}
 
开发者ID:ctlab,项目名称:sgmwcs-solver,代码行数:24,代码来源:RLTSolver.java

示例6: initVariables

import ilog.concert.IloException; //导入依赖的package包/类
private void initVariables() throws IloException {
    y = new LinkedHashMap<>();
    w = new LinkedHashMap<>();
    d = new LinkedHashMap<>();
    x = new LinkedHashMap<>();
    x0 = new LinkedHashMap<>();
    for (Node node : graph.vertexSet()) {
        String nodeName = Integer.toString(node.getNum() + 1);
        d.put(node, cplex.numVar(0, Double.MAX_VALUE, "d" + nodeName));
        y.put(node, cplex.boolVar("y" + nodeName));
        x0.put(node, cplex.boolVar("x_0_" + (node.getNum() + 1)));
    }
    for (Edge edge : graph.edgeSet()) {
        Node from = graph.getEdgeSource(edge);
        Node to = graph.getEdgeTarget(edge);
        String edgeName = (from.getNum() + 1) + "_" + (to.getNum() + 1);
        w.put(edge, cplex.boolVar("w_" + edgeName));
        IloNumVar in = cplex.boolVar("x_" + edgeName + "_in");
        IloNumVar out = cplex.boolVar("x_" + edgeName + "_out");
        x.put(edge, new Pair<>(in, out));
    }
}
 
开发者ID:ctlab,项目名称:sgmwcs-solver,代码行数:23,代码来源:RLTSolver.java

示例7: tuning

import ilog.concert.IloException; //导入依赖的package包/类
private void tuning(IloCplex cplex) throws IloException {
    if (logLevel < 2) {
        cplex.setOut(null);
        cplex.setWarning(null);
    }
    if (isLBShared) {
        cplex.use(new MIPCallback(logLevel == 0));
    }
    cplex.setParam(IloCplex.IntParam.Threads, threads);
    cplex.setParam(IloCplex.IntParam.ParallelMode, -1);
    cplex.setParam(IloCplex.IntParam.MIPOrdType, 3);
    if (tl.getRemainingTime() <= 0) {
        cplex.setParam(IloCplex.DoubleParam.TiLim, EPS);
    } else if (tl.getRemainingTime() != Double.POSITIVE_INFINITY) {
        cplex.setParam(IloCplex.DoubleParam.TiLim, tl.getRemainingTime());
    }
}
 
开发者ID:ctlab,项目名称:sgmwcs-solver,代码行数:18,代码来源:RLTSolver.java

示例8: breakRootSymmetry

import ilog.concert.IloException; //导入依赖的package包/类
private void breakRootSymmetry() throws IloException {
    int n = graph.vertexSet().size();
    PriorityQueue<Node> nodes = new PriorityQueue<>();
    nodes.addAll(graph.vertexSet());
    int k = n;
    IloNumExpr[] terms = new IloNumExpr[n];
    IloNumExpr[] rs = new IloNumExpr[n];
    while (!nodes.isEmpty()) {
        Node node = nodes.poll();
        terms[k - 1] = cplex.prod(k, x0.get(node));
        rs[k - 1] = cplex.prod(k, y.get(node));
        k--;
    }
    IloNumVar sum = cplex.numVar(0, n, "prSum");
    cplex.addEq(sum, cplex.sum(terms));
    for (int i = 0; i < n; i++) {
        cplex.addGe(sum, rs[i]);
    }
}
 
开发者ID:ctlab,项目名称:sgmwcs-solver,代码行数:20,代码来源:RLTSolver.java

示例9: sumConstraints

import ilog.concert.IloException; //导入依赖的package包/类
private void sumConstraints() throws IloException {
    // (31)
    cplex.addLe(cplex.sum(graph.vertexSet().stream().map(x -> x0.get(x)).toArray(IloNumVar[]::new)), 1);
    if (root != null) {
        cplex.addEq(x0.get(root), 1);
    }
    // (32)
    for (Node node : graph.vertexSet()) {
        Set<Edge> edges = graph.edgesOf(node);
        IloNumVar xSum[] = new IloNumVar[edges.size() + 1];
        int i = 0;
        for (Edge edge : edges) {
            xSum[i++] = getX(edge, node);
        }
        xSum[xSum.length - 1] = x0.get(node);
        cplex.addEq(cplex.sum(xSum), y.get(node));
    }
}
 
开发者ID:ctlab,项目名称:sgmwcs-solver,代码行数:19,代码来源:RLTSolver.java

示例10: initWeights

import ilog.concert.IloException; //导入依赖的package包/类
private void initWeights() throws IloException {
    if (!inited) {
        init();
    }
    double[] values = getValues(vars);
    for (CutGenerator generator : generatorList) {
        Set<Edge> visited = new HashSet<>();
        for (Edge edge : generator.getEdges()) {
            if (visited.contains(edge)) {
                continue;
            }
            double weight = 0;
            for (Edge e : graph.getAllEdges(graph.getEdgeSource(edge), graph.getEdgeTarget(edge))) {
                weight += values[indices.get(e)];
                visited.add(e);
            }
            generator.setCapacity(edge, weight + ADDITION_CAPACITY);
        }
        for (Node node : generator.getNodes()) {
            generator.setVertexCapacity(node, values[indices.get(node)] - EPS);
        }
    }
}
 
开发者ID:ctlab,项目名称:sgmwcs-solver,代码行数:24,代码来源:Separator.java

示例11: dispose

import ilog.concert.IloException; //导入依赖的package包/类
/**
 * 
 */
@Override
public void dispose() {
	
	try {

		if( m_model != null ) {

			removeAllRanges();
			removeAllVars();
			m_model.clearModel();
		}

	} catch( IloException e ) {

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

示例12: removeColumn

import ilog.concert.IloException; //导入依赖的package包/类
/**
 * @param index
 * @throws CPException
 */
@Override
public void removeColumn(int index) throws CPException {
	
	IloNumVar var = getVar( index );
	
	try {
		
		m_model.delete( var );
		removeVar( index );
		ArrayUtils.remove( m_objCoeffs, index );
		
	} catch( IloException e ) {

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

示例13: removeColumns

import ilog.concert.IloException; //导入依赖的package包/类
public void removeColumns(String namePrefix) {
	
	try {
		
		for (Iterator<IloNumVar> varIter = m_vars.iterator(); varIter.hasNext();) {
			
			IloNumVar var = varIter.next();
			String name = var.getName();
			
			if (name != null && name.startsWith( namePrefix )) {

				m_model.delete( var );
				m_nameVarMap.remove( var.getName() );
				varIter.remove();
			}
		}
	} catch( IloException e ) {
		
		m_logger.fatal( e );
		throw new RuntimeException( e );
	}
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:23,代码来源:CPLEXLPSolverImpl.java

示例14: addColumn

import ilog.concert.IloException; //导入依赖的package包/类
/**
 * Function which adds a new column to the cplex problem
 */
@Override
public void addColumn(CuttingPattern column) {
	try {
		//Register column with objective
		IloColumn iloColumn= cplex.column(obj,1);
	
		//Register column with demand constraint
		for(int i=0; i< dataModel.nrFinals; i++)
			iloColumn=iloColumn.and(cplex.column(satisfyDemandConstr[i], column.yieldVector[i]));
		
		//Create the variable and store it
		IloNumVar var= cplex.numVar(iloColumn, 0, Double.MAX_VALUE, "z_"+","+masterData.getNrColumns());
		cplex.add(var);
		masterData.addColumn(column, var);
	} catch (IloException e) {
		e.printStackTrace();
	}
}
 
开发者ID:coin-or,项目名称:jorlib,代码行数:22,代码来源:Master.java

示例15: defineMode

import ilog.concert.IloException; //导入依赖的package包/类
/**
 * creates constraints for linear problem
 *
 * @param mode
 *            BitSet, active reaction = 0
 * @param booleanSize
 *            number of converted reactions
 */
protected void defineMode(final BitSet mode, int booleanSize) {
    BitSet t_mode = (BitSet) mode.clone();
    t_mode.flip(0, booleanSize);
    try {
        m_solver.removeRows(m_drgConstrStartIndex);
        int i = -1;
        while ((i = t_mode.nextSetBit(i + 1)) > -1) {
            if (m_predefinedReactions.containsKey(i)) {
                PredefinedReaction pr = m_predefinedReactions.get(i);
                ArrayList<LpReaction> rx = pr.getReactions();
                ArrayList<Integer> dir = pr.getDirections();
                for (int j = 0; j < rx.size(); j++) {
                    m_solver.addReaction(rx.get(j), dir.get(j));
                }
            }
        }
    } catch (IloException e) {
        System.out.println(e);
    }
}
 
开发者ID:mpgerstl,项目名称:tEFMA,代码行数:29,代码来源:ThermoChecker.java


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