CYCLUS
Loading...
Searching...
No Matches
symbolic_function_factories.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_TOOLKIT_SYMBOLIC_FUNCTION_FACTORIES_H_
2#define CYCLUS_SRC_TOOLKIT_SYMBOLIC_FUNCTION_FACTORIES_H_
3
4#include <string>
5#include <map>
6#include <sstream>
7#include <boost/shared_ptr.hpp>
8
10
11namespace cyclus {
12namespace toolkit {
13
14
15/// An abstract factory for pointers to symbolic functions
17 public:
18 /// Virtual destructor for an abstract base class
20
21 /// A virtual function that must be defined by derived classes
22 /// @param params a string of required parameters for the function
23 /// @return a FunctionPtr to the constructed function
24 virtual SymFunction::Ptr GetFunctionPtr(std::string params) = 0;
25};
26
27/// A concrete factory for linear functions
29 public:
30 /// Return a function pointer to a linear function
31 ///
32 /// @param params a string of space-separated values for m and b in the equation
33 /// \f[
34 /// y = mx + b
35 /// \f]
36 ///
37 /// @return the linear function
38 ///
39 /// \b Example
40 /// @code
41 /// SymFunction::Ptr func = fac.GetFunctionPtr("2.5 5"); // y = 2.5x + 5
42 /// @endcode
43 virtual SymFunction::Ptr GetFunctionPtr(std::string params);
44};
45
46/// A concrete factory for exponential functions
48 public:
49 /// Return a function pointer to a exponential function
50 ///
51 /// @param params a string of space-separated values for c, a, and b in the
52 /// equation
53 /// \f[
54 /// y = ce^{ax} + b
55 /// \f]
56 ///
57 /// @return the exponential function
58 ///
59 /// \b Example
60 /// @code
61 /// SymFunction::Ptr func = fac.GetFunctionPtr("2.5 0.1 5"); // y = 2.5exp(0.1x) + 5
62 /// @endcode
63 virtual SymFunction::Ptr GetFunctionPtr(std::string params);
64};
65
66/// A concrete factory for piecewise functions
68 public:
69 /// Constructor
71
72 /// Return a function pointer to a piecewise function
73 /// @param params an empty string by default. if this is not empty,
74 /// an error is thrown
75 /// @return the piecewise function
76 virtual SymFunction::Ptr GetFunctionPtr(std::string params = "");
77
78 /// Add a function to the piecewise function being constructed
79 /// @param function the function to append
80 /// @param starting_coord the x coordinate to begin this function
81 /// @param continuous if true, the added function and previous
82 /// function will be continuous, if false, discontinuous
83 void AddFunction(SymFunction::Ptr function, double starting_coord = 0.0,
84 bool continuous = true);
85
86 private:
87 /// The piecewise function to construct
88 boost::shared_ptr<PiecewiseFunction> function_;
89};
90
91/// A concrete factory that can provide access to basic symbolic
92/// functions.
94 public:
95 /// The type of functions this factory can provide
97 /// See cyclus::toolkit::LinFunctionFactory for a description of function
98 /// parameters
100 /// See cyclus::toolkit::ExpFunctionFactory for a description of function
101 /// parameters
102 EXP
103 };
104
105 /// Constructor sets up the enum names map
107
108 /// Return a function pointer to a registered function type
109 /// @param type the function type, see BasicFunctionFactory::FunctionType for
110 /// supported function types. For each supported function type, either the
111 /// full name or the first three letters are acceptable. For example, for a
112 /// "linear" function, either "linear" or "lin" are acceptable.
113 /// @param params the function parameters
114 /// @return the function
115 SymFunction::Ptr GetFunctionPtr(std::string type, std::string params);
116
117 private:
118 /// A map between enums and names
119 static std::map<std::string, BasicFunctionFactory::FunctionType> enum_names_;
120};
121
122} // namespace toolkit
123} // namespace cyclus
124
125#endif // CYCLUS_SRC_TOOLKIT_SYMBOLIC_FUNCTION_FACTORIES_H_
A concrete factory that can provide access to basic symbolic functions.
SymFunction::Ptr GetFunctionPtr(std::string type, std::string params)
Return a function pointer to a registered function type.
FunctionType
The type of functions this factory can provide.
@ LIN
See cyclus::toolkit::LinFunctionFactory for a description of function parameters.
@ EXP
See cyclus::toolkit::ExpFunctionFactory for a description of function parameters.
BasicFunctionFactory()
Constructor sets up the enum names map.
A concrete factory for exponential functions.
virtual SymFunction::Ptr GetFunctionPtr(std::string params)
Return a function pointer to a exponential function.
A concrete factory for linear functions.
virtual SymFunction::Ptr GetFunctionPtr(std::string params)
Return a function pointer to a linear function.
A concrete factory for piecewise functions.
virtual SymFunction::Ptr GetFunctionPtr(std::string params="")
Return a function pointer to a piecewise function.
void AddFunction(SymFunction::Ptr function, double starting_coord=0.0, bool continuous=true)
Add a function to the piecewise function being constructed.
boost::shared_ptr< SymFunction > Ptr
An abstract factory for pointers to symbolic functions.
virtual ~SymbFunctionFactory()
Virtual destructor for an abstract base class.
virtual SymFunction::Ptr GetFunctionPtr(std::string params)=0
A virtual function that must be defined by derived classes.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters