OptiPy
Loading...
Searching...
No Matches
Problem Class Referenceabstract

Abstract base class for all optimization benchmark problems. More...

#include <Problem.h>

Inheritance diagram for Problem:
AckleyOne AckleyTwo DeJongOne EggHolder Griewangk Rastrigin Rosenbrock Schwefel SineEnvelope StretchedV

Public Member Functions

 Problem (double lb, double ub, const std::string_view n)
 Constructs a Problem instance.
virtual ~Problem ()=default
 Virtual destructor for safe polymorphic cleanup.
virtual double evaluate (const std::vector< double > &x) const =0
 Evaluates the fitness of a candidate solution.
double evaluateSolution (const std::vector< double > &solution)
void getInitialSolutions (std::vector< std::vector< double > > &population)
Accessors
double getLowerBounds () const
double getUpperBounds () const
const std::string getName () const
unsigned long getSeed () const
void setSeed (unsigned long s)
void setDimensions (size_t dims)

Protected Attributes

const double lowerBound
 Lower bound of the search space.
const double upperBound
 Upper bound of the search space.
const std::string name
 Name of the benchmark function.
size_t dimensions
unsigned long seed = 0

Detailed Description

Abstract base class for all optimization benchmark problems.

Provides a common interface for evaluating fitness and retrieving search space boundaries.

Constructor & Destructor Documentation

◆ Problem()

Problem::Problem ( double lb,
double ub,
const std::string_view n )
inline

Constructs a Problem instance.

  • Parameters
    lbLower bound for the solution space.
    ubUpper bound for the solution space.
    nName of the optimization function.

Member Function Documentation

◆ evaluate()

virtual double Problem::evaluate ( const std::vector< double > & x) const
pure virtual

Evaluates the fitness of a candidate solution.

  • This is a pure virtual function that must be implemented by specific benchmark functions (e.g., Ackley, Rosenbrock).
  • Parameters
    xThe solution vector to evaluate.
    Returns
    The scalar fitness value (cost).

Implemented in AckleyOne, AckleyTwo, DeJongOne, EggHolder, Griewangk, Rastrigin, Rosenbrock, Schwefel, SineEnvelope, and StretchedV.

◆ getLowerBounds()

double Problem::getLowerBounds ( ) const
inline
Returns
The lower boundary of the search space.

◆ getName()

const std::string Problem::getName ( ) const
inline
Returns
The name of the benchmark function.

◆ getUpperBounds()

double Problem::getUpperBounds ( ) const
inline
Returns
The upper boundary of the search space.

The documentation for this class was generated from the following file:
  • src/opti_py/cpp/include/opti_py/Problem/Problem.h