![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
The violation of an int_mod constraint is defined as follow:
if target and expr0 have the same sign: min( abs(value(target) - (value(expr0) % value(expr1))), abs(value(target)) + abs((value(expr0) % value(expr1)) - value(expr1)), abs(value(expr0) % value(expr1)) + abs(value(target) - value(expr1)), )
if target and expr0 have different sign: abs(target) + abs(expr0)
Definition at line 525 of file constraint_violation.h.
#include <constraint_violation.h>
Public Member Functions | |
| CompiledIntModConstraint (const ConstraintProto &ct_proto) | |
| --— CompiledIntModConstraint --— | |
| ~CompiledIntModConstraint () override=default | |
| int64_t | ComputeViolation (absl::Span< const int64_t > solution) override |
| Public Member Functions inherited from operations_research::sat::CompiledConstraintWithProto | |
| CompiledConstraintWithProto (const ConstraintProto &ct_proto) | |
| --— CompiledConstraintWithProto --— | |
| ~CompiledConstraintWithProto () override=default | |
| const ConstraintProto & | ct_proto () const |
| std::vector< int > | UsedVariables (const CpModelProto &model_proto) const final |
| This just returns the variables used by the stored ct_proto_. | |
| Public Member Functions inherited from operations_research::sat::CompiledConstraint | |
| CompiledConstraint ()=default | |
| virtual | ~CompiledConstraint ()=default |
| void | InitializeViolation (absl::Span< const int64_t > solution) |
| Recomputes the violation of the constraint from scratch. | |
| virtual void | PerformMove (int var, int64_t old_value, absl::Span< const int64_t > solution_with_new_value) |
| Updates the violation with the new value. | |
| virtual int64_t | ViolationDelta (int var, int64_t old_value, absl::Span< const int64_t > solution_with_new_value) |
| Returns the delta if var changes from old_value to solution[var]. | |
| int64_t | violation () const |
| The cached violation of this constraint. | |
Additional Inherited Members | |
| Protected Attributes inherited from operations_research::sat::CompiledConstraint | |
| int64_t | violation_ |
|
explicit |
--— CompiledIntModConstraint --—
Definition at line 1033 of file constraint_violation.cc.
|
overridedefault |
|
overridevirtual |
Computes the violation of a constraint.
This is called by InitializeViolation() and also the default implementation of ViolationDelta().
Easy case.
Different signs. We use the sum of the absolute value to have a better gradient. We could also use the min of target_move and the expr_move.
Implements operations_research::sat::CompiledConstraint.
Definition at line 1037 of file constraint_violation.cc.