C++ Reference: class NeighborhoodGeneratorHelper

Note: This documentation is automatically generated.

Contains pre-computed information about a given CpModelProto that is meant to be used to generate LNS neighborhood. This class can be shared between more than one generator in order to reduce memory usage.

Note that its implement the SubSolver interface to be able to Synchronize() the bounds of the base problem with the external world.
Method
ActiveVariables

Return type: std::vector<int>

Returns the list of "active" variables.

ActiveVariablesWhileHoldingLock

Return type: const std::vector<int>&

Arguments: ) const ABSL_SHARED_LOCKS_REQUIRED(graph_mutex_

Returns the vector of active variables. The graph_mutex_ must be locked before calling this method.

AddSolutionHinting

Return type: void

Arguments: const CpSolverResponse& initial_solution, CpModelProto* model_proto

Adds solution hinting to the neighborhood from the value of the initial solution.

DifficultyMeansFullNeighborhood

Return type: bool

Arguments: double difficulty

FixAllVariables

Return type: Neighborhood

Arguments: const CpSolverResponse& initial_solution

Returns a trivial model by fixing all active variables to the initial solution values.

FixGivenVariables

Return type: Neighborhood

Arguments: const CpSolverResponse& base_solution, const absl::flat_hash_set<int>& variables_to_fix

Returns the LNS fragment where the given variables are fixed to the value they take in the given solution.

FullNeighborhood

Return type: Neighborhood

Returns a neighborhood that correspond to the full problem.

GenerateTask

Return type: std::function<void()>

Arguments: int64_t task_id

GetActiveIntervals

Return type: std::vector<int>

Arguments: const CpSolverResponse& initial_solution

Returns the list of indices of active interval constraints according to the initial_solution and the parameter lns_focus_on_performed_intervals. If true, this method returns the list of performed intervals in the solution. If false, it returns all intervals of the model.

IsActive

Return type: bool

Arguments: int var) const ABSL_SHARED_LOCKS_REQUIRED(graph_mutex_

Indicates if the variable can be frozen. It happens if the variable is non constant, and if it is a decision variable, or if focus_on_decision_variables is false.

ModelProto

Return type: const CpModelProto&

The initial problem. Note that the domain of the variables are not updated here.

NeighborhoodGeneratorHelper

Arguments: CpModelProto const* model_proto, SatParameters const* parameters, SharedResponseManager* shared_response, SharedBoundsManager* shared_bounds = nullptr

NoNeighborhood

Return type: Neighborhood

Returns a neighborhood that will just be skipped. It usually indicate that the generator failed to generated a neighborhood.

NumActiveVariables

Return type: int

Parameters

Return type: const SatParameters&

RelaxGivenVariables

Return type: Neighborhood

Arguments: const CpSolverResponse& initial_solution, const std::vector<int>& relaxed_variables

Returns the LNS fragment which will relax all inactive variables and all variables in relaxed_variables.

RemoveMarkedConstraints

Return type: Neighborhood

Arguments: const std::vector<int>& constraints_to_remove

Returns the neighborhood where the given constraints are removed.

shared_response

Return type: const SharedResponseManager&

Synchronize

Return type: void

TaskIsAvailable

Return type: bool

SubSolver interface.

TypeToConstraints

Return type: const absl::Span<const int>

Arguments: ConstraintProto::ConstraintCase type

Returns all the constraints indices of a given type.