OptimizerBase.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef OPTIMIZERBASE_H
  2. #define OPTIMIZERBASE_H
  3. #include "IOptimizer.h"
  4. #include "exprtk.hpp"
  5. namespace mdd {
  6. ////////////////////////////////////////////////////////////
  7. //
  8. //Optimization is always minimization!
  9. //
  10. ////////////////////////////////////////////////////////////
  11. class OptimizerBase
  12. : public IOptimizer
  13. {
  14. protected:
  15. std::string _base_config = "";
  16. std::shared_ptr<IModule> _module;
  17. std::vector<std::shared_ptr<IInput>> _inputs;
  18. std::vector<std::shared_ptr<IOutput>> _outputs;
  19. std::vector<double> _output_vals;
  20. exprtk::expression<double> _func_expr;
  21. struct opt_state {
  22. state module_state = state::STATE_ERROR;
  23. double opt_value = 0;
  24. };
  25. opt_state updateOutputs();
  26. OptimizerBase(const std::string& base_config);
  27. public:
  28. void updateLayout();
  29. bool setEvaluation(std::string func) override;
  30. bool configure(const std::string& config);
  31. std::string getBaseConfiguration();
  32. //virtual std::string getGeneratorID() = 0;
  33. void load(const json& j);
  34. json dump();
  35. //state update() override;
  36. };
  37. }
  38. #endif