[CP-SAT] c# fix

This commit is contained in:
Laurent Perron
2024-08-16 07:36:45 -07:00
parent 1b9e132782
commit 43e28c4669

View File

@@ -501,6 +501,11 @@ public class CpModel
return ct;
}
/**
* <summary>
* Adds <c>var == i + offset ⇔ bool_vars[i] == true for all i</c>.
* </summary>
*/
public void AddMapDomain(IntVar var, IEnumerable<IntVar> bool_vars, long offset = 0)
{
int i = 0;
@@ -523,11 +528,11 @@ public class CpModel
model_.Constraints.Add(ct1);
LinearConstraintProto lin2 = new LinearConstraintProto();
lin1.Vars.Capacity = 1;
lin2.Vars.Capacity = 1;
lin2.Vars.Add(var_index);
lin1.Coeffs.Capacity = 1;
lin2.Coeffs.Capacity = 1;
lin2.Coeffs.Add(1L);
lin1.Domain.Capacity = 4;
lin2.Domain.Capacity = 4;
lin2.Domain.Add(Int64.MinValue);
lin2.Domain.Add(offset + i - 1);
lin2.Domain.Add(offset + i + 1);
@@ -1057,7 +1062,7 @@ public class CpModel
model_.SolutionHint.Vars.Add(Negated(index));
model_.SolutionHint.Values.Add(value ? 0 : 1);
}
}
}
/** <summary>Clears all hinting from the model.</summary>*/
public void ClearHints()