diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f592faa..3447b76 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: # build wheels for some linux name: Build linux ${{ matrix.python.name }} wheel runs-on: ubuntu-latest - container: quay.io/pypa/manylinux2014_x86_64 + container: ${{ matrix.cont.val }} strategy: matrix: python: @@ -46,6 +46,19 @@ jobs: abi: cp312, version: '3.12', } + cont: + - { + name: manylinux2014_x86_64, + val: quay.io/pypa/manylinux2014_x86_64 + } + - { + name: manylinux2014_aarch64, + val: quay.io/pypa/manylinux2014_aarch64 + } + - { + name: musllinux_1_1_i686, + val: quay.io/pypa/musllinux_1_1_i686 + } steps: @@ -80,11 +93,10 @@ jobs: pip3 install wheelhouse/*.whl --user pip freeze - # - name: Install GDB - # run: yum install -y gdb - - name: Check package can be imported (bare install) run: | + mkdir tmp_for_import_checking + cd tmp_for_import_checking python3 -c "import lightsim2grid" python3 -c "from lightsim2grid import *" python3 -c "from lightsim2grid.newtonpf import newtonpf" @@ -106,6 +118,7 @@ jobs: - name: Check extra can be imported can be imported (with grid2op) run: + cd tmp_for_import_checking python3 -v -c "from lightsim2grid import LightSimBackend" python3 -c "from lightsim2grid.timeSerie import TimeSerie" python3 -c "from lightsim2grid.contingencyAnalysis import ContingencyAnalysis" @@ -114,12 +127,13 @@ jobs: - name: Check LightSimBackend can be used to create env run: + cd tmp_for_import_checking python3 -v -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())" - name: Upload wheel uses: actions/upload-artifact@v3 # v4 broken with: - name: lightsim2grid-wheel-linux-${{ matrix.python.name }} + name: lightsim2grid-wheel-linux-${{ matrix.python.name }}-${{ matrix.cont.name }} path: wheelhouse/*.whl - name: Upload source archive diff --git a/src/ChooseSolver.h b/src/ChooseSolver.h index a373908..af76606 100644 --- a/src/ChooseSolver.h +++ b/src/ChooseSolver.h @@ -320,6 +320,12 @@ class ChooseSolver return p_solver -> get_timers_jacobian(); } + TimerPTDFLODFType get_timers_ptdf_lodf() const + { + const BaseAlgo * p_solver = get_prt_solver("get_timers_ptdf_lodf", true); + return p_solver -> get_timers_ptdf_lodf(); + } + ErrorType get_error() const{ auto p_solver = get_prt_solver("get_error", true); return p_solver -> get_error(); diff --git a/src/main.cpp b/src/main.cpp index b88e01e..bba1c24 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -446,6 +446,7 @@ PYBIND11_MODULE(lightsim2grid_cpp, m) .def("get_computation_time", &ChooseSolver::get_computation_time, DocSolver::get_computation_time.c_str()) .def("get_timers", &ChooseSolver::get_timers, "TODO") .def("get_timers_jacobian", &ChooseSolver::get_timers_jacobian, "TODO") + .def("get_timers_ptdf_lodf", &ChooseSolver::get_timers_ptdf_lodf, "TODO") .def("get_fdpf_xb_lu", &ChooseSolver::get_fdpf_xb_lu, py::return_value_policy::reference, DocGridModel::_internal_do_not_use.c_str()) // TODO this for all solver ! .def("get_fdpf_bx_lu", &ChooseSolver::get_fdpf_bx_lu, py::return_value_policy::reference, DocGridModel::_internal_do_not_use.c_str()); diff --git a/src/powerflow_algorithm/BaseAlgo.h b/src/powerflow_algorithm/BaseAlgo.h index 800c334..4801776 100644 --- a/src/powerflow_algorithm/BaseAlgo.h +++ b/src/powerflow_algorithm/BaseAlgo.h @@ -33,6 +33,7 @@ class GridModel; typedef std::tuple TimerJacType; +typedef std::tuple TimerPTDFLODFType; /** This class represents a algorithm to compute powerflow. @@ -104,6 +105,16 @@ class BaseAlgo : public BaseConstants }; return res; } + + virtual TimerPTDFLODFType get_timers_ptdf_lodf() const + { + TimerPTDFLODFType res = { + -1., // not available for non NR solver, so I put -1 + -1., // not available for non NR solver, so I put -1 + -1., // not available for non NR solver, so I put -1 + }; + return res; + } virtual bool compute_pf(const Eigen::SparseMatrix & Ybus, diff --git a/src/powerflow_algorithm/BaseDCAlgo.h b/src/powerflow_algorithm/BaseDCAlgo.h index b507aa8..5421e68 100644 --- a/src/powerflow_algorithm/BaseDCAlgo.h +++ b/src/powerflow_algorithm/BaseDCAlgo.h @@ -19,12 +19,29 @@ class BaseDCAlgo: public BaseAlgo BaseAlgo(false), _linear_solver(), need_factorize_(true), + timer_ptdf_(0.), + timer_lodf_(0.), sizeYbus_with_slack_(0), sizeYbus_without_slack_(0){}; ~BaseDCAlgo(){} virtual void reset(); + virtual void reset_timer(){ + BaseAlgo::reset_timer(); + timer_ptdf_ = 0.; + timer_lodf_ = 0.; + } + + virtual TimerPTDFLODFType get_timers_ptdf_lodf() const + { + TimerPTDFLODFType res = { + timer_ptdf_, + timer_lodf_ - timer_ptdf_, + -1., // not available yet so I put -1 + }; + return res; + } // TODO SLACK : this should be handled in Sbus by the gridmodel maybe ? virtual @@ -62,6 +79,9 @@ class BaseDCAlgo: public BaseAlgo LinearSolver _linear_solver; bool need_factorize_; + double timer_ptdf_; + double timer_lodf_; + // save this not to recompute them when not needed int sizeYbus_with_slack_; int sizeYbus_without_slack_; diff --git a/src/powerflow_algorithm/BaseDCAlgo.tpp b/src/powerflow_algorithm/BaseDCAlgo.tpp index 3e59cfb..124aa80 100644 --- a/src/powerflow_algorithm/BaseDCAlgo.tpp +++ b/src/powerflow_algorithm/BaseDCAlgo.tpp @@ -234,6 +234,7 @@ void BaseDCAlgo::reset(){ template RealMat BaseDCAlgo::get_ptdf(const Eigen::SparseMatrix & dcYbus){ + auto timer = CustTimer(); Eigen::SparseMatrix Bf_T_with_slack; RealMat PTDF; RealVect rhs = RealVect::Zero(sizeYbus_without_slack_); // TODO dist slack: -1 or -mat_bus_id_.size() here ???? @@ -277,6 +278,7 @@ RealMat BaseDCAlgo::get_ptdf(const Eigen::SparseMatrix rhs.array() = 0.; // rhs = RealVect::Zero(sizeYbus_without_slack_); } + timer_ptdf_ = timer.duration(); // TODO PTDF: if the solver can solve the MAT directly, do that instead return PTDF; } @@ -285,6 +287,7 @@ template RealMat BaseDCAlgo::get_lodf(const Eigen::SparseMatrix & dcYbus, const IntVect & from_bus, const IntVect & to_bus){ + auto timer = CustTimer(); const RealMat PTDF = get_ptdf(dcYbus); // size n_line x n_bus RealMat LODF = RealMat::Zero(from_bus.size(), from_bus.rows()); // nb_line, nb_line for(Eigen::Index line_id=0; line_id < from_bus.size(); ++line_id){ @@ -297,6 +300,7 @@ RealMat BaseDCAlgo::get_lodf(const Eigen::SparseMatrix LODF.col(line_id).array() = std::numeric_limits::quiet_NaN(); } } + timer_lodf_ = timer.duration(); return LODF; }