C++ Reference: class PresolveContext
This documentation is automatically generated.
Wrap the CpModelProto we are presolving with extra data structure like the in-memory domain of each variables and the constraint variable graph.Method | |
---|---|
AddImplication | Return type: Arguments: a => b. |
AddImplyInDomain | Return type: Arguments: b => x in [lb, ub]. |
AffineRelationDebugString | Return type: Arguments: |
CanBeUsedAsLiteral | Return type: Arguments: |
CanonicalizeDomainOfSizeTwo | Return type: Arguments: If not already done, adds a Boolean to represent any integer variables that take only two values. Make sure all the relevant affine and encoding relations are updated. Note that this might create a new Boolean variable. |
CanonicalizeObjective | Return type: |
ClearPrecedenceCache | Return type: Clear the precedence cache. |
ClearStats | Return type: Clears the "rules" statistics. |
ConstraintToVars | Return type: Arguments: Variable <-> constraint graph. The vector list is sorted and contains unique elements. Important: To properly handle the objective, var_to_constraints[objective] contains -1 so that if the objective appear in only one constraint, the constraint cannot be simplified. |
ConstraintVariableGraphIsUpToDate | Return type: At the beginning of the presolve, we delay the costly creation of this "graph" until we at least ran some basic presolve. This is because during a LNS neighbhorhood, many constraints will be reduced significantly by this "simple" presolve. |
ConstraintVariableUsageIsConsistent | Return type: Returns true if our current constraints <-> variables graph is ok. This is meant to be used in DEBUG mode only. |
DomainContains | Return type: Arguments: |
DomainIsEmpty | Return type: Arguments: Helpers to query the current domain of a variable. |
DomainOf | Return type: Arguments: |
DomainOfVarIsIncludedIn | Return type: Arguments: This function takes a positive variable reference. |
ExploitFixedDomain | Return type: Arguments: Regroups fixed variables with the same value. TODO(user): Also regroup cte and -cte? |
GetAbsRelation | Return type: Arguments: |
GetAffineRelation | Return type: Arguments: This makes sure that the affine relation only uses one of the representative from the var_equiv_relations. |
GetLiteralRepresentative | Return type: Arguments: Returns the representative of a literal. |
GetOrCreateConstantVar | Return type: Arguments: |
GetOrCreateReifiedPrecedenceLiteral | Return type: Arguments: The following helper adds the following constraint: result <=> (time_i <= time_j && active_i is true && active_j is true) and returns the (cached) literal result. Note that this cache should just be used temporarily and then cleared with ClearPrecedenceCache() because there is no mechanism to update the cached literals when literal equivalence are detected. |
GetOrCreateVarValueEncoding | Return type: Arguments: Gets the associated literal if it is already created. Otherwise create it, add the corresponding constraints and returns it. Important: This does not update the constraint<->variable graph, so ConstraintVariableGraphIsUpToDate() will be false until UpdateNewConstraintsVariableUsage() is called. |
GetVariableRepresentative | Return type: Arguments: Returns another reference with exactly the same value. |
HasVarValueEncoding | Return type: Arguments: Returns true if a literal attached to ref == var exists. It assigns the corresponding to `literal` if non null. |
InitializeNewDomains | Return type: Creates the internal structure for any new variables in working_model. |
InsertVarValueEncoding | Return type: Arguments: Inserts the given literal to encode ref == value. If an encoding already exists, it adds the two implications between the previous encoding and the new encoding. Important: This does not update the constraint<->variable graph, so ConstraintVariableGraphIsUpToDate() will be false until UpdateNewConstraintsVariableUsage() is called. |
IntersectDomainWith | Return type: Arguments: Returns false if the new domain is empty. Sets 'domain_modified' (if provided) to true iff the domain is modified otherwise does not change it. |
IntervalUsage | Return type: Arguments: |
IsFixed | Return type: Arguments: |
LiteralIsFalse | Return type: Arguments: |
LiteralIsTrue | Return type: Arguments: |
logger | Return type: |
MarkVariableAsRemoved | Return type: Arguments: Functions to make sure that once we remove a variable, we no longer reuse it. |
MaxOf | Return type: Arguments: |
MaxOf | Return type: Arguments: |
MinOf | Return type: Arguments: |
MinOf | Return type: Arguments: Helpers to query the current domain of a linear expression. This doesn't check for integer overflow, but our linear expression should be such that this cannot happen (tested at validation). |
ModelIsUnsat | Return type: |
NewBoolVar | Return type: |
NewIntVar | Return type: Arguments: Helpers to adds new variables to the presolved model. |
NotifyThatModelIsUnsat | Return type: Arguments: This function always return false. It is just a way to make a little bit more sure that we abort right away when infeasibility is detected. |
NumAffineRelations | Return type: Used for statistics. |
NumEquivRelations | Return type: |
ObjectiveDomain | Return type: Objective getters. |
ObjectiveDomainIsConstraining | Return type: |
ObjectiveMap | Return type: |
params | Return type: |
PresolveContext | Return type: Arguments: |
PropagateAffineRelation | Return type: Arguments: Makes sure the domain of ref and of its representative are in sync. Returns false on unsat. |
random | Return type: |
ReadObjectiveFromProto | Return type: Objective handling functions. We load it at the beginning so that during presolve we can work on the more efficient hash_map representation. Note that ReadObjectiveFromProto() makes sure that var_to_constraints of all the variable that appear in the objective contains -1. This is later enforced by all the functions modifying the objective. Note(user): Because we process affine relation only on CanonicalizeObjective(), it is possible that when processing a canonicalized linear constraint, we don't detect that a variable in affine relation is in the objective. For now this is fine, because when this is the case, we also have an affine linear constraint, so we can't really do anything with that variable since it appear in at least two constraints. |
RefDebugString | Return type: Arguments: To facilitate debugging. |
RegisterVariablesUsedInAssumptions | Return type: Make sure we never delete an "assumption" literal by using a special constraint for that. |
RemoveAllVariablesFromAffineRelationConstraint | Return type: |
RemoveVariableFromAffineRelation | Return type: Arguments: Advanced usage. This should be called when a variable can be removed from the problem, so we don't count it as part of an affine relation anymore. |
SetLiteralToFalse | Return type: Arguments: Returns false if the 'lit' doesn't have the desired value in the domain. |
SetLiteralToTrue | Return type: Arguments: |
StoreAbsRelation | Return type: Arguments: Stores/Get the relation target_ref = abs(ref); The first function returns false if it already exist and the second false if it is not present. |
StoreAffineRelation | Return type: Arguments: Adds the relation (ref_x = coeff * ref_y + offset) to the repository. Once the relation is added, it doesn't need to be enforced by a constraint in the model proto, since we will propagate such relation directly and add them to the proto at the end of the presolve. Returns true if the relation was added. In some rare case, like if x = 3*z and y = 5*t are already added, we currently cannot add x = 2 * y and we will return false in these case. So when this returns false, the relation needs to be enforced by a separate constraint. If the relation was added, both variables will be marked to appear in the special kAffineRelationConstraint. This will allow to identify when a variable is no longer needed (only appear there and is not a representative). |
StoreBooleanEqualityRelation | Return type: Arguments: Adds the fact that ref_a == ref_b using StoreAffineRelation() above. This should never fail, so the relation will always be added. |
StoreLiteralImpliesVarEqValue | Return type: Arguments: Stores the fact that literal implies var == value. It returns true if that information is new. |
StoreLiteralImpliesVarNEqValue | Return type: Arguments: Stores the fact that literal implies var != value. It returns true if that information is new. |
SubstituteVariableInObjective | Return type: Arguments: Given a variable defined by the given inequality that also appear in the objective, remove it from the objective by transferring its cost to other variables in the equality. If new_vars_in_objective is not nullptr, it will be filled with "new" variables that where not in the objective before and are after substitution. Returns false, if the substitution cannot be done. This is the case if the model become UNSAT or if doing it will result in an objective that do not satisfy our overflow preconditions. Note that this can only happen if the substitued variable is not implied free (i.e. if its domain is smaller than the implied domain from the equality). |
time_limit | Return type: |
UpdateConstraintVariableUsage | Return type: Arguments: Updates the constraints <-> variables graph. This needs to be called each time a constraint is modified. |
UpdateNewConstraintsVariableUsage | Return type: Calls UpdateConstraintVariableUsage() on all newly created constraints. |
UpdateRuleStats | Return type: Arguments: Stores a description of a rule that was just applied to have a summary of what the presolve did at the end. |
VariableIsNotUsedAnymore | Return type: Arguments: Returns true if this ref no longer appears in the model. |
VariableIsOnlyUsedInEncoding | Return type: Arguments: Returns true if an integer variable is only appearing in the rhs of constraints of the form lit => var in domain. When this is the case, then we can usually remove this variable and replace these constraints with the proper constraints on the enforcement literals. |
VariableIsUniqueAndRemovable | Return type: Arguments: Returns true if this ref only appear in one constraint. |
VariableWasRemoved | Return type: Arguments: |
VariableWithCostIsUniqueAndRemovable | Return type: Arguments: Same as VariableIsUniqueAndRemovable() except that in this case the variable also appear in the objective in addition to a single constraint. |
VarToConstraints | Return type: Arguments: |
WriteObjectiveToProto | Return type: |