public IntervalVar NewOptionalIntervalVar <S, D, E>(S start, D duration, E end, ILiteral is_present, string name) { int i = is_present.GetIndex(); return(new IntervalVar(model_, GetOrCreateIndex(start), GetOrCreateIndex(duration), GetOrCreateIndex(end), i, name)); }
public Constraint AddImplication(ILiteral a, ILiteral b) { Constraint ct = new Constraint(model_); BoolArgumentProto or = new BoolArgumentProto(); or.Literals.Add(a.Not().GetIndex()); or.Literals.Add(b.GetIndex()); ct.Proto.BoolOr = or; return ct; }
/** * <summary> * Add an arc to the graph of the circuit constraint. * </summary> * * <param name="tail"> the index of the tail node</param> * <param name="head"> the index of the head node</param> * <param name="literal"> it will be set to true if the arc is selected</param> */ public CircuitConstraint AddArc(int tail, int head, ILiteral literal) { CircuitConstraintProto circuit = Proto.Circuit; circuit.Tails.Add(tail); circuit.Heads.Add(head); circuit.Literals.Add(literal.GetIndex()); return(this); }
/** * <summary> * Adds an optional event. * </summary> * * <remarks> * If `is_active` is true, It will increase the used capacity by `level_change` at time `time`. * `time` must be an affine expression. * </remarks> */ public ReservoirConstraint AddOptionalEvent <T, L>(T time, L level_change, ILiteral literal) { ReservoirConstraintProto res = Proto.Reservoir; res.TimeExprs.Add(cp_model_.GetLinearExpressionProto(cp_model_.GetLinearExpr(time))); res.LevelChanges.Add(Convert.ToInt64(level_change)); res.ActiveLiterals.Add(literal.GetIndex()); return(this); }
/** * <summary> * Add an arc to the graph of the multiple circuit constraint. * </summary> * * <param name="tail"> the index of the tail node</param> * <param name="head"> the index of the head node</param> * <param name="literal"> it will be set to true if the arc is selected</param> */ public MultipleCircuitConstraint AddArc(int tail, int head, ILiteral literal) { RoutesConstraintProto routes = Proto.Routes; routes.Tails.Add(tail); routes.Heads.Add(head); routes.Literals.Add(literal.GetIndex()); return(this); }
public IntervalVar NewOptionalIntervalVar<S, D, E>( S start, D duration, E end, ILiteral is_present, string name) { int i = is_present.GetIndex(); return new IntervalVar(model_, GetOrCreateOptionalIndex(start, i), // Size is currently not optional. GetOrCreateIndex(duration), GetOrCreateOptionalIndex(end, i), i, name); }
public IntervalVar NewOptionalFixedSizeIntervalVar <S>(S start, long duration, ILiteral is_present, string name) { LinearExpr startExpr = GetLinearExpr(start); LinearExpr durationExpr = GetLinearExpr(duration); LinearExpr endExpr = LinearExpr.Sum(new LinearExpr[] { startExpr, durationExpr }); LinearExpressionProto startProto = GetLinearExpressionProto(startExpr); LinearExpressionProto durationProto = GetLinearExpressionProto(durationExpr); LinearExpressionProto endProto = GetLinearExpressionProto(endExpr); return(new IntervalVar(model_, startProto, durationProto, endProto, is_present.GetIndex(), name)); }
public Boolean BooleanValue(ILiteral literal) { if (literal is IntVar || literal is NotBooleanVariable) { int index = literal.GetIndex(); return(SolutionBooleanValue(index)); } else { throw new ArgumentException("Cannot evaluate '" + literal.ToString() + "' as a boolean literal"); } }
public IntervalVar NewOptionalIntervalVar <S, D, E>(S start, D duration, E end, ILiteral is_present, string name) { LinearExpr startExpr = GetLinearExpr(start); LinearExpr durationExpr = GetLinearExpr(duration); LinearExpr endExpr = GetLinearExpr(end); Add(startExpr + durationExpr == endExpr).OnlyEnforceIf(is_present); LinearExpressionProto startProto = GetLinearExpressionProto(startExpr); LinearExpressionProto durationProto = GetLinearExpressionProto(durationExpr); LinearExpressionProto endProto = GetLinearExpressionProto(endExpr); return(new IntervalVar(model_, startProto, durationProto, endProto, is_present.GetIndex(), name)); }
public Boolean BooleanValue(ILiteral literal) { if (literal is IntVar || literal is NotBooleanVariable) { int index = literal.GetIndex(); if (index >= 0) { return(response_.Solution[index] != 0); } else { return(response_.Solution[-index - 1] == 0); } } else { throw new ArgumentException("Cannot evaluate '" + literal.ToString() + "' as a boolean literal"); } }
public void AddAssumption(ILiteral lit) { model_.Assumptions.Add(lit.GetIndex()); }
public void OnlyEnforceIf(ILiteral lit) { constraint_.EnforcementLiteral.Add(lit.GetIndex()); }
public IntVar NewOptionalConstant( long value, ILiteral is_present, string name) { long[] bounds = { value, value }; return(new IntVar(model_, bounds, is_present.GetIndex(), name)); }
public IntVar NewOptionalEnumeratedIntVar( IEnumerable <long> bounds, ILiteral is_present, string name) { return(new IntVar(model_, bounds, is_present.GetIndex(), name)); }
public IntVar NewOptionalIntVar( long lb, long ub, ILiteral is_present, string name) { long[] bounds = { lb, ub }; return(new IntVar(model_, bounds, is_present.GetIndex(), name)); }