OP  0.1
OP is a optimization solver plugin package
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends
Namespaces | Classes | Typedefs | Enumerations | Functions
op Namespace Reference

Op namespace. More...

Namespaces

 debug
 This namespace includes several methods for debugging parallel communication patterns.
 
 mpi
 template MPI namespace
 
 utility
 Utility methods to facilitate common operations.
 

Classes

class  NLopt
 A op::optimizer implementation for NLopt. More...
 
struct  NLoptOptions
 Options specific for nlopt. They are made to look like ipopt's interface. More...
 
class  Go
 
class  Vector
 Abstracted Optimization Vector container. More...
 
class  Functional
 Abstracted Objective Functional class. More...
 
class  Optimizer
 Abstracted Optimizer implementation. More...
 
class  WaitLoop
 

Typedefs

using nlopt_index_type = std::vector< std::size_t >
 Default nlopt type.
 
using CallbackFn = std::function< void()>
 Callback function type.
 
using ActionFn = std::function< void()>
 Action type we'll use over and over again.
 

Enumerations

enum  State : int {
  OTHER, SOLUTION_FOUND = -4, UPDATE_VARIABLES = -3, OBJ_GRAD = -2,
  OBJ_EVAL = -1
}
 

Functions

template<typename T >
double NLoptFunctional (const std::vector< double > &x, std::vector< double > &grad, void *objective_and_optimizer)
 Takes in a op::Functional and computes the objective function and it's gradient as a nlopt function. More...
 
auto wrapNLoptFunc (std::function< double(unsigned, const double *, double *, void *)> func)
 wraps any nltop::function into an objective call and a gradient call More...
 
template<typename T >
 NLopt (op::Vector< std::vector< double >>, NLoptOptions &, MPI_Comm, utility::CommPattern< T >) -> NLopt< T >
 
template<class OptType , typename... Args>
std::unique_ptr< OptType > PluginOptimizer (std::string optimizer_path, Args &&...args)
 Dynamically load an Optimizer. More...
 
template<typename V , typename T >
auto ReduceObjectiveFunction (const std::function< V(T)> &local_func, MPI_Op op, MPI_Comm comm=MPI_COMM_WORLD)
 Generate an objective function that performs a global reduction. More...
 
template<typename T , typename I >
auto OwnedLocalObjectiveGradientFunction (utility::RankCommunication< T > &info, I &global_ids_to_local, T &reduced_id_list, std::function< std::vector< double >(const std::vector< double > &)> local_obj_grad_func, std::function< double(const std::vector< double > &)> local_reduce_func, MPI_Comm comm=MPI_COMM_WORLD)
 Generate an objective gradient function that takes local variables and reduces them in parallel to locally "owned" variables. More...
 
template<typename T , typename I , typename ValuesType >
ValuesType ReturnLocalUpdatedVariables (utility::RankCommunication< T > &info, I &global_ids_to_local, ValuesType &reduced_values)
 Generate update method to propagate owned local variables back to local variables in parallel. More...
 
template<typename T >
auto AdvancedRegistration (T &global_ids_on_rank, int root=0, MPI_Comm mpicomm=MPI_COMM_WORLD)
 

Detailed Description

Op namespace.

Namespace for the OP interface.

Enumeration Type Documentation

enum op::State : int

Define a simple state messaging scheme

n = constraint.size()

-4 => solution found -3 => update variables -2 => obj_grad -1 => obj_eval [0,n-1] => constraint_eval [n,2n-1] => constraint_eval

Definition at line 23 of file op_waitloop.hpp.

Function Documentation

template<typename T >
auto op::AdvancedRegistration ( T &  global_ids_on_rank,
int  root = 0,
MPI_Comm  mpicomm = MPI_COMM_WORLD 
)

AdvancedRegistration procedure given

Returns
CommPattern to use with op::Optimizer

Definition at line 338 of file op.hpp.

template<typename T >
double op::NLoptFunctional ( const std::vector< double > &  x,
std::vector< double > &  grad,
void *  objective_and_optimizer 
)

Takes in a op::Functional and computes the objective function and it's gradient as a nlopt function.

Has the same signature as nlopt::function so we can convert any op::Functional into a nlopt::function

Parameters
[in]xthe optimization variables (on rank = 0 this is the actual global optimization variables, on other ranks it is the local-view of variables.data())
[in]gradthe result of the gradient of the function w.r.t. x (on rank 0, this is the global gradient eval, on other ranks it is the owned-local gradient)
[in]objectiveGet FunctionalInfo into this call

for constraints g >= lower_bound, they need to be rewritten as -(g - lower_bound) <= 0

for constraints g <= upper_bound, they need to be rewritten as g - upper_bound < = 0

for constraints g >= lower_bound, they need to be rewritten as -(g - lower_bound) <= 0

for constraints g <= upper_bound, they need to be rewritten as g - upper_bound < = 0

Definition at line 406 of file nlopt_op.hpp.

template<typename T , typename I >
auto op::OwnedLocalObjectiveGradientFunction ( utility::RankCommunication< T > &  info,
I &  global_ids_to_local,
T &  reduced_id_list,
std::function< std::vector< double >(const std::vector< double > &)>  local_obj_grad_func,
std::function< double(const std::vector< double > &)>  local_reduce_func,
MPI_Comm  comm = MPI_COMM_WORLD 
)

Generate an objective gradient function that takes local variables and reduces them in parallel to locally "owned" variables.

Parameters
[in]infoRankCommunication struct for local_variables
[in]global_ids_to_localA vector mapping of global ids corresponding to local_variable indices
[in]local_obj_grad_funcThe rank-local gradient contributions corresponding to local_variables
[in]local_reduce_funcA serial user-defined function computed on "owned" variables over both recieved contributions from other ranks and rank-local gradient contributions
[in]commthe MPI communicator

Definition at line 283 of file op.hpp.

template<class OptType , typename... Args>
std::unique_ptr<OptType> op::PluginOptimizer ( std::string  optimizer_path,
Args &&...  args 
)

Dynamically load an Optimizer.

Parameters
[in]optimizer_pathpath to dynamically loadable .so plugin
[in]argsA list of args to pass in for initialization

Definition at line 231 of file op.hpp.

template<typename V , typename T >
auto op::ReduceObjectiveFunction ( const std::function< V(T)> &  local_func,
MPI_Op  op,
MPI_Comm  comm = MPI_COMM_WORLD 
)

Generate an objective function that performs a global reduction.

Parameters
[in]local_funcA user-defined function to compute a rank-local objective-contribution
[in]opThe MPI reduction operation
[in]commThe MPI communicator

Definition at line 257 of file op.hpp.

template<typename T , typename I , typename ValuesType >
ValuesType op::ReturnLocalUpdatedVariables ( utility::RankCommunication< T > &  info,
I &  global_ids_to_local,
ValuesType &  reduced_values 
)

Generate update method to propagate owned local variables back to local variables in parallel.

for the variables a rank owns.. update() should propagate those for the variables an update does not own.. they will be in returned_data returned_remapped_data is a map[local_ids] -> values we want to write it back into our local variable array

Parameters
[in]infoThe RankCommunication information corresponding to local_variable data
[in]global_ids_to_localA vector mapping of global ids corresponding to local_variable indices
[in]reduced_valuesThe rank-local "owned" variables

Definition at line 313 of file op.hpp.

auto op::wrapNLoptFunc ( std::function< double(unsigned, const double *, double *, void *)>  func)

wraps any nltop::function into an objective call and a gradient call

Parameters
[in]funca nlopt::function

Definition at line 40 of file nlopt_op.hpp.