#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<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();
		
	public:
		void updateLayout();
		bool setEvaluation(std::string func) override;
		//state update() override;
	};
}
#endif
