// Copyright (C) 2026 EDF
// All Rights Reserved
// This code is published under the GNU Lesser General Public License (GNU LGPL)
#ifndef DYNAMICPROGRAMMINGSTORAGE_H
#define DYNAMICPROGRAMMINGSTORAGE_H
#include <memory>
#include <string>
#ifdef USE_MPI
#include <boost/mpi.hpp>
#endif
#include <Eigen/Dense>
#include <StOpt/regression/BaseRegression.h>
#include "StOpt/core/grids/SpaceGrid.h"
#include "StOpt/dp/OptimizerDPBase.h"
#include "test/c++/tools/utils/Tunnel.h"


///\brief DynamicProgrammingStorage   Optimize the storage
/// \param p_tunnel          Define min and max of the tunnel used. At each date, get back discretization grid associated
/// \param p_optimize        Optimizer object defining the control at each level in the storage
/// \param p_pointStockInit  Initial level in storage
/// \param p_fileToDump      file where Bellman and continuation values and storage are dumped
/// \param p_world           MPI communicator
double  DynamicProgrammingStorage(const Tunnel &p_tunnel,
                                  const std::shared_ptr<StOpt::OptimizerDPBase > &p_optimize,
                                  const std::shared_ptr<StOpt::BaseRegression> &p_regressor,
                                  const Eigen::ArrayXd &p_pointStockInit,
                                  const std::string   &p_fileToDump
#ifdef USE_MPI
                                  , const boost::mpi::communicator &p_world
#endif
                                 );
#endif
