Skip to content

Commit 43e28c4

Browse files
committed
[CP-SAT] c# fix
1 parent 1b9e132 commit 43e28c4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ortools/sat/csharp/CpModel.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,11 @@ public ReservoirConstraint AddReservoirConstraint(long minLevel, long maxLevel)
501501
return ct;
502502
}
503503

504+
/**
505+
* <summary>
506+
* Adds <c>var == i + offset ⇔ bool_vars[i] == true for all i</c>.
507+
* </summary>
508+
*/
504509
public void AddMapDomain(IntVar var, IEnumerable<IntVar> bool_vars, long offset = 0)
505510
{
506511
int i = 0;
@@ -523,11 +528,11 @@ public void AddMapDomain(IntVar var, IEnumerable<IntVar> bool_vars, long offset
523528
model_.Constraints.Add(ct1);
524529

525530
LinearConstraintProto lin2 = new LinearConstraintProto();
526-
lin1.Vars.Capacity = 1;
531+
lin2.Vars.Capacity = 1;
527532
lin2.Vars.Add(var_index);
528-
lin1.Coeffs.Capacity = 1;
533+
lin2.Coeffs.Capacity = 1;
529534
lin2.Coeffs.Add(1L);
530-
lin1.Domain.Capacity = 4;
535+
lin2.Domain.Capacity = 4;
531536
lin2.Domain.Add(Int64.MinValue);
532537
lin2.Domain.Add(offset + i - 1);
533538
lin2.Domain.Add(offset + i + 1);
@@ -1057,7 +1062,7 @@ public void AddHint(ILiteral lit, bool value)
10571062
model_.SolutionHint.Vars.Add(Negated(index));
10581063
model_.SolutionHint.Values.Add(value ? 0 : 1);
10591064
}
1060-
}
1065+
}
10611066

10621067
/** <summary>Clears all hinting from the model.</summary>*/
10631068
public void ClearHints()

0 commit comments

Comments
 (0)