@@ -28,10 +28,9 @@ py::bytes saveNetworkToBinaryBufferPython(const pypowsybl::JavaHandle& network,
28
28
29
29
void setCracSource (const pypowsybl::JavaHandle& networkHandle, const pypowsybl::JavaHandle& raoHandle, const py::buffer& crac);
30
30
void setGlskSource (const pypowsybl::JavaHandle& networkHandle, const pypowsybl::JavaHandle& raoHandle, const py::buffer& glsk);
31
- void runRaoWithParameters (const pypowsybl::JavaHandle& networkHandle, const pypowsybl::JavaHandle& raoHandle, const pypowsybl::JavaHandle& parametersHandle);
32
- pypowsybl::JavaHandle loadRaoParametersFromBuffer (const py::buffer& parameters);
31
+ pypowsybl::RaoParameters* loadRaoParametersFromBuffer (const py::buffer& parameters);
33
32
34
- py::bytes saveRaoParametersToBinaryBuffer (const pypowsybl::JavaHandle & rao_parameters);
33
+ py::bytes saveRaoParametersToBinaryBuffer (const pypowsybl::RaoParameters & rao_parameters);
35
34
py::bytes saveRaoResultsToBinaryBuffer (const pypowsybl::JavaHandle& raoContext, const pypowsybl::JavaHandle& crac);
36
35
37
36
template <typename T>
@@ -764,6 +763,84 @@ PYBIND11_MODULE(_pypowsybl, m) {
764
763
.value (" DEFAULT" , RaoComputationStatus::DEFAULT)
765
764
.value (" FAILURE" , RaoComputationStatus::FAILURE);
766
765
766
+ py::enum_<pypowsybl::PreventiveStopCriterion>(m, " PreventiveStopCriterion" , " " )
767
+ .value (" MIN_OBJECTIVE" , pypowsybl::PreventiveStopCriterion::P_MIN_OBJECTIVE, " " )
768
+ .value (" SECURE" , pypowsybl::PreventiveStopCriterion::P_SECURE, " " );
769
+
770
+ py::enum_<pypowsybl::CurativeStopCriterion>(m, " CurativeStopCriterion" , " " )
771
+ .value (" MIN_OBJECTIVE" , pypowsybl::CurativeStopCriterion::C_MIN_OBJECTIVE, " " )
772
+ .value (" SECURE" , pypowsybl::CurativeStopCriterion::C_SECURE, " " )
773
+ .value (" PREVENTIVE_OBJECTIVE" , pypowsybl::CurativeStopCriterion::C_PREVENTIVE_OBJECTIVE, " " )
774
+ .value (" PREVENTIVE_OBJECTIVE_AND_SECURE" , pypowsybl::CurativeStopCriterion::C_PREVENTIVE_OBJECTIVE_AND_SECURE, " " );
775
+
776
+ py::enum_<pypowsybl::ObjectiveFunctionType>(m, " ObjectiveFunctionType" , " " )
777
+ .value (" MAX_MIN_MARGIN_IN_MEGAWATT" , pypowsybl::ObjectiveFunctionType::MAX_MIN_MARGIN_IN_MEGAWATT, " " )
778
+ .value (" MAX_MIN_MARGIN_IN_AMPERE" , pypowsybl::ObjectiveFunctionType::MAX_MIN_MARGIN_IN_AMPERE, " " )
779
+ .value (" MAX_MIN_RELATIVE_MARGIN_IN_MEGAWATT" , pypowsybl::ObjectiveFunctionType::MAX_MIN_RELATIVE_MARGIN_IN_MEGAWATT, " " )
780
+ .value (" MAX_MIN_RELATIVE_MARGIN_IN_AMPERE" , pypowsybl::ObjectiveFunctionType::MAX_MIN_RELATIVE_MARGIN_IN_AMPERE, " " )
781
+ .value (" MIN_COST_IN_MEGAWATT" , pypowsybl::ObjectiveFunctionType::MIN_COST_IN_MEGAWATT, " " )
782
+ .value (" MIN_COST_IN_AMPERE" , pypowsybl::ObjectiveFunctionType::MIN_COST_IN_AMPERE, " " );
783
+
784
+ py::enum_<pypowsybl::Solver>(m, " Solver" )
785
+ .value (" CBC" , pypowsybl::Solver::CBC)
786
+ .value (" SCIP" , pypowsybl::Solver::SCIP)
787
+ .value (" XPRESS" , pypowsybl::Solver::XPRESS);
788
+
789
+ py::enum_<pypowsybl::PstModel>(m, " PstModel" )
790
+ .value (" CONTINUOUS" , pypowsybl::PstModel::CONTINUOUS)
791
+ .value (" APPROXIMATED_INTEGERS" , pypowsybl::PstModel::APPROXIMATED_INTEGERS);
792
+
793
+ py::enum_<pypowsybl::RaRangeShrinking>(m, " RaRangeShrinking" )
794
+ .value (" DISABLED" , pypowsybl::RaRangeShrinking::DISABLED)
795
+ .value (" ENABLED" , pypowsybl::RaRangeShrinking::ENABLED)
796
+ .value (" ENABLED_IN_FIRST_PRAO_AND_CRAO" , pypowsybl::RaRangeShrinking::ENABLED_IN_FIRST_PRAO_AND_CRAO);
797
+
798
+ py::enum_<pypowsybl::ExecutionCondition>(m, " ExecutionCondition" )
799
+ .value (" DISABLED" , pypowsybl::ExecutionCondition::DISABLED)
800
+ .value (" POSSIBLE_CURATIVE_IMPROVEMENT" , pypowsybl::ExecutionCondition::POSSIBLE_CURATIVE_IMPROVEMENT)
801
+ .value (" COST_INCREASE" , pypowsybl::ExecutionCondition::COST_INCREASE);
802
+
803
+ py::class_<pypowsybl::RaoParameters>(m, " RaoParameters" )
804
+ .def (py::init (&pypowsybl::createRaoParameters))
805
+ .def_readwrite (" objective_function_type" , &pypowsybl::RaoParameters::objective_function_type)
806
+ .def_readwrite (" preventive_stop_criterion" , &pypowsybl::RaoParameters::preventive_stop_criterion)
807
+ .def_readwrite (" curative_stop_criterion" , &pypowsybl::RaoParameters::curative_stop_criterion)
808
+ .def_readwrite (" curative_min_obj_improvement" , &pypowsybl::RaoParameters::curative_min_obj_improvement)
809
+ .def_readwrite (" forbid_cost_increase" , &pypowsybl::RaoParameters::forbid_cost_increase)
810
+ .def_readwrite (" optimize_curative_if_preventive_unsecure" , &pypowsybl::RaoParameters::optimize_curative_if_preventive_unsecure)
811
+ .def_readwrite (" solver" , &pypowsybl::RaoParameters::solver)
812
+ .def_readwrite (" relative_mip_gap" , &pypowsybl::RaoParameters::relative_mip_gap)
813
+ .def_readwrite (" solver_specific_parameters" , &pypowsybl::RaoParameters::solver_specific_parameters)
814
+ .def_readwrite (" max_mip_iterations" , &pypowsybl::RaoParameters::max_mip_iterations)
815
+ .def_readwrite (" pst_penalty_cost" , &pypowsybl::RaoParameters::pst_penalty_cost)
816
+ .def_readwrite (" pst_sensitivity_threshold" , &pypowsybl::RaoParameters::pst_sensitivity_threshold)
817
+ .def_readwrite (" pst_model" , &pypowsybl::RaoParameters::pst_model)
818
+ .def_readwrite (" hvdc_penalty_cost" , &pypowsybl::RaoParameters::hvdc_penalty_cost)
819
+ .def_readwrite (" hvdc_sensitivity_threshold" , &pypowsybl::RaoParameters::hvdc_sensitivity_threshold)
820
+ .def_readwrite (" injection_ra_penalty_cost" , &pypowsybl::RaoParameters::injection_ra_penalty_cost)
821
+ .def_readwrite (" injection_ra_sensitivity_threshold" , &pypowsybl::RaoParameters::injection_ra_sensitivity_threshold)
822
+ .def_readwrite (" ra_range_shrinking" , &pypowsybl::RaoParameters::ra_range_shrinking)
823
+ .def_readwrite (" max_preventive_search_tree_depth" , &pypowsybl::RaoParameters::max_preventive_search_tree_depth)
824
+ .def_readwrite (" max_auto_search_tree_depth" , &pypowsybl::RaoParameters::max_auto_search_tree_depth)
825
+ .def_readwrite (" max_curative_search_tree_depth" , &pypowsybl::RaoParameters::max_curative_search_tree_depth)
826
+ .def_readwrite (" relative_min_impact_threshold" , &pypowsybl::RaoParameters::relative_min_impact_threshold)
827
+ .def_readwrite (" absolute_min_impact_threshold" , &pypowsybl::RaoParameters::absolute_min_impact_threshold)
828
+ .def_readwrite (" skip_actions_far_from_most_limiting_element" , &pypowsybl::RaoParameters::skip_actions_far_from_most_limiting_element)
829
+ .def_readwrite (" max_number_of_boundaries_for_skipping_actions" , &pypowsybl::RaoParameters::max_number_of_boundaries_for_skipping_actions)
830
+ .def_readwrite (" contingency_scenarios_in_parallel" , &pypowsybl::RaoParameters::contingency_scenarios_in_parallel)
831
+ .def_readwrite (" preventive_leaves_in_parallel" , &pypowsybl::RaoParameters::preventive_leaves_in_parallel)
832
+ .def_readwrite (" auto_leaves_in_parallel" , &pypowsybl::RaoParameters::auto_leaves_in_parallel)
833
+ .def_readwrite (" curative_leaves_in_parallel" , &pypowsybl::RaoParameters::curative_leaves_in_parallel)
834
+ .def_readwrite (" execution_condition" , &pypowsybl::RaoParameters::execution_condition)
835
+ .def_readwrite (" re_optimize_curative_range_actions" , &pypowsybl::RaoParameters::re_optimize_curative_range_actions)
836
+ .def_readwrite (" hint_from_first_preventive_rao" , &pypowsybl::RaoParameters::hint_from_first_preventive_rao)
837
+ .def_readwrite (" do_not_optimize_curative_cnecs_for_tsos_without_cras" , &pypowsybl::RaoParameters::do_not_optimize_curative_cnecs_for_tsos_without_cras)
838
+ .def_readwrite (" load_flow_provider" , &pypowsybl::RaoParameters::load_flow_provider)
839
+ .def_readwrite (" sensitivity_provider" , &pypowsybl::RaoParameters::sensitivity_provider)
840
+ .def_readwrite (" sensitivity_failure_overcost" , &pypowsybl::RaoParameters::sensitivity_failure_overcost)
841
+ .def_readwrite (" provider_parameters_keys" , &pypowsybl::RaoParameters::provider_parameters_keys)
842
+ .def_readwrite (" provider_parameters_values" , &pypowsybl::RaoParameters::provider_parameters_values);
843
+
767
844
py::class_<network_metadata, std::shared_ptr<network_metadata>>(m, " NetworkMetadata" )
768
845
.def_property_readonly (" id" , [](const network_metadata& att) {
769
846
return att.id ;
@@ -1145,7 +1222,7 @@ PYBIND11_MODULE(_pypowsybl, m) {
1145
1222
m.def (" get_short_circuit_bus_results" , &pypowsybl::getShortCircuitBusResults, " gets the bus results of a short-circuit analysis" , py::arg (" result" ), py::arg (" with_fortescue_result" ));
1146
1223
1147
1224
m.def (" create_rao" , &pypowsybl::createRao, " Create rao context" );
1148
- m.def (" run_rao" , ::runRaoWithParameters, py::call_guard<py::gil_scoped_release>(), " Run a rao from buffered inputs" ,
1225
+ m.def (" run_rao" , &pypowsybl ::runRaoWithParameters, py::call_guard<py::gil_scoped_release>(), " Run a rao from buffered inputs" ,
1149
1226
py::arg (" network" ), py::arg (" rao_context" ), py::arg (" parameters" ));
1150
1227
m.def (" set_crac_source" , ::setCracSource, py::call_guard<py::gil_scoped_release>(), " Set crac source" ,
1151
1228
py::arg (" network" ), py::arg (" rao_context" ), py::arg (" crac_source" ));
@@ -1158,6 +1235,8 @@ PYBIND11_MODULE(_pypowsybl, m) {
1158
1235
m.def (" serialize_rao_parameters" , ::saveRaoParametersToBinaryBuffer, " Serialize rao parameters to a buffer" , py::arg (" rao_parameters" ));
1159
1236
m.def (" serialize_rao_results_to_buffer" , ::saveRaoResultsToBinaryBuffer, " Run a rao" , py::arg (" rao_result" ), py::arg (" crac" ));
1160
1237
m.def (" get_rao_result_status" , &pypowsybl::getRaoResultStatus, " Get the status of a rao result" , py::arg (" rao_result" ));
1238
+ m.def (" run_voltage_monitoring" , &pypowsybl::runVoltageMonitoring, " Run voltage monitoring" , py::arg (" network" ), py::arg (" rao_context" ), py::arg (" load_flow_parameters" ), py::arg (" provider" ));
1239
+ m.def (" run_angle_monitoring" , &pypowsybl::runAngleMonitoring, " Run angle monitoring" , py::arg (" network" ), py::arg (" rao_context" ), py::arg (" load_flow_parameters" ), py::arg (" provider" ));
1161
1240
1162
1241
py::enum_<Grid2opStringValueType>(m, " Grid2opStringValueType" )
1163
1242
.value (" VOLTAGE_LEVEL_NAME" , Grid2opStringValueType::VOLTAGE_LEVEL_NAME)
@@ -1290,11 +1369,6 @@ void setGlskSource(const pypowsybl::JavaHandle& networkHandle, const pypowsybl::
1290
1369
static_cast <char *>(glskInfo.ptr ), glskInfo.size );
1291
1370
}
1292
1371
1293
- void runRaoWithParameters (const pypowsybl::JavaHandle& networkHandle, const pypowsybl::JavaHandle& raoHandle, const pypowsybl::JavaHandle& parametersHandle) {
1294
- pypowsybl::PowsyblCaller::get ()->callJava <>(::runRao,
1295
- networkHandle, raoHandle, parametersHandle);
1296
- }
1297
-
1298
1372
py::bytes saveRaoResultsToBinaryBuffer (const pypowsybl::JavaHandle& raoResult, const pypowsybl::JavaHandle& crac) {
1299
1373
array* byteArray = pypowsybl::PowsyblCaller::get ()->callJava <array*>(::serializeRaoResultsToBuffer, raoResult, crac);
1300
1374
py::gil_scoped_acquire acquire;
@@ -1303,14 +1377,15 @@ py::bytes saveRaoResultsToBinaryBuffer(const pypowsybl::JavaHandle& raoResult, c
1303
1377
return bytes;
1304
1378
}
1305
1379
1306
- pypowsybl::JavaHandle loadRaoParametersFromBuffer (const py::buffer& parameters) {
1380
+ pypowsybl::RaoParameters* loadRaoParametersFromBuffer (const py::buffer& parameters) {
1307
1381
py::buffer_info parametersInfo = parameters.request ();
1308
- return pypowsybl::PowsyblCaller::get ()->callJava <pypowsybl::JavaHandle >(::loadRaoParameters,
1309
- static_cast < char *>(parametersInfo. ptr ), parametersInfo. size );
1382
+ rao_parameters* c_parameters = pypowsybl::PowsyblCaller::get ()->callJava <rao_parameters* >(::loadRaoParameters, static_cast < char *>(parametersInfo. ptr ), parametersInfo. size );
1383
+ return new pypowsybl::RaoParameters (c_parameters );
1310
1384
}
1311
1385
1312
- py::bytes saveRaoParametersToBinaryBuffer (const pypowsybl::JavaHandle& rao_parameters) {
1313
- array* byteArray = pypowsybl::PowsyblCaller::get ()->callJava <array*>(::serializeRaoParameters, rao_parameters);
1386
+ py::bytes saveRaoParametersToBinaryBuffer (const pypowsybl::RaoParameters& rao_parameters) {
1387
+ auto c_parameters = rao_parameters.to_c_struct ();
1388
+ array* byteArray = pypowsybl::PowsyblCaller::get ()->callJava <array*>(::serializeRaoParameters, c_parameters.get ());
1314
1389
py::gil_scoped_acquire acquire;
1315
1390
py::bytes bytes ((char *) byteArray->ptr , byteArray->length );
1316
1391
pypowsybl::PowsyblCaller::get ()->callJava <>(::freeBinaryBuffer, byteArray);
0 commit comments