Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
libnest2d::opt Namespace Reference

Classes

class  Bound
 An interval of possible input values for optimization. More...
 
class  DummyOptimizer
 
class  GeneticOptimizer
 
struct  limits
 A Type trait for upper and lower limit of a numeric type. More...
 
struct  limits< T, enable_if_t< std::numeric_limits< T >::has_infinity, void > >
 
class  metaloop
 Helper class to be able to loop over a parameter pack's elements. More...
 
class  NloptOptimizer
 
class  Optimizer
 The Optimizer base class with CRTP pattern. More...
 
struct  OptimizerSubclass
 
struct  OptimizerSubclass< Method::G_GENETIC >
 
struct  OptimizerSubclass< Method::L_SIMPLEX >
 
struct  OptimizerSubclass< Method::L_SUBPLEX >
 
struct  Result
 A type to hold the complete result of the optimization. More...
 
class  SimplexOptimizer
 
struct  StopCriteria
 A type for specifying the stop criteria. More...
 
class  SubplexOptimizer
 

Typedefs

template<class... Args>
using Input = tuple< Args... >
 
template<Method m>
using TOptimizer = typename OptimizerSubclass< m >::Type
 Optimizer type based on the method provided in parameter m.
 

Enumerations

enum class  Method { L_SIMPLEX , L_SUBPLEX , G_GENETIC , G_PARTICLE_SWARM }
 Specific optimization methods for which a default optimizer implementation can be instantiated. More...
 
enum  ResultCodes {
  FAILURE = -1 , INVALID_ARGS = -2 , OUT_OF_MEMORY = -3 , ROUNDOFF_LIMITED = -4 ,
  FORCED_STOP = -5 , SUCCESS = 1 , STOPVAL_REACHED = 2 , FTOL_REACHED = 3 ,
  XTOL_REACHED = 4 , MAXEVAL_REACHED = 5 , MAXTIME_REACHED = 6
}
 Info about result of an optimization. These codes are exactly the same as the nlopt codes for convinience. More...
 

Functions

template<class T >
Bound< T > bound (const T &min, const T &max)
 
template<class... Args>
tuple< Args... > initvals (Args...args)
 
template<Method m>
TOptimizer< m > GlobalOptimizer (Method, const StopCriteria &scr={})
 Global optimizer with an explicitly specified local method.
 
template<>
TOptimizer< Method::G_GENETICGlobalOptimizer< Method::G_GENETIC > (Method localm, const StopCriteria &scr)
 
nlopt::algorithm method2nloptAlg (Method m)
 

Class Documentation

◆ libnest2d::opt::OptimizerSubclass

struct libnest2d::opt::OptimizerSubclass
template<Method m>
struct libnest2d::opt::OptimizerSubclass< m >
Class Members
typedef DummyOptimizer<> Type

◆ libnest2d::opt::OptimizerSubclass< Method::G_GENETIC >

struct libnest2d::opt::OptimizerSubclass< Method::G_GENETIC >
Class Members
typedef GeneticOptimizer Type

◆ libnest2d::opt::OptimizerSubclass< Method::L_SIMPLEX >

struct libnest2d::opt::OptimizerSubclass< Method::L_SIMPLEX >
Class Members
typedef SimplexOptimizer Type

◆ libnest2d::opt::OptimizerSubclass< Method::L_SUBPLEX >

struct libnest2d::opt::OptimizerSubclass< Method::L_SUBPLEX >
Class Members
typedef SubplexOptimizer Type

◆ libnest2d::opt::Result

struct libnest2d::opt::Result
template<class... Args>
struct libnest2d::opt::Result< Args >

A type to hold the complete result of the optimization.

+ Collaboration diagram for libnest2d::opt::Result< Args >:
Class Members
tuple< Args... > optimum
ResultCodes resultcode
double score

◆ libnest2d::opt::StopCriteria

struct libnest2d::opt::StopCriteria

A type for specifying the stop criteria.

Class Members
double absolute_score_difference = std::nan("") If the absolute value difference between two scores.
unsigned max_iterations = 0 The max allowed number of iterations.
double relative_score_difference = std::nan("") If the relative value difference between two scores.
function< bool()> stop_condition = [] { return false; } A predicate that if evaluates to true, the optimization should terminate and the best result found prior to termination should be returned.
double stop_score = std::nan("") Stop if this value or better is found.

Typedef Documentation

◆ Input

template<class... Args>
using libnest2d::opt::Input = typedef tuple<Args...>

This is the type of an input tuple for the object function. It holds the values and their type in each dimension.

◆ TOptimizer

template<Method m>
using libnest2d::opt::TOptimizer = typedef typename OptimizerSubclass<m>::Type

Optimizer type based on the method provided in parameter m.

Enumeration Type Documentation

◆ Method

enum class libnest2d::opt::Method
strong

Specific optimization methods for which a default optimizer implementation can be instantiated.

Enumerator
L_SIMPLEX 
L_SUBPLEX 
G_GENETIC 
G_PARTICLE_SWARM 

◆ ResultCodes

Info about result of an optimization. These codes are exactly the same as the nlopt codes for convinience.

Enumerator
FAILURE 
INVALID_ARGS 
OUT_OF_MEMORY 
ROUNDOFF_LIMITED 
FORCED_STOP 
SUCCESS 
STOPVAL_REACHED 
FTOL_REACHED 
XTOL_REACHED 
MAXEVAL_REACHED 
MAXTIME_REACHED 
72 {
73 FAILURE = -1, /* generic failure code */
74 INVALID_ARGS = -2,
75 OUT_OF_MEMORY = -3,
77 FORCED_STOP = -5,
78 SUCCESS = 1, /* generic success code */
80 FTOL_REACHED = 3,
81 XTOL_REACHED = 4,
84};
@ STOPVAL_REACHED
Definition optimizer.hpp:79
@ MAXEVAL_REACHED
Definition optimizer.hpp:82
@ MAXTIME_REACHED
Definition optimizer.hpp:83
@ INVALID_ARGS
Definition optimizer.hpp:74
@ XTOL_REACHED
Definition optimizer.hpp:81
@ FTOL_REACHED
Definition optimizer.hpp:80
@ OUT_OF_MEMORY
Definition optimizer.hpp:75
@ FORCED_STOP
Definition optimizer.hpp:77
@ SUCCESS
Definition optimizer.hpp:78
@ ROUNDOFF_LIMITED
Definition optimizer.hpp:76
@ FAILURE
Definition optimizer.hpp:73

Function Documentation

◆ bound()

template<class T >
Bound< T > libnest2d::opt::bound ( const T &  min,
const T &  max 
)
inline

Helper function to make a Bound object with its type deduced automatically.

45{ return Bound<T>(min, max); }
An interval of possible input values for optimization.
Definition optimizer.hpp:31

Referenced by libnest2d::placers::minimizeCircle().

+ Here is the caller graph for this function:

◆ GlobalOptimizer()

template<Method m>
TOptimizer< m > libnest2d::opt::GlobalOptimizer ( Method  ,
const StopCriteria scr = {} 
)
inline

Global optimizer with an explicitly specified local method.

246 {})
247{ // Need to be specialized in order to do anything useful.
248 return TOptimizer<m>(scr);
249}

◆ GlobalOptimizer< Method::G_GENETIC >()

27{
28 return GeneticOptimizer (scr).localMethod(localm);
29}
Definition genetic.hpp:8
GeneticOptimizer & localMethod(Method m)
Definition genetic.hpp:13

◆ initvals()

template<class... Args>
tuple< Args... > libnest2d::opt::initvals ( Args...  args)
inline
54{ return make_tuple(args...); }

References initvals().

Referenced by libnest2d::findBestRotation(), initvals(), libnest2d::placers::minimizeCircle(), libnest2d::opt::NloptOptimizer::optimize(), libnest2d::opt::Optimizer< Subclass >::optimize_max(), libnest2d::opt::Optimizer< Subclass >::optimize_max(), libnest2d::opt::Optimizer< Subclass >::optimize_min(), and libnest2d::opt::Optimizer< Subclass >::optimize_min().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ method2nloptAlg()

nlopt::algorithm libnest2d::opt::method2nloptAlg ( Method  m)
inline
22 {
23
24 switch(m) {
25 case Method::L_SIMPLEX: return nlopt::LN_NELDERMEAD;
26 case Method::L_SUBPLEX: return nlopt::LN_SBPLX;
27 case Method::G_GENETIC: return nlopt::GN_ESCH;
28 default: assert(false); throw(m);
29 }
30}

References G_GENETIC, L_SIMPLEX, and L_SUBPLEX.

Referenced by libnest2d::opt::NloptOptimizer::optimize().

+ Here is the caller graph for this function: