12345678910111213141516171819202122232425262728293031323334353637 |
- #ifndef OPTIMIZERBASE_H
- #define OPTIMIZERBASE_H
- #include "IOptimizer.h"
- #include "exprtk.hpp"
- namespace mdd {
- ////////////////////////////////////////////////////////////
- //
- //Optimization is always minimization!
- //
- ////////////////////////////////////////////////////////////
- class OptimizerBase : public IOptimizer {
- protected:
- std::shared_ptr<IModule> _module;
- std::vector<std::shared_ptr<IInput>> _inputs;
- std::vector<json> _input_limits;
- std::vector<std::shared_ptr<IOutput>> _outputs;
- std::vector<double> _output_vals;
- exprtk::expression<double> _func_expr;
- struct opt_state {
- state module_state = state::STATE_ERROR;
- double opt_value = 0;
- };
- opt_state updateReader();
- public:
- bool addModifier(std::string input_id, const json& limit) override;
- bool addReader(std::string output_id) override;
- bool changeModifier(std::string input_id, const json& limit) override;
- void removeModifier(std::string input_id) override;
- void removeReader(std::string output_id) override;
- bool setEvaluation(std::string func) override;
- //state update() override;
- };
- }
- #endif
|