fix doc for assumptions new API

This commit is contained in:
Laurent Perron
2021-02-05 17:18:58 +01:00
parent aa78bde881
commit ce52397ccf
3 changed files with 9 additions and 6 deletions

View File

@@ -971,19 +971,19 @@ public final class CpModel {
modelBuilder.clearSolutionHint();
}
/** Adds variable as assumption */
/** Adds a literal to the model as assumption */
public void addAssumption(Literal lit) {
modelBuilder.addAssumptions(lit.getIndex());
}
/** Adds multiple variables to the assumptions */
/** Adds multiple literals to the model as assumptions */
public void addAssumptions(Literal[] literals) {
for (Literal lit : literals) {
addAssumption(lit);
}
}
/** Remove all solution hints */
/** Remove all assumptions from the model */
public void clearAssumptions() {
modelBuilder.clearAssumptions();
}

View File

@@ -862,13 +862,13 @@ class CpModelBuilder {
/// Remove all hints.
void ClearHints();
/// Adds a variable to the assumptions.
/// Adds a literal to the model as assumptions.
void AddAssumption(BoolVar lit);
/// Adds multiple variables to the assumptions.
/// Adds multiple literals to the model as assumptions.
void AddAssumptions(absl::Span<const BoolVar> literals);
/// Remove all assumptions.
/// Remove all assumptions from the model.
void ClearAssumptions();
// TODO(user) : add MapDomain?

View File

@@ -1547,13 +1547,16 @@ class CpModel(object):
self.__model.ClearField("solution_hint")
def AddAssumption(self, lit):
"""Add the literal 'lit' to the model as assumptions."""
self.__model.assumptions.append(self.GetOrMakeBooleanIndex(lit))
def AddAssumptions(self, literals):
"""Add the literals to the model as assumptions."""
for lit in literals:
self.AddAssumption(lit)
def ClearAssumptions(self):
"""Remove all assumptions from the model."""
self.__model.ClearField("assumptions")