@Override public void run() throws LPModelException { try { int vertexClasses = (int) model().getLPConstant(FixedConstants.CIRCUIT_CLASSES).getValue(); LPNameGenerator dynCircuitNameGenerator = model().getLPVarGroup(VarGroups.DYN_CIRCUITS).getNameGenerator(); LPConstraintGroup group = model().getLPConstraintGroup(this.getGroup().getIdentifier()); for (String s : vertices) { for (String d : vertices) { // for all distinct pair of vertices, routing can only use a link that exists : r(s,d,i,j) // <= LE (i,j) if (s.equals(d)) continue; LPExpression lhs = new LPExpression(model()); for (int n = 1; n <= vertexClasses; n++) { lhs.addTerm(model().getLPVar(dynCircuitNameGenerator.getName(n, s, d))); } LPExpression rhs = new LPExpression(model()); rhs.addTerm(model().getLPConstant(FixedConstants.DYN_CIRTUITS_MAX).getValue()); model().addConstraint(generator().getName(s, d), lhs, LPOperator.LESS_EQUAL, rhs, group); } } } catch (LPNameException e) { log.error("Variable name not found: " + e.getMessage()); throw new LPModelException("Variable name not found: " + e.getMessage()); } }
@Override public void run() throws LPModelException { try { LPNameGenerator routingNameGenerator = model().getLPVarGroup(VarGroups.ROUTING).getNameGenerator(); LPConstraintGroup group = model().getLPConstraintGroup(this.getGroup().getIdentifier()); for (String s : vertices) { for (String d : vertices) { // Take a single s, d pair and create symmetric routing rules for all i,j pairs if (s.compareTo(d) <= 0) continue; for (String i : vertices) { for (String j : vertices) { if (i.equals(j)) continue; LPExpression lhs = new LPExpression(model()); lhs.addTerm(model().getLPVar(routingNameGenerator.getName(s, d, i, j))); LPExpression rhs = new LPExpression(model()); rhs.addTerm(model().getLPVar(routingNameGenerator.getName(d, s, j, i))); model() .addConstraint( generator().getName(s, d, i, j), lhs, LPOperator.EQUAL, rhs, group); } } } } } catch (LPNameException e) { log.error("Variable name not found: " + e.getMessage()); throw new LPModelException("Variable name not found: " + e.getMessage()); } }