本文整理汇总了Java中ilog.concert.IloLinearNumExpr.add方法的典型用法代码示例。如果您正苦于以下问题:Java IloLinearNumExpr.add方法的具体用法?Java IloLinearNumExpr.add怎么用?Java IloLinearNumExpr.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilog.concert.IloLinearNumExpr
的用法示例。
在下文中一共展示了IloLinearNumExpr.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createObjective
import ilog.concert.IloLinearNumExpr; //导入方法依赖的package包/类
public IloLinearNumExpr createObjective() throws IloException {
double cycleBonus = kepInstance.getCycleBonus();
IloLinearNumExpr obj = this.edgeVariables.doubleSum(edgeVariables,
kepInstance.getEdgeWeights());
// int negativeCount = 0;gm
// int nonNeg = 0;
// for (E edge : this.getEdgeVariables()) {
// if (kepInstance.getEdgeWeights().apply(edge).doubleValue() < 0) {
// negativeCount++;
// } else {
// nonNeg++;
// }
// }
// System.out.println("negative count: " + negativeCount
// + ", positive count: " + nonNeg);
Function<EdgeCycle<E>, Double> cycleWeights = kepInstance.makeCycleWeight(
kepInstance.getEdgeWeights(), 1 + cycleBonus);
obj.add(this.cycleVariables.doubleSum(cycleVariables, cycleWeights));
return obj;
}
示例2: addPrimalIncentiveConstraints
import ilog.concert.IloLinearNumExpr; //导入方法依赖的package包/类
/**
* Outer method that loops over all informationSetIds and action pairs for the limited look-ahead player.
* @throws IloException
*/
private void addPrimalIncentiveConstraints() throws IloException {
for (int informationSetId = game.getSmallestInformationSetId(playerNotToSolveFor); informationSetId < (numDualInformationSets + game.getSmallestInformationSetId(playerNotToSolveFor)); informationSetId++) {
// We need to access the set of actions available at the information set. To do this, we loop over node.actions on the (arbitrarily picked) first node in the information set.
int idOfFirstNodeInSet = game.getInformationSet(playerNotToSolveFor, informationSetId).get(0);
Node firstNodeInSet = game.getNodeById(idOfFirstNodeInSet);
// Dynamic programming table for expressions representing dominated actions
HashMap<Action, IloLinearNumExpr> dominatedActionExpressionTable = new HashMap<Action, IloLinearNumExpr>();
for (Action incentivizedAction : firstNodeInSet.getActions()) {
// get expr representing value of chosen action
IloLinearNumExpr incentiveExpr = getIncentivizedActionExpression(informationSetId, incentivizedAction);
IloLinearNumExpr incentiveConstraintLHS = cplex.linearNumExpr();
incentiveConstraintLHS.add(incentiveExpr);
int incentiveSequenceId = getSequenceIdForPlayerNotToSolveFor(informationSetId, incentivizedAction.getName());
// ensure that expression is only active if the sequence is chosen
//incentiveConstraintLHS.addTerm(maxEvaluationValueForSequence[incentiveSequenceId]+this.epsilon, sequenceDeactivationVars[incentiveSequenceId]);
for (Action dominatedAction : firstNodeInSet.getActions()) {
if (!incentivizedAction.equals(dominatedAction)) {
// get expr representing value of dominated action
IloLinearNumExpr dominatedExpr = getDominatedActionExpression(informationSetId, dominatedAction, dominatedActionExpressionTable);
IloLinearNumExpr incentiveConstraintRHS = cplex.linearNumExpr();
incentiveConstraintRHS.add(dominatedExpr);
int dominatedSequenceId = getSequenceIdForPlayerNotToSolveFor(informationSetId, dominatedAction.getName());
// ensure that expression is only active is the sequence is deactivated
incentiveConstraintRHS.addTerm(maxEvaluationValueForSequence[dominatedSequenceId]+this.epsilon, sequenceDeactivationVars[dominatedSequenceId]);
incentiveConstraintRHS.addTerm(-maxEvaluationValueForSequence[dominatedSequenceId], sequenceDeactivationVars[incentiveSequenceId]);
// TODO: something needs to be flipped here. Perhaps it needs to be LB of other side
incentiveConstraintRHS.setConstant(-maxEvaluationValueForSequence[dominatedSequenceId]);
cplex.addGe(incentiveConstraintLHS, incentiveConstraintRHS, "PrimalIncentive("+informationSetId+";"+incentivizedAction.getName()+";"+dominatedAction.getName()+")");
// add constraint requiring equality if both sequences are chosen to be incentivized, here we add one side of the two weak inequalities enforcing equality, since the other direction is also iterated over
IloLinearNumExpr equalityRHS = cplex.linearNumExpr();
equalityRHS.add(dominatedExpr);
equalityRHS.addTerm(-maxEvaluationValueForSequence[dominatedSequenceId], sequenceDeactivationVars[dominatedSequenceId]);
equalityRHS.addTerm(-maxEvaluationValueForSequence[dominatedSequenceId], sequenceDeactivationVars[incentiveSequenceId]);
cplex.addGe(incentiveExpr, equalityRHS, "quality("+informationSetId+";"+incentivizedAction.getName()+";"+dominatedAction.getName()+")");
}
}
}
}
}
示例3: addPrimalIncentiveConstraints
import ilog.concert.IloLinearNumExpr; //导入方法依赖的package包/类
/**
* Outer method that loops over all informationSetIds and action pairs for the limited look-ahead player.
* @throws IloException
*/
private void addPrimalIncentiveConstraints() throws IloException {
for (int informationSetId = game.getSmallestInformationSetId(playerNotToSolveFor); informationSetId < (numDualInformationSets + game.getSmallestInformationSetId(playerNotToSolveFor)); informationSetId++) {
// We need to access the set of actions available at the information set. To do this, we loop over node.actions on the (arbitrarily picked) first node in the information set.
int idOfFirstNodeInSet = game.getInformationSet(playerNotToSolveFor, informationSetId).get(0);
Node firstNodeInSet = game.getNodeById(idOfFirstNodeInSet);
// Dynamic programming table for expressions representing dominated actions
HashMap<Action, IloLinearNumExpr> dominatedActionExpressionTable = new HashMap<Action, IloLinearNumExpr>();
for (Action incentivizedAction : firstNodeInSet.getActions()) {
// get expr representing value of chosen action
IloLinearNumExpr incentiveExpr = getIncentivizedActionExpression(informationSetId, incentivizedAction);
IloLinearNumExpr incentiveConstraintLHS = cplex.linearNumExpr();
incentiveConstraintLHS.add(incentiveExpr);
int incentiveSequenceId = getSequenceIdForPlayerNotToSolveFor(informationSetId, incentivizedAction.getName());
// ensure that expression is only active if the sequence is chosen
//incentiveConstraintLHS.addTerm(maxEvaluationValueForSequence[incentiveSequenceId]+this.epsilon, sequenceDeactivationVars[incentiveSequenceId]);
for (Action dominatedAction : firstNodeInSet.getActions()) {
if (!incentivizedAction.equals(dominatedAction)) {
// get expr representing value of dominated action
IloLinearNumExpr dominatedExpr = getDominatedActionExpression(informationSetId, dominatedAction, dominatedActionExpressionTable);
IloLinearNumExpr incentiveConstraintRHS = cplex.linearNumExpr();
incentiveConstraintRHS.add(dominatedExpr);
int dominatedSequenceId = getSequenceIdForPlayerNotToSolveFor(informationSetId, dominatedAction.getName());
// ensure that expression is only active is the sequence is deactivated
incentiveConstraintRHS.addTerm(maxEvaluationValueForSequence[dominatedSequenceId]+this.epsilon, sequenceDeactivationVars[dominatedSequenceId]);
incentiveConstraintRHS.addTerm(-maxEvaluationValueForSequence[dominatedSequenceId], sequenceDeactivationVars[incentiveSequenceId]);
// TODO: something needs to be flipped here. Perhaps it needs to be LB of other side
incentiveConstraintRHS.setConstant(-maxEvaluationValueForSequence[dominatedSequenceId]);
cplex.addGe(incentiveConstraintLHS, incentiveConstraintRHS, "PrimalIncentive("+informationSetId+";"+incentivizedAction.getName()+";"+dominatedAction.getName()+")");
// add constraint requiring equality if both sequences are chosen to be incentivized, here we add one side of the two weak inequalities enforcing equality, since the other direction is also iterated over
IloLinearNumExpr equalityRHS = cplex.linearNumExpr();
equalityRHS.add(dominatedExpr);
equalityRHS.addTerm(-maxEvaluationValueForSequence[dominatedSequenceId], sequenceDeactivationVars[dominatedSequenceId]);
equalityRHS.addTerm(-maxEvaluationValueForSequence[dominatedSequenceId], sequenceDeactivationVars[incentiveSequenceId]);
cplex.addGe(incentiveExpr, equalityRHS, "quality("+informationSetId+";"+incentivizedAction.getName()+";"+dominatedAction.getName()+")");
}
}
}
}
}
示例4: addFlowInDoubleScaled
import ilog.concert.IloLinearNumExpr; //导入方法依赖的package包/类
@Override
public void addFlowInDoubleScaled(V vertex, IloLinearNumExpr expr, double d)
throws IloException {
expr.add(edgeVariables.doubleSum(graph.getInEdges(vertex), CplexUtil.makeConstantDoubleFunction(d)));
}
示例5: addFlowOutDoubleScaled
import ilog.concert.IloLinearNumExpr; //导入方法依赖的package包/类
@Override
public void addFlowOutDoubleScaled(V vertex,IloLinearNumExpr expr, double d)
throws IloException {
expr.add(edgeVariables.doubleSum(graph.getOutEdges(vertex), CplexUtil.makeConstantDoubleFunction(d)));
}