C++ Reference: class NeighborhoodGenerator

Note: This documentation is automatically generated.

Base class for a CpModelProto neighborhood generator.
Method
AddSolveData

Return type: void

Arguments: SolveData data

deterministic_limit

Return type: double

The current time limit that the sub-solve should use on this generator.

deterministic_time

Return type: double

The sum of the deterministic time spent in this generator.

difficulty

Return type: double

The current difficulty of this generator

Generate

Return type: virtual Neighborhood

Arguments: const CpSolverResponse& initial_solution, double difficulty, absl::BitGenRef random

Generates a "local" subproblem for the given seed. The difficulty will be in [0, 1] and is related to the asked neighborhood size (and thus local problem difficulty). A difficulty of 0.0 means empty neighborhood and a difficulty of 1.0 means the full problem. The algorithm should try to generate a neighborhood according to this difficulty which will be dynamically adjusted depending on whether or not we can solve the subproblem in a given time limit. The given initial_solution should contain a feasible solution to the initial CpModelProto given to this class. Any solution to the returned CPModelProto should also be valid solution to the same initial model. This function should be thread-safe.

GetUCBScore

Return type: double

Arguments: int64_t total_num_calls

Uses UCB1 algorithm to compute the score (Multi armed bandit problem). Details are at https://lilianweng.github.io/lil-log/2018/01/23/the-multi-armed-bandit-problem-and-its-solutions.html. 'total_num_calls' should be the sum of calls across all generators part of the multi armed bandit problem. If the generator is called less than 10 times then the method returns infinity as score in order to get more data about the generator performance.

IsRelaxationGenerator

Return type: virtual bool

Returns true if the neighborhood generator generates relaxation of the given problem.

name

Return type: std::string

Returns a short description of the generator.

NeighborhoodGenerator

Arguments: const std::string& name, NeighborhoodGeneratorHelper const* helper

~NeighborhoodGenerator

Return type: virtual

num_calls

Return type: int64_t

Number of times this generator was called.

num_fully_solved_calls

Return type: int64_t

Number of time the neighborhood was fully solved (OPTIMAL/INFEASIBLE).

ReadyToGenerate

Return type: virtual bool

Returns true if the neighborhood generator can generate a neighborhood.

Synchronize

Return type: void

Process all the recently added solve data and update this generator score and difficulty.