12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #ifndef OPTIMIZERBASE_H
- #define OPTIMIZERBASE_H
- #include "IOptimizer.h"
- #include "exprtk.hpp"
- namespace mdd {
- ////////////////////////////////////////////////////////////
- //
- //Optimization is always minimization!
- //
- ////////////////////////////////////////////////////////////
- class OptimizerBase
- : public IOptimizer
- {
- protected:
- std::string _base_config = "";
- std::shared_ptr<IModule> _module;
- std::vector<std::shared_ptr<IInput>> _inputs;
- 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 updateOutputs();
- OptimizerBase(const std::string& base_config);
- public:
- bool connect(std::shared_ptr<IModule> module) override;
- void updateLayout();
- bool setEvaluation(std::string func) override;
- bool configure(const std::string& config) override;
- std::string getConfiguration() override;
- //virtual std::string getGeneratorID() = 0;
- void load(const json& j);
- json dump();
- json getIdentifier() override;
- //state update() override;
- };
- }
- #endif
|