14package com.google.ortools.sat;
16import com.google.ortools.sat.ConstraintProto;
17import com.google.ortools.sat.CpModelProto;
18import com.google.ortools.sat.IntervalConstraintProto;
19import com.google.ortools.sat.LinearExpressionProto;
22public final class IntervalVar {
23 IntervalVar(CpModelProto.Builder builder, LinearExpressionProto.Builder startBuilder,
24 LinearExpressionProto.Builder sizeBuilder, LinearExpressionProto.Builder endBuilder,
26 this.modelBuilder = builder;
28 ConstraintProto.Builder ct = modelBuilder.addConstraintsBuilder();
30 this.intervalBuilder = ct.getIntervalBuilder();
31 this.intervalBuilder.setStart(startBuilder);
32 this.intervalBuilder.setSize(sizeBuilder);
33 this.intervalBuilder.setEnd(endBuilder);
36 IntervalVar(CpModelProto.Builder builder, LinearExpressionProto.Builder startBuilder,
37 LinearExpressionProto.Builder sizeBuilder, LinearExpressionProto.Builder endBuilder,
38 int isPresentIndex, String name) {
39 this.modelBuilder = builder;
41 ConstraintProto.Builder ct = modelBuilder.addConstraintsBuilder();
43 ct.addEnforcementLiteral(isPresentIndex);
44 this.intervalBuilder = ct.getIntervalBuilder();
45 this.intervalBuilder.setStart(startBuilder);
46 this.intervalBuilder.setSize(sizeBuilder);
47 this.intervalBuilder.setEnd(endBuilder);
57 return constraintIndex;
62 return intervalBuilder;
85 private final CpModelProto.Builder modelBuilder;
86 private final int constraintIndex;
87 private final IntervalConstraintProto.Builder intervalBuilder;