Responsible for creating random solutions and neighborhood samples.
More...
#include <SolutionBuilder.h>
|
| | SolutionBuilder (int dimensions, int lower, int upper, int seed) |
| | Constructs a SolutionBuilder with specific space constraints.
|
| std::vector< double > | getRand () |
| | Generates a single random solution vector within bounds.
|
| std::vector< std::vector< double > > | getNeighbors (const std::vector< double > ¢er, int numNeighbors, double maxDelta) |
| | Generates a set of neighboring solutions around a central point.
|
|
double | getDimensions () |
| | Returns the dimensionality of the solution space.
|
| std::vector< int > | getSubset (int populationSize, int subsetSize, int source) |
| | Generates a subset of unique solutions from given population.
|
|
std::vector< double > | getDifference (const std::vector< double > vec1, const std::vector< double > vec2) |
| double | checkBounds (double value) |
| | Ensures a coordinate stays within the defined [lower, upper] bounds.
|
|
double | randNum () |
|
int | randNum (int x, int y) |
|
std::vector< double > | getInitialVelocity () |
|
double | clampVelocity (double v) |
Responsible for creating random solutions and neighborhood samples.
This class encapsulates the logic for generating initial random positions within the search space and perturbing existing solutions to find neighbors. It utilizes the Mersenne Twister algorithm for high-quality random number generation.
◆ SolutionBuilder()
| SolutionBuilder::SolutionBuilder |
( |
int | dimensions, |
|
|
int | lower, |
|
|
int | upper, |
|
|
int | seed ) |
|
inline |
Constructs a SolutionBuilder with specific space constraints.
- Parameters
-
| dimensions | Number of variables in the solution vector. |
| lower | Minimum value for any given dimension. |
| upper | Maximum value for any given dimension. |
| seed | Value used to initialize the Mersenne Twister generator. |
◆ checkBounds()
| double SolutionBuilder::checkBounds |
( |
double | value | ) |
|
Ensures a coordinate stays within the defined [lower, upper] bounds.
- Parameters
-
- Returns
- The clamped value.
◆ getNeighbors()
| std::vector< std::vector< double > > SolutionBuilder::getNeighbors |
( |
const std::vector< double > & | center, |
|
|
int | numNeighbors, |
|
|
double | maxDelta ) |
Generates a set of neighboring solutions around a central point.
Used primarily by Local Search algorithms to explore the immediate vicinity of the current best candidate.
- Parameters
-
| center | The original solution vector to perturb. |
| numNeighbors | Number of neighbor vectors to generate. |
| maxDelta | The maximum step size allowed for perturbation in any dimension. |
- Returns
- A collection of neighboring solution vectors.
◆ getRand()
| std::vector< double > SolutionBuilder::getRand |
( |
| ) |
|
Generates a single random solution vector within bounds.
- Returns
- A vector of size dimensions with values in range [lower, upper].
◆ getSubset()
| std::vector< int > SolutionBuilder::getSubset |
( |
int | populationSize, |
|
|
int | subsetSize, |
|
|
int | source ) |
Generates a subset of unique solutions from given population.
- Parameters
-
| population | Size population from which subset is selected. |
| subsetSize | Number of solutions to include in returned subset. |
- Returns
- A collection of unique indices from initial population.
The documentation for this class was generated from the following files:
- src/opti_py/cpp/include/opti_py/SolutionBuilder.h
- src/opti_py/cpp/src/SolutionBuilder.cpp