From b87a359190498647b34f49b3699e7ac4ce7d1785 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sat, 19 Sep 2026 00:54:00 +0200 Subject: [PATCH 01/28] the configuration templates that use the bundle are written for the BundleSolver 2.0, whose master is solved by the Solver of MPBCfg.txt --- .../data/configs/InvestmentBlock/BSPar.txt | 24 +--- .../data/configs/InvestmentBlock/MPBCfg.txt | 122 ++++++++++++++++++ pysmspp/data/configs/README.md | 3 + pysmspp/data/configs/SDDPBlock/BSPar-LD.txt | 23 +--- .../configs/SDDPBlock/BSPar-greedy-LD.txt | 24 +--- pysmspp/data/configs/SDDPBlock/MPBCfg.txt | 122 ++++++++++++++++++ pysmspp/data/configs/SVMBlock/LDCfg.txt | 28 +--- pysmspp/data/configs/SVMBlock/MPBCfg.txt | 118 +++++++++++++++++ pysmspp/data/configs/TSSBlock/LPBSCfg-LD.txt | 24 +--- pysmspp/data/configs/TSSBlock/MPBCfg.txt | 122 ++++++++++++++++++ pysmspp/data/configs/TSSBlock/TSSBSCfg-LD.txt | 24 +--- 11 files changed, 517 insertions(+), 117 deletions(-) create mode 100644 pysmspp/data/configs/InvestmentBlock/MPBCfg.txt create mode 100644 pysmspp/data/configs/SDDPBlock/MPBCfg.txt create mode 100644 pysmspp/data/configs/SVMBlock/MPBCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/MPBCfg.txt diff --git a/pysmspp/data/configs/InvestmentBlock/BSPar.txt b/pysmspp/data/configs/InvestmentBlock/BSPar.txt index e783924..635e226 100644 --- a/pysmspp/data/configs/InvestmentBlock/BSPar.txt +++ b/pysmspp/data/configs/InvestmentBlock/BSPar.txt @@ -29,9 +29,10 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -23 # number of integer parameters +17 # number of integer parameters # now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized intDoEasy 0 # do easy components for (some) LagBFunction intMaxIter 10000 # max number of iterations for each call intMaxThread 6 # MaxThread, max number of new tasks to spawn @@ -47,25 +48,10 @@ intMnSSC 0 # min number of consecutive SS with the same t for a t increas intMnNSC 3 # min number of consecutive NS with the same t for a t decrease inttSPar1 0 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) intMaxNrEvls 2 # maximum number of function evaluations at each iteration -intMPName 8 # MP solver: 0 = QPP, 7 = Cplex/Gurobi with quadratic stabilization - # + 8 = check for duplicate linearizations -# QPPenalty's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - - -intMPlvl 20 # log verbosity of Master Problem -intQPmp1 0 # MxAdd, how many variables can be added to the base at each - # iteration in BMinQuad (0 = at will) -intQPmp2 0 # MxRmv, how many variables can be removed from the base at each - # iteration in BMinQuad (0 = at will) - -# OSIMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - -intOSImp1 1 # Osi(Cpx/Grb)Solver algorithm (0 = auto (default), 1 = primal, 2 = dual, 3 = network, 4 = barrier, 5 = sifting, 6 = concurrent) -intOSImp2 1 # pre-processing (reduction) -intOSImp3 1 # threads intRstAlg 2 # parameter to handle the reset of the algorithm -16 # number of double parameters +15 # number of double parameters # now all the double parameters dblRelAcc 1e-4 # relative accuracy required to solution @@ -83,13 +69,13 @@ dbltMaior 1e+6 # maximum value for t dbltMinor 1e-10 # minimum value for t dbltInit 1e+0 # initial value for t dbltSPar2 1e-2 # parameter for the long-term t-strategy -dblCtOff 0.01 # cut-off factor for pricing in MinQuad -0 # number of string parameters +1 # number of string parameters # now all the string parameters #str_LagBF_BSCfg LPBSCfg.txt # BlockSolverConfig for the LagBFunctions # not needed if intDoEasy >= 1 && USE_BundleSolver > 0, this is done "by hand" +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt new file mode 100644 index 0000000..7c15020 --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt @@ -0,0 +1,122 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of the +# MasterProblemBlock used by the BundleSolver +# +# Donato Meoli, Antonio Frangioni +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +6 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END MPBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index d996971..19d1b7a 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -9,3 +9,6 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. + +The configurations that use the BundleSolver, i.e., InvestmentBlock/BSPar.txt, SDDPBlock/BSPar-LD.txt, SDDPBlock/BSPar-greedy-LD.txt, SVMBlock/LDCfg.txt, TSSBlock/TSSBSCfg-LD.txt and TSSBlock/LPBSCfg-LD.txt, are written for the BundleSolver 2.0, whose master problem is a Block of its own: `intMPStbl` chooses its stabilization and `strMPBSolverCfg` names the BlockSolverConfig of its Solver, the MPBCfg.txt of the same folder, which solves it with Gurobi. The parameters of the master of the BundleSolver 1.0 (`intMPName`, `intMPlvl`, `intQPmp1`, `intQPmp2`, `intOSImp1`, `intOSImp2`, `intOSImp3`, `dblCtOff`) are gone, and a name the SMS++ at hand does not know makes its whole ComputeConfig fail to load, so these files do not load with an SMS++ whose bundle is the 1.0. The MPBCfg.txt of SVMBlock is the one of the tests of the SVMBlock, which turns the presolve of the master off; the others leave it on, which the masters of the stochastic and investment problems need. + diff --git a/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt b/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt index 4f5f74d..3e80a6f 100644 --- a/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt @@ -61,9 +61,10 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -24 # number of integer parameters +18 # number of integer parameters # now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized intDoEasy 15 # do easy components for (some) LagBFunction intMaxIter 200 # max number of iterations for each call intMaxThread 1 # MaxThread, max number of new tasks to spawn @@ -80,26 +81,12 @@ intMnSSC 0 # min number of consecutive SS with the same t for a t increas intMnNSC 1 # min number of consecutive NS with the same t for a t decrease inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) intMaxNrEvls 2 # maximum number of function evaluations at each iteration -intMPName 15 # MP solver: 0 = QPP, 7 = Cplex/Gurobi with quadratic stabilization - # + 8 = check for duplicate linearizations - -# QPPenalty's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - -intMPlvl 2 # log verbosity of Master Problem -intQPmp1 0 # MxAdd, how many variables can be added to the base at each - # iteration in BMinQuad (0 = at will) -intQPmp2 0 # MxRmv, how many variables can be removed from the base at each - # iteration in BMinQuad (0 = at will) # OSiMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - -intOSImp1 4 # Osi(Cpx/Grb)Solver algorithm (0 = auto (default), - # 1 = primal, 2 = dual, 3 = network, 4 = barrier, - # 5 = sifting, 6 = concurrent) -intOSImp2 1 # pre-processing (reduction) -intOSImp3 1 # threads intRstAlg 2 # parameter to handle the reset of the algorithm #int_InnerS_WVarSCfg 0 # set by sddp_solver with the -z (hydro-easy) option -16 # number of double parameters +15 # number of double parameters # now all the double parameters dblRelAcc 1e-8 # relative accuracy required to solution @@ -117,15 +104,15 @@ dbltMaior 1e+6 # maximum value for t dbltMinor 1e-10 # minimum value for t dbltInit 1e-5 # initial value for t dbltSPar2 1e-2 # parameter for the long-term t-strategy -dblCtOff 0.01 # cut-off factor for pricing in MinQuad -2 # number of string parameters +3 # number of string parameters # now all the string parameters str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver #str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver str_LagBF_BSCfg config/InnerBSCfg.txt # meta BlockSolverConfig for the LagBFunctions, # dispatched by inner Block classname() +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt b/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt index 54ac734..3e8f256 100644 --- a/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt @@ -29,9 +29,10 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -23 # number of integer parameters +17 # number of integer parameters # now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized intDoEasy 15 # do easy components for (some) LagBFunction intMaxIter 10000 # max number of iterations for each call intMaxThread 36 # MaxThread, max number of new tasks to spawn @@ -48,25 +49,11 @@ intMnSSC 0 # min number of consecutive SS with the same t for a t increas intMnNSC 1 # min number of consecutive NS with the same t for a t decrease inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) intMaxNrEvls 2 # maximum number of function evaluations at each iteration -intMPName 15 # MP solver: 0 = QPP, 7 = Cplex/Gurobi with quadratic stabilization - # + 8 = check for duplicate linearizations - -# QPPenalty's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - -intMPlvl 2 # log verbosity of Master Problem -intQPmp1 0 # MxAdd, how many variables can be added to the base at each - # iteration in BMinQuad (0 = at will) -intQPmp2 0 # MxRmv, how many variables can be removed from the base at each - # iteration in BMinQuad (0 = at will) # OSiMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - -intOSImp1 4 # Osi(Cpx/Grb)Solver algorithm (0 = auto (default), - # 1 = primal, 2 = dual, 3 = network, 4 = barrier, - # 5 = sifting, 6 = concurrent) -intOSImp2 1 # pre-processing (reduction) -intOSImp3 1 # threads intRstAlg 2 # parameter to handle the reset of the algorithm -16 # number of double parameters +15 # number of double parameters # now all the double parameters dblRelAcc 1e-4 # relative accuracy required to solution @@ -85,15 +72,14 @@ dbltMinor 1e-10 # minimum value for t dbltInit 1e+0 # initial value for t dbltSPar2 1e-2 # parameter for the long-term t-strategy -dblCtOff 0.01 # cut-off factor for pricing in MinQuad - -2 # number of string parameters +3 # number of string parameters # now all the string parameters str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver #str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver str_LagBF_BSCfg config/InnerBSCfg-sim.txt # meta BlockSolverConfig for the LagBFunctions, # dispatched by inner Block classname() +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/SDDPBlock/MPBCfg.txt b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt new file mode 100644 index 0000000..7c15020 --- /dev/null +++ b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt @@ -0,0 +1,122 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of the +# MasterProblemBlock used by the BundleSolver +# +# Donato Meoli, Antonio Frangioni +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +6 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END MPBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SVMBlock/LDCfg.txt b/pysmspp/data/configs/SVMBlock/LDCfg.txt index 0e149fc..5f7e272 100644 --- a/pysmspp/data/configs/SVMBlock/LDCfg.txt +++ b/pysmspp/data/configs/SVMBlock/LDCfg.txt @@ -15,10 +15,11 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -28 # number of integer parameters +22 # number of integer parameters # now all the integer parameters # first those of LagrangianDualSolver proper +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied int_LDSlv_NNMult 0 # the consensus constraints are equalities, hence # their multipliers are free @@ -53,28 +54,9 @@ intTrgtMng 0 # bit-wise encoding targets and accuracies management: # MPSolver parameters : - - - - - - - - - - - - - - - - - - - - - - - - - - - -intMPName 15 # MP solver: 0 = QPP, 7 = Cplex/Gurobi with quadratic stabilization - # + 8 = check for duplicate linearizations - -# QPPenalty's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - - -intMPlvl 4 # log verbosity of Master Problem - -intQPmp1 0 # MxAdd, how many variables can be added to the base at each - # iteration in BMinQuad (0 = at will) -intQPmp2 0 # MxRmv, how many variables can be removed from the base at each - # iteration in BMinQuad (0 = at will) - -# OSIMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - -intOSImp1 1 # Osi(Cpx/Grb)Solver algorithm (0 = auto (default), - # 1 = primal, 2 = dual, 3 = network, 4 = barrier, - # 5 = sifting, 6 = concurrent) -intOSImp2 3 # pre-processing (reduction) -intOSImp3 1 # threads intRstAlg 2 # parameter to handle the reset of the algorithm -17 # number of double parameters +16 # number of double parameters # now all the double parameters dblRelAcc 1e-7 # relative accuracy required to solution @@ -100,9 +82,8 @@ dbltMinor 1e-4 # minimum value for t dbltInit 1e-2 # initial value for t dbltSPar2 0.001 # parameter for the long-term t-strategy dbltSPar3 0 # parameter for small heuristic t adjustments -dblCtOff 0.01 # cut-off factor for pricing in MinQuad -2 # number of string parameters +3 # number of string parameters # now all the string parameters # first those of LagrangianDualSolver proper @@ -111,6 +92,7 @@ str_LagBF_BSCfg LPBSCfg.txt # the BlockSolverConfig for inner Block # then those of BundleSolver as its inner Solver # [none] +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/SVMBlock/MPBCfg.txt b/pysmspp/data/configs/SVMBlock/MPBCfg.txt new file mode 100644 index 0000000..eeea8a0 --- /dev/null +++ b/pysmspp/data/configs/SVMBlock/MPBCfg.txt @@ -0,0 +1,118 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of +# the MasterProblemBlock used by the BundleSolver +# +# Donato Meoli, Antonio Frangioni +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +7 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 4 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier, 6 = concurrent +#CPXPARAM_Preprocessing_Presolve 0 # disable presolve for reproducibility +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1) +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END MPBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/LPBSCfg-LD.txt b/pysmspp/data/configs/TSSBlock/LPBSCfg-LD.txt index 976bf61..60d07e0 100644 --- a/pysmspp/data/configs/TSSBlock/LPBSCfg-LD.txt +++ b/pysmspp/data/configs/TSSBlock/LPBSCfg-LD.txt @@ -30,9 +30,10 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -24 # number of integer parameters +18 # number of integer parameters # now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized intPushCostToOwner 1 # whether sub-Block Objective are changed intDoEasy 0 # do easy components for (some) LagBFunction intMaxIter 10000 # max number of iterations for each call @@ -49,25 +50,10 @@ intMnSSC 0 # min number of consecutive SS with the same t for a t increas intMnNSC 1 # min number of consecutive NS with the same t for a t decrease inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) intMaxNrEvls 2 # maximum number of function evaluations at each iteration -intMPName 15 # MP solver: 0 = QPP, 7 = Cplex/Gurobi with quadratic stabilization - # + 8 = check for duplicate linearizations -# QPPenalty's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - - -intMPlvl 7 # log verbosity of Master Problem -intQPmp1 0 # MxAdd, how many variables can be added to the base at each - # iteration in BMinQuad (0 = at will) -intQPmp2 0 # MxRmv, how many variables can be removed from the base at each - # iteration in BMinQuad (0 = at will) - -# OSIMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - -intOSImp1 0 # Osi(Cpx/Grb)Solver algorithm (0 = auto (default), 1 = primal, 2 = dual, 3 = network, 4 = barrier, 5 = sifting, 6 = concurrent) -intOSImp2 0 # pre-processing (reduction) -intOSImp3 1 # threads intRstAlg 2 # parameter to handle the reset of the algorithm -16 # number of double parameters +15 # number of double parameters # now all the double parameters dblRelAcc 1e-6 # relative accuracy required to solution @@ -85,15 +71,15 @@ dbltMaior 1e+6 # maximum value for t dbltMinor 1e-10 # minimum value for t dbltInit 1e+1 # initial value for t dbltSPar2 1e-2 # parameter for the long-term t-strategy -dblCtOff 0.01 # cut-off factor for pricing in MinQuad -3 # number of string parameters +4 # number of string parameters # now all the string parameters strLogFileName unit-ld.log # filename for the Solver log #str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver str_LagBF_BSCfg BSCfg.txt # BlockSolverConfig for the LagBFunctions +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/TSSBlock/MPBCfg.txt b/pysmspp/data/configs/TSSBlock/MPBCfg.txt new file mode 100644 index 0000000..7c15020 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/MPBCfg.txt @@ -0,0 +1,122 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of the +# MasterProblemBlock used by the BundleSolver +# +# Donato Meoli, Antonio Frangioni +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +6 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END MPBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD.txt index 08055a6..b952684 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD.txt @@ -29,9 +29,10 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -25 # number of integer parameters +19 # number of integer parameters # now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized intPushCostToOwner 1 # whether sub-Block Objective are changed intDoEasy 0 # do easy components for (some) LagBFunction intMaxIter 10000 # max number of iterations for each call @@ -48,30 +49,15 @@ intMnSSC 0 # min number of consecutive SS with the same t for a t increas intMnNSC 1 # min number of consecutive NS with the same t for a t decrease inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) intMaxNrEvls 2 # maximum number of function evaluations at each iteration -intMPName 15 # MP solver: 0 = QPP, 7 = Cplex/Gurobi with quadratic stabilization - # + 8 = check for duplicate linearizations intTrgtMng 31 # bit-wise encoding targets and accuracies management: # bit 0: if lower/upper target is set to each convex/concave component # bit 1: if upper/lower target is set to each convex/concave component # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) # bit 4: if Lipschitz constant is used to compute the upper model -# QPPenalty's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - - -intMPlvl 7 # log verbosity of Master Problem -intQPmp1 0 # MxAdd, how many variables can be added to the base at each - # iteration in BMinQuad (0 = at will) -intQPmp2 0 # MxRmv, how many variables can be removed from the base at each - # iteration in BMinQuad (0 = at will) - -# OSIMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - - -intOSImp1 0 # Osi(Cpx/Grb)Solver algorithm (0 = auto (default), 1 = primal, 2 = dual, 3 = network, 4 = barrier, 5 = sifting, 6 = concurrent) -intOSImp2 0 # pre-processing (reduction) -intOSImp3 1 # threads intRstAlg 2 # parameter to handle the reset of the algorithm -16 # number of double parameters +15 # number of double parameters # now all the double parameters dblRelAcc 1e-6 # relative accuracy required to solution @@ -89,9 +75,8 @@ dbltMaior 1e+6 # maximum value for t dbltMinor 1e-10 # minimum value for t dbltInit 1e-3 # initial value for t dbltSPar2 1e-2 # parameter for the long-term t-strategy -dblCtOff 0.01 # cut-off factor for pricing in MinQuad -2 # number of string parameters +3 # number of string parameters # now all the string parameters #strLogFileName tssb.log # filename for the Solver log @@ -99,6 +84,7 @@ dblCtOff 0.01 # cut-off factor for pricing in MinQuad str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver #str_LagBF_BSCfg LPBSCfg-LD.txt # BlockSolverConfig for the LagBFunctions str_LagBF_BSCfg BSCfg.txt # BlockSolverConfig for the LagBFunctions +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver 0 # number of vector-of-int parameters From b869624e5ae3bebe22af631944edea1dbe204e85 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sat, 19 Sep 2026 00:54:32 +0200 Subject: [PATCH 02/28] release notes --- docs/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release_notes.md b/docs/release_notes.md index 03d0329..289c743 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -25,6 +25,8 @@ * Give Gurobi, in the `TSSBlock/TSSBSCfg_grb.txt` template, the options PyPSA-Eur gives it (barrier without crossover, a tolerance of 1e-5, no dualization and no fill-in from the aggregation), where it passed none. See [PR #117](https://github.com/SPSUnipi/pySMSpp/pull/117) +* Write the configuration templates that use the BundleSolver for the BundleSolver 2.0, whose master problem is a Block solved by a Solver of its own, configured by the `MPBCfg.txt` now shipped in each of those folders; the parameters of the master of the BundleSolver 1.0 are gone. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) + * Update the shipped `BlockConfig` files to the current format: SMS++ now reads a version number after the differential flag and the structure `Configuration` first, so the shipped file was rejected, with the `-B` option silently having no effect. See [PR #110](https://github.com/SPSUnipi/pySMSpp/pull/110) * Specify local directory when running solvers through `SMSPPSolverTool`: the current working directory is now set to the network directory. See [PR #112](https://github.com/SPSUnipi/pySMSpp/pull/112) From 0f4d4a944d662a4c56e13f83f223ad3bd397fa36 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 21 Sep 2026 04:54:36 +0200 Subject: [PATCH 03/28] the Lagrangian dual of a two-stage stochastic problem can be taken down to its units, by a solver per scenario or by decomposing the whole tree at once, and the two pay on different sizes --- docs/release_notes.md | 2 + pysmspp/data/configs/README.md | 4 +- .../data/configs/TSSBlock/TSSBSCfg-LDLD.txt | 124 +++++++++++++++++ .../data/configs/TSSBlock/TSSBSCfg-LDrec.txt | 125 ++++++++++++++++++ 4 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt diff --git a/docs/release_notes.md b/docs/release_notes.md index 289c743..2595431 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -27,6 +27,8 @@ * Write the configuration templates that use the BundleSolver for the BundleSolver 2.0, whose master problem is a Block solved by a Solver of its own, configured by the `MPBCfg.txt` now shipped in each of those folders; the parameters of the master of the BundleSolver 1.0 are gone. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) +* Add `TSSBlock/TSSBSCfg-LDLD.txt` and `TSSBlock/TSSBSCfg-LDrec.txt`, which take the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a `LagrangianDualSolver` of its own and the second one by decomposing the whole tree at once. They are the same dual written two ways and pay on different sizes, the chain on the scenarios and the recursive one on the units and on the horizon; both need the BundleSolver 2.0. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) + * Update the shipped `BlockConfig` files to the current format: SMS++ now reads a version number after the differential flag and the structure `Configuration` first, so the shipped file was rejected, with the `-B` option silently having no effect. See [PR #110](https://github.com/SPSUnipi/pySMSpp/pull/110) * Specify local directory when running solvers through `SMSPPSolverTool`: the current working directory is now set to the network directory. See [PR #112](https://github.com/SPSUnipi/pySMSpp/pull/112) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 19d1b7a..120e1fe 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -10,5 +10,7 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. -The configurations that use the BundleSolver, i.e., InvestmentBlock/BSPar.txt, SDDPBlock/BSPar-LD.txt, SDDPBlock/BSPar-greedy-LD.txt, SVMBlock/LDCfg.txt, TSSBlock/TSSBSCfg-LD.txt and TSSBlock/LPBSCfg-LD.txt, are written for the BundleSolver 2.0, whose master problem is a Block of its own: `intMPStbl` chooses its stabilization and `strMPBSolverCfg` names the BlockSolverConfig of its Solver, the MPBCfg.txt of the same folder, which solves it with Gurobi. The parameters of the master of the BundleSolver 1.0 (`intMPName`, `intMPlvl`, `intQPmp1`, `intQPmp2`, `intOSImp1`, `intOSImp2`, `intOSImp3`, `dblCtOff`) are gone, and a name the SMS++ at hand does not know makes its whole ComputeConfig fail to load, so these files do not load with an SMS++ whose bundle is the 1.0. The MPBCfg.txt of SVMBlock is the one of the tests of the SVMBlock, which turns the presolve of the master off; the others leave it on, which the masters of the stochastic and investment problems need. +TSSBlock/TSSBSCfg-LDLD.txt and TSSBlock/TSSBSCfg-LDrec.txt solve the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a LagrangianDualSolver of its own (TSSBlock/LPBSCfg-LD.txt), the second one by decomposing the whole tree at once (`intRecursive`). They are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios, where it makes two or three iterations of which each is a whole dual solved inside, and the recursive one pays on the units and on the horizon, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios grow the cost moves onto the master, which the recursive one has much larger. Both need the BundleSolver 2.0. + +The configurations that use the BundleSolver, i.e., InvestmentBlock/BSPar.txt, SDDPBlock/BSPar-LD.txt, SDDPBlock/BSPar-greedy-LD.txt, SVMBlock/LDCfg.txt, TSSBlock/TSSBSCfg-LD.txt, TSSBlock/TSSBSCfg-LDLD.txt, TSSBlock/TSSBSCfg-LDrec.txt and TSSBlock/LPBSCfg-LD.txt, are written for the BundleSolver 2.0, whose master problem is a Block of its own: `intMPStbl` chooses its stabilization and `strMPBSolverCfg` names the BlockSolverConfig of its Solver, the MPBCfg.txt of the same folder, which solves it with Gurobi. The parameters of the master of the BundleSolver 1.0 (`intMPName`, `intMPlvl`, `intQPmp1`, `intQPmp2`, `intOSImp1`, `intOSImp2`, `intOSImp3`, `dblCtOff`) are gone, and a name the SMS++ at hand does not know makes its whole ComputeConfig fail to load, so these files do not load with an SMS++ whose bundle is the 1.0. The MPBCfg.txt of SVMBlock is the one of the tests of the SVMBlock, which turns the presolve of the master off; the others leave it on, which the masters of the stochastic and investment problems need. diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt new file mode 100644 index 0000000..4814e2c --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt @@ -0,0 +1,124 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - TSSBSCfg-LDLD.txt - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for a TSSBlock to be solved by a +# LagrangianDualSolver whose sub-problems are solved by a LagrangianDualSolver +# in turn: the outer dual relaxes the non-anticipativity Constraint, making +# one sub-problem of each scenario, and the inner one relaxes the Constraint +# that tie the units of a scenario together, making one sub-problem of each +# unit. What tells this file from TSSBSCfg-LD.txt, where a scenario goes to a +# :MILPSolver whole, is the BlockSolverConfig it names for the LagBFunctions, +# LPBSCfg-LD.txt instead of BSCfg.txt. +# +# The two ways of decomposing the same tree pay on different sizes: this one +# pays on the scenarios, one sub-problem each, while decomposing the whole +# tree at once [see TSSBSCfg-LDrec.txt] pays on the units and on the horizon. +# +# It needs the BundleSolver 2.0: the 1.0 does not solve a Lagrangian dual +# whose sub-problems are Lagrangian duals in turn. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +LagrangianDualSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +19 # number of integer parameters + +# now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized +intPushCostToOwner 1 # whether sub-Block Objective are changed +intDoEasy 0 # do easy components for (some) LagBFunction +intMaxIter 10000 # max number of iterations for each call +intMaxThread 1 # MaxThread, max number of new tasks to spawn +intLogVerb 7 # log verbosity of main Bundle algorithm +intWZNorm 2 # which norm to use in the norm-based stopping condition +intBPar1 20 # discard items when they have been useless for iterations +intBPar2 100 # max bundle size per component +intBPar3 1 # max n. of items to fetch from Fi() at each iteration +intBPar4 1 # min n. of items to fetch from Fi() at each iteration +intBPar6 0 # second parameter for dynamic max n. of items per iteration +intBPar7 11 # how to deal with the global pools +intMnSSC 0 # min number of consecutive SS with the same t for a t increase +intMnNSC 1 # min number of consecutive NS with the same t for a t decrease +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) +intMaxNrEvls 2 # maximum number of function evaluations at each iteration +intTrgtMng 31 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +intRstAlg 2 # parameter to handle the reset of the algorithm + +15 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-6 # relative accuracy required to solution +dblNZEps 1e-2 # stopping parameter: threshold to declare 0 the || residual || +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dblBPar5 4 # first parameter for dynamic max n. of items per iteration +dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* +dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* +dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || +dblmxIncr 10 # max increase of t +dblmnIncr 1.5 # min increase of t (each time it is increased) +dblmxDecr 0.1 # max decrease of t +dblmnDecr 0.66 # min decrease of t (each time it is decreased) +dbltMaior 1e+6 # maximum value for t +dbltMinor 1e-10 # minimum value for t +dbltInit 1e-3 # initial value for t +dbltSPar2 1e-2 # parameter for the long-term t-strategy + +3 # number of string parameters + +# now all the string parameters +#strLogFileName tssb.log # filename for the Solver log +#str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver +str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver +str_LagBF_BSCfg LPBSCfg-LD.txt # BlockSolverConfig for the LagBFunctions +#str_LagBF_BSCfg BSCfg.txt # BlockSolverConfig for the LagBFunctions +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of 2nd ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - END BSPar.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt new file mode 100644 index 0000000..7c47930 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt @@ -0,0 +1,125 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - TSSBSCfg-LDrec.txt - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for a TSSBlock to be solved by one +# LagrangianDualSolver that decomposes the whole tree instead of its children +# alone: with intRecursive a child that has no Variable and no Objective of +# its own is decomposed in turn, its linking Constraint being relaxed +# together with those of the root, so that the sub-problems are the units of +# every scenario and the multipliers are those of both levels at once. +# +# The chain of two solvers [see TSSBSCfg-LDLD.txt] solves the same dual the +# other way round, one Lagrangian dual per scenario under another, and the +# two pay on different sizes: this one pays on the units and on the horizon, +# where it makes hundreds of iterations whose evaluations cost very little, +# while the chain pays on the scenarios, where it makes two or three +# iterations of which each is a whole dual solved inside. +# +# It needs the BundleSolver 2.0, as the chain does. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +LagrangianDualSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +20 # number of integer parameters + +# now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized +intRecursive 1 # decompose the descendants too, and not the children alone +intPushCostToOwner 1 # whether sub-Block Objective are changed +intDoEasy 0 # do easy components for (some) LagBFunction +intMaxIter 10000 # max number of iterations for each call +intMaxThread 1 # MaxThread, max number of new tasks to spawn +intLogVerb 7 # log verbosity of main Bundle algorithm +intWZNorm 2 # which norm to use in the norm-based stopping condition +intBPar1 20 # discard items when they have been useless for iterations +intBPar2 100 # max bundle size per component +intBPar3 1 # max n. of items to fetch from Fi() at each iteration +intBPar4 1 # min n. of items to fetch from Fi() at each iteration +intBPar6 0 # second parameter for dynamic max n. of items per iteration +intBPar7 11 # how to deal with the global pools +intMnSSC 0 # min number of consecutive SS with the same t for a t increase +intMnNSC 1 # min number of consecutive NS with the same t for a t decrease +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) +intMaxNrEvls 2 # maximum number of function evaluations at each iteration +intTrgtMng 31 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +intRstAlg 2 # parameter to handle the reset of the algorithm + +15 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-6 # relative accuracy required to solution +dblNZEps 1e-2 # stopping parameter: threshold to declare 0 the || residual || +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dblBPar5 4 # first parameter for dynamic max n. of items per iteration +dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* +dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* +dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || +dblmxIncr 10 # max increase of t +dblmnIncr 1.5 # min increase of t (each time it is increased) +dblmxDecr 0.1 # max decrease of t +dblmnDecr 0.66 # min decrease of t (each time it is decreased) +dbltMaior 1e+6 # maximum value for t +dbltMinor 1e-10 # minimum value for t +dbltInit 1e-3 # initial value for t +dbltSPar2 1e-2 # parameter for the long-term t-strategy + +3 # number of string parameters + +# now all the string parameters +#strLogFileName tssb.log # filename for the Solver log +#str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver +str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver +#str_LagBF_BSCfg LPBSCfg-LD.txt # BlockSolverConfig for the LagBFunctions +str_LagBF_BSCfg BSCfg.txt # BlockSolverConfig for the LagBFunctions +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of 2nd ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - END BSPar.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 3cf6936841f4cbbaf6097ed3911085d79f6fcd6d Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 21 Sep 2026 05:10:26 +0200 Subject: [PATCH 04/28] a template for the BendersDecompositionSolver on the Benders form of a two-stage stochastic problem, in the version that is fastest on the TSSB instances of pypsa2smspp --- pysmspp/data/configs/README.md | 4 +- pysmspp/data/configs/TSSBlock/BDSMCfg.txt | 74 +++++++++++++++ pysmspp/data/configs/TSSBlock/BDSSCfg.txt | 91 +++++++++++++++++++ .../data/configs/TSSBlock/TSSBSCfg-BDS.txt | 77 ++++++++++++++++ 4 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 pysmspp/data/configs/TSSBlock/BDSMCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/BDSSCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 120e1fe..cce0fa4 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -10,7 +10,9 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. -TSSBlock/TSSBSCfg-LDLD.txt and TSSBlock/TSSBSCfg-LDrec.txt solve the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a LagrangianDualSolver of its own (TSSBlock/LPBSCfg-LD.txt), the second one by decomposing the whole tree at once (`intRecursive`). They are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios, where it makes two or three iterations of which each is a whole dual solved inside, and the recursive one pays on the units and on the horizon, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios grow the cost moves onto the master, which the recursive one has much larger. Both need the BundleSolver 2.0. +TSSBlock/TSSBSCfg-LDLD.txt and TSSBlock/TSSBSCfg-LDrec.txt solve the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a LagrangianDualSolver of its own (TSSBlock/LPBSCfg-LD.txt), the second one by decomposing the whole tree at once (`intRecursive`). They are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios and on horizons of a month, where it makes a few iterations (from 2 to a few dozen) of which each is a whole dual solved inside, and the recursive one pays on the units and on horizons up to 2 weeks, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios or the periods grow the cost moves onto the master, which the recursive one has much larger. Both need the BundleSolver 2.0. + +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver in the MILP regime, with one optimality cut per scenario, its master and its subproblems being configured by TSSBlock/BDSMCfg.txt and TSSBlock/BDSSCfg.txt (Gurobi, the subproblems with the presolve off, which a Farkas certificate needs). It applies to the Benders form of a two-stage stochastic problem, i.e., a root with a single copy of the here-and-now Variable and one sub-Block per scenario coupled to it by Constraint of the scenario, and not to the extensive form of a TSSBlock that pypsa2smspp writes; no tool builds that form from a netCDF file yet. The configurations that use the BundleSolver, i.e., InvestmentBlock/BSPar.txt, SDDPBlock/BSPar-LD.txt, SDDPBlock/BSPar-greedy-LD.txt, SVMBlock/LDCfg.txt, TSSBlock/TSSBSCfg-LD.txt, TSSBlock/TSSBSCfg-LDLD.txt, TSSBlock/TSSBSCfg-LDrec.txt and TSSBlock/LPBSCfg-LD.txt, are written for the BundleSolver 2.0, whose master problem is a Block of its own: `intMPStbl` chooses its stabilization and `strMPBSolverCfg` names the BlockSolverConfig of its Solver, the MPBCfg.txt of the same folder, which solves it with Gurobi. The parameters of the master of the BundleSolver 1.0 (`intMPName`, `intMPlvl`, `intQPmp1`, `intQPmp2`, `intOSImp1`, `intOSImp2`, `intOSImp3`, `dblCtOff`) are gone, and a name the SMS++ at hand does not know makes its whole ComputeConfig fail to load, so these files do not load with an SMS++ whose bundle is the 1.0. The MPBCfg.txt of SVMBlock is the one of the tests of the SVMBlock, which turns the presolve of the master off; the others leave it on, which the masters of the stochastic and investment problems need. diff --git a/pysmspp/data/configs/TSSBlock/BDSMCfg.txt b/pysmspp/data/configs/TSSBlock/BDSMCfg.txt new file mode 100644 index 0000000..8d549bd --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSMCfg.txt @@ -0,0 +1,74 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BDSMCfg.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the master problem of the +# Benders decomposition of TSSBSCfg-BDS.txt, in the MILP regime: a single +# :MILPSolver that solves the master (with the epigraph Variable and the +# dynamically added Benders cuts) at each round of the cut loop. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +GRBMILPSolver # name of Solver +#CPXMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +0 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +2 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # LogVerb, log verbosity of the MILPSolver +Threads 1 # one thread, so that the time is that of a sequential + # algorithm, as every other one here is + +1 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-9 # relative accuracy required to solution + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BDSMCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSSCfg.txt b/pysmspp/data/configs/TSSBlock/BDSSCfg.txt new file mode 100644 index 0000000..f6eadc2 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSSCfg.txt @@ -0,0 +1,91 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BDSSCfg.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the subproblem of one Benders +# component of TSSBSCfg-BDS.txt, i.e., the linear program whose value function +# is being approximated, and whose duals are the Benders cuts. +# +# Two things are asked of the Solver beyond solving it, and only the second +# constrains how it is solved: +# +# - the duals of an optimal solution, which give the optimality cut: any +# optimal dual solution does, basic or not, an interior-point one included; +# +# - the unbounded dual direction of an infeasible one, i.e., a Farkas +# certificate, which gives the feasibility cut: it is a ray of the dual +# polyhedron, hence any method can produce it, but the presolve cannot, it +# detecting the infeasibility on the reduced problem and leaving no +# certificate for the original one. +# +# With Gurobi nothing else is needed, the InfUnbdInfo parameter being set by +# GRBMILPSolver itself; the equivalent configurations are +# +# CPXMILPSolver: CPXPARAM_Preprocessing_Presolve 0 +# HiGHSMILPSolver: presolve off +# +# while SCIPMILPSolver has no Farkas certificate at all: with it, only +# subproblems that are always feasible can be dealt with. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +GRBMILPSolver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - +ComputeConfig # exact type of the ComputeConfig object + +0 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +5 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # LogVerb, log verbosity of the MILPSolver +Threads 1 # one thread, so that the time is that of a sequential + # algorithm, as every other one here is +intRelaxIntVars 1 # solve the continuous (LP) relaxation +Method 1 # dual simplex: asked for reproducibility of the duals, + # any optimal ones giving a valid optimality cut +Presolve 0 # off, or an infeasible subproblem leaves no Farkas + # certificate and no feasibility cut can be generated + +1 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-9 # relative accuracy required to solution + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BDSSCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt new file mode 100644 index 0000000..5c63ff6 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt @@ -0,0 +1,77 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - TSSBSCfg-BDS.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for a Block having a single +# BendersDecompositionSolver attached, in the MILP regime, with one optimality +# cut per scenario (multi-cut), which is the fastest of the options of the +# Solver on the TSSB instances of pypsa2smspp. The master and the subproblems +# are configured by BDSMCfg.txt and BDSSCfg.txt. +# +# It applies to the Benders form of a two-stage stochastic problem, i.e., a +# root with a single copy of the here-and-now Variable, one sub-Block per +# scenario, and the coupling written as Constraint of each scenario in which +# those Variable appear linearly; this is not the extensive form of a TSSBlock +# that pypsa2smspp writes, and no tool builds it from a netCDF file yet. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BendersDecompositionSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +0 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +1 # number of integer parameters + +# now all the integer parameters +int_BDSlv_Regime 1 # 0 = convex master, 1 = MILP master + +0 # number of double parameters + +# now all the double parameters +# [none] + +2 # number of string parameters + +# now all the string parameters +str_Bsub_BSCfg BDSSCfg.txt # BlockSolverConfig of the subproblems +str_Mstr_BSCfg BDSMCfg.txt # BlockSolverConfig of the master + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - END TSSBSCfg-BDS.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 079b5b35d14323cc8902e8363e12850f65a51184 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 21 Sep 2026 12:18:23 +0200 Subject: [PATCH 05/28] the template of the BendersDecompositionSolver evaluates the subproblems of a round by 8 threads --- pysmspp/data/configs/README.md | 2 +- pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index cce0fa4..659a0ea 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -12,7 +12,7 @@ The template configuration option for OSolCfg.txt allows to extract the most inf TSSBlock/TSSBSCfg-LDLD.txt and TSSBlock/TSSBSCfg-LDrec.txt solve the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a LagrangianDualSolver of its own (TSSBlock/LPBSCfg-LD.txt), the second one by decomposing the whole tree at once (`intRecursive`). They are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios and on horizons of a month, where it makes a few iterations (from 2 to a few dozen) of which each is a whole dual solved inside, and the recursive one pays on the units and on horizons up to 2 weeks, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios or the periods grow the cost moves onto the master, which the recursive one has much larger. Both need the BundleSolver 2.0. -TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver in the MILP regime, with one optimality cut per scenario, its master and its subproblems being configured by TSSBlock/BDSMCfg.txt and TSSBlock/BDSSCfg.txt (Gurobi, the subproblems with the presolve off, which a Farkas certificate needs). It applies to the Benders form of a two-stage stochastic problem, i.e., a root with a single copy of the here-and-now Variable and one sub-Block per scenario coupled to it by Constraint of the scenario, and not to the extensive form of a TSSBlock that pypsa2smspp writes; no tool builds that form from a netCDF file yet. +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver in the MILP regime, with one optimality cut per scenario and the scenarios of a round evaluated by 8 threads (`int_BDSlv_MaxThread`, which changes the time and not the run), its master and its subproblems being configured by TSSBlock/BDSMCfg.txt and TSSBlock/BDSSCfg.txt (Gurobi, the subproblems with the presolve off, which a Farkas certificate needs). It applies to the Benders form of a two-stage stochastic problem, i.e., a root with a single copy of the here-and-now Variable and one sub-Block per scenario coupled to it by Constraint of the scenario, and not to the extensive form of a TSSBlock that pypsa2smspp writes; no tool builds that form from a netCDF file yet. The configurations that use the BundleSolver, i.e., InvestmentBlock/BSPar.txt, SDDPBlock/BSPar-LD.txt, SDDPBlock/BSPar-greedy-LD.txt, SVMBlock/LDCfg.txt, TSSBlock/TSSBSCfg-LD.txt, TSSBlock/TSSBSCfg-LDLD.txt, TSSBlock/TSSBSCfg-LDrec.txt and TSSBlock/LPBSCfg-LD.txt, are written for the BundleSolver 2.0, whose master problem is a Block of its own: `intMPStbl` chooses its stabilization and `strMPBSolverCfg` names the BlockSolverConfig of its Solver, the MPBCfg.txt of the same folder, which solves it with Gurobi. The parameters of the master of the BundleSolver 1.0 (`intMPName`, `intMPlvl`, `intQPmp1`, `intQPmp2`, `intOSImp1`, `intOSImp2`, `intOSImp3`, `dblCtOff`) are gone, and a name the SMS++ at hand does not know makes its whole ComputeConfig fail to load, so these files do not load with an SMS++ whose bundle is the 1.0. The MPBCfg.txt of SVMBlock is the one of the tests of the SVMBlock, which turns the presolve of the master off; the others leave it on, which the masters of the stochastic and investment problems need. diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt index 5c63ff6..979409f 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt @@ -5,7 +5,8 @@ # BendersDecompositionSolver attached, in the MILP regime, with one optimality # cut per scenario (multi-cut), which is the fastest of the options of the # Solver on the TSSB instances of pypsa2smspp. The master and the subproblems -# are configured by BDSMCfg.txt and BDSSCfg.txt. +# are configured by BDSMCfg.txt and BDSSCfg.txt, and the subproblems of a +# round are evaluated by several threads. # # It applies to the Benders form of a two-stage stochastic problem, i.e., a # root with a single copy of the here-and-now Variable, one sub-Block per @@ -34,10 +35,14 @@ ComputeConfig # exact type of the ComputeConfig object 0 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -1 # number of integer parameters +2 # number of integer parameters # now all the integer parameters -int_BDSlv_Regime 1 # 0 = convex master, 1 = MILP master +int_BDSlv_Regime 1 # 0 = convex master, 1 = MILP master +int_BDSlv_MaxThread 8 # threads evaluating the subproblems of a round, at + # most the cores of the machine; the run is the same + # for every value, only faster, and 1 evaluates them + # one after the other 0 # number of double parameters From f09970ce12febb8ac1fb959970696193eb3ca052 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 21 Sep 2026 12:47:28 +0200 Subject: [PATCH 06/28] the template of the BendersDecompositionSolver says that tssb_solver -k assembles the form it applies to --- pysmspp/data/configs/README.md | 2 +- pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 659a0ea..dba3ab5 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -12,7 +12,7 @@ The template configuration option for OSolCfg.txt allows to extract the most inf TSSBlock/TSSBSCfg-LDLD.txt and TSSBlock/TSSBSCfg-LDrec.txt solve the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a LagrangianDualSolver of its own (TSSBlock/LPBSCfg-LD.txt), the second one by decomposing the whole tree at once (`intRecursive`). They are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios and on horizons of a month, where it makes a few iterations (from 2 to a few dozen) of which each is a whole dual solved inside, and the recursive one pays on the units and on horizons up to 2 weeks, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios or the periods grow the cost moves onto the master, which the recursive one has much larger. Both need the BundleSolver 2.0. -TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver in the MILP regime, with one optimality cut per scenario and the scenarios of a round evaluated by 8 threads (`int_BDSlv_MaxThread`, which changes the time and not the run), its master and its subproblems being configured by TSSBlock/BDSMCfg.txt and TSSBlock/BDSSCfg.txt (Gurobi, the subproblems with the presolve off, which a Farkas certificate needs). It applies to the Benders form of a two-stage stochastic problem, i.e., a root with a single copy of the here-and-now Variable and one sub-Block per scenario coupled to it by Constraint of the scenario, and not to the extensive form of a TSSBlock that pypsa2smspp writes; no tool builds that form from a netCDF file yet. +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver in the MILP regime, with one optimality cut per scenario and the scenarios of a round evaluated by 8 threads (`int_BDSlv_MaxThread`, which changes the time and not the run), its master and its subproblems being configured by TSSBlock/BDSMCfg.txt and TSSBlock/BDSSCfg.txt (Gurobi, the subproblems with the presolve off, which a Farkas certificate needs). It applies to the Benders form of a two-stage stochastic problem, i.e., a root with a single copy of the here-and-now Variable and one sub-Block per scenario coupled to it by Constraint of the scenario, which tssb_solver assembles around the extensive form of a TSSBlock when it is given -k (in pySMSpp, `TSSBSolver(..., k=None)`). The configurations that use the BundleSolver, i.e., InvestmentBlock/BSPar.txt, SDDPBlock/BSPar-LD.txt, SDDPBlock/BSPar-greedy-LD.txt, SVMBlock/LDCfg.txt, TSSBlock/TSSBSCfg-LD.txt, TSSBlock/TSSBSCfg-LDLD.txt, TSSBlock/TSSBSCfg-LDrec.txt and TSSBlock/LPBSCfg-LD.txt, are written for the BundleSolver 2.0, whose master problem is a Block of its own: `intMPStbl` chooses its stabilization and `strMPBSolverCfg` names the BlockSolverConfig of its Solver, the MPBCfg.txt of the same folder, which solves it with Gurobi. The parameters of the master of the BundleSolver 1.0 (`intMPName`, `intMPlvl`, `intQPmp1`, `intQPmp2`, `intOSImp1`, `intOSImp2`, `intOSImp3`, `dblCtOff`) are gone, and a name the SMS++ at hand does not know makes its whole ComputeConfig fail to load, so these files do not load with an SMS++ whose bundle is the 1.0. The MPBCfg.txt of SVMBlock is the one of the tests of the SVMBlock, which turns the presolve of the master off; the others leave it on, which the masters of the stochastic and investment problems need. diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt index 979409f..0fe4945 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt @@ -11,8 +11,9 @@ # It applies to the Benders form of a two-stage stochastic problem, i.e., a # root with a single copy of the here-and-now Variable, one sub-Block per # scenario, and the coupling written as Constraint of each scenario in which -# those Variable appear linearly; this is not the extensive form of a TSSBlock -# that pypsa2smspp writes, and no tool builds it from a netCDF file yet. +# those Variable appear linearly, which tssb_solver assembles around the +# extensive form of a TSSBlock when it is given -k (in pySMSpp, the argument +# k=None of TSSBSolver). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 79a6b74a529bf6c74836f43426b7f851cbac6b62 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 21 Sep 2026 14:39:26 +0200 Subject: [PATCH 07/28] the templates of the thermal family are the configurations the comparison with PyPSA was measured with: the MILP, the dual of the scenarios, the chain of two duals and the recursive dual, with their BlockConfig --- pysmspp/data/configs/README.md | 2 +- pysmspp/data/configs/TSSBlock/ACBCfg.txt | 59 +++++++ pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt | 78 ++++++++++ pysmspp/data/configs/TSSBlock/BSCfg1.txt | 76 +++++++++ pysmspp/data/configs/TSSBlock/DCNBCfg.txt | 51 ++++++ pysmspp/data/configs/TSSBlock/InnerBCfg.txt | 32 ++++ .../data/configs/TSSBlock/InnerBSCfg-IP.txt | 32 ++++ pysmspp/data/configs/TSSBlock/InnerBSCfg.txt | 32 ++++ pysmspp/data/configs/TSSBlock/LDCfg.txt | 84 ++++++++++ .../data/configs/TSSBlock/LPBSCfg-LDLD.txt | 80 ++++++++++ pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt | 51 ++++++ pysmspp/data/configs/TSSBlock/PFBCfg.txt | 51 ++++++ pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt | 37 +++++ .../data/configs/TSSBlock/TSSBSCfg-LD-IP.txt | 71 +++++++++ .../data/configs/TSSBlock/TSSBSCfg-LDLD.txt | 137 ++++++----------- .../data/configs/TSSBlock/TSSBSCfg-LDrec.txt | 145 +++++++----------- pysmspp/data/configs/TSSBlock/TUBCfg.txt | 61 ++++++++ pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt | 61 ++++++++ 18 files changed, 958 insertions(+), 182 deletions(-) create mode 100644 pysmspp/data/configs/TSSBlock/ACBCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt create mode 100644 pysmspp/data/configs/TSSBlock/BSCfg1.txt create mode 100644 pysmspp/data/configs/TSSBlock/DCNBCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/InnerBCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt create mode 100644 pysmspp/data/configs/TSSBlock/InnerBSCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/LDCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt create mode 100644 pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt create mode 100644 pysmspp/data/configs/TSSBlock/PFBCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt create mode 100644 pysmspp/data/configs/TSSBlock/TUBCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index dba3ab5..55b96b6 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -10,7 +10,7 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. -TSSBlock/TSSBSCfg-LDLD.txt and TSSBlock/TSSBSCfg-LDrec.txt solve the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a LagrangianDualSolver of its own (TSSBlock/LPBSCfg-LD.txt), the second one by decomposing the whole tree at once (`intRecursive`). They are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios and on horizons of a month, where it makes a few iterations (from 2 to a few dozen) of which each is a whole dual solved inside, and the recursive one pays on the units and on horizons up to 2 weeks, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios or the periods grow the cost moves onto the master, which the recursive one has much larger. Both need the BundleSolver 2.0. +The family of two-stage instances whose scenario is a unit commitment (the thermal instances of pypsa2smspp) has its own templates in TSSBlock/, all to be used with the BlockConfig TSSBlock/InnerBCfg.txt (option -B of tssb_solver, i.e., `B="InnerBCfg.txt"` of TSSBSolver): TSSBSCfg-IP.txt solves the deterministic equivalent with a :MILPSolver and its integer Variable (MILPCfg-IP.txt, relative gap 1e-6), TSSBSCfg-LD-IP.txt takes the Lagrangian dual of the non-anticipativity Constraint with each scenario solved whole by a :MILPSolver, and TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt take the dual down to the units, the first one by giving each scenario a LagrangianDualSolver of its own (LPBSCfg-LDLD.txt), the second one, the recursive Lagrangian dual, by decomposing the whole tree at once (`intRecursive`), each thermal unit being solved by its dynamic programming (InnerBSCfg.txt, TUBSCfg-DP.txt). They all load LDCfg.txt and change a few of its parameters. The two duals down to the units are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios and on horizons of a month, where it makes a few iterations (from 2 to a few dozen) of which each is a whole dual solved inside, and the recursive Lagrangian dual pays on the units and on horizons up to 2 weeks, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios or the periods grow the cost moves onto the master, which the recursive one has much larger. A Lagrangian dual gives a bound; option -R of tssb_solver, e.g., `-R BSCfg1-IP.txt`, recovers a feasible solution from it by fixing the design to its mean over the scenarios and solving each scenario alone. The duals need the BundleSolver 2.0. TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver in the MILP regime, with one optimality cut per scenario and the scenarios of a round evaluated by 8 threads (`int_BDSlv_MaxThread`, which changes the time and not the run), its master and its subproblems being configured by TSSBlock/BDSMCfg.txt and TSSBlock/BDSSCfg.txt (Gurobi, the subproblems with the presolve off, which a Farkas certificate needs). It applies to the Benders form of a two-stage stochastic problem, i.e., a root with a single copy of the here-and-now Variable and one sub-Block per scenario coupled to it by Constraint of the scenario, which tssb_solver assembles around the extensive form of a TSSBlock when it is given -k (in pySMSpp, `TSSBSolver(..., k=None)`). diff --git a/pysmspp/data/configs/TSSBlock/ACBCfg.txt b/pysmspp/data/configs/TSSBlock/ACBCfg.txt new file mode 100644 index 0000000..a014004 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/ACBCfg.txt @@ -0,0 +1,59 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - ACBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockConfig for all the NetworkBlock of a UCBlock +# +# + +# exact type of the Configuration object +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockConfig + +1 # the BlockConfig is differential + +2 # version of the BlockConfig format + +# the Configuration for the structure, i.e., the tree of sub-Block +* # [none] + +# static constraints Configuration +# a SimpleConfiguration< std::vector< double > > to set +# the scaling constants in ACNetworkBlock +# exact type of the Configuration object +SimpleConfiguration> +4 # the number of elements in the vector +1.0 # C_v_scal +0.0 # f_ACvS +1.0 # f_scale +16 # f_digits + +# dynamic constraints Configuration +* # none + +# static variables Configuration +* # none + +# dynamic variables Configuration +* # none + +# objective Configuration +* # none + +# is_feasible Configuration +* # none + +# is_optimal Configuration +* # none + +# solution Configuration +* # none + +# extra Configuration +* # none + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END ACBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt b/pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt new file mode 100644 index 0000000..efbf812 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt @@ -0,0 +1,78 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BSCfg1-IP.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for any Block that is a simple +# MILP / MIQP / MIQCQP and can be solved by a :MILPSolver +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +2 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 0 # nonzero if the continuous relaxation is solved + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_Preprocessing_Presolve 0 # 0 = off, 1 = on (default) + # disable presolve for reproducibility +#CPXPARAM_Emphasis_Numerical 1 # 0 = off (default), 1 = extreme numerical caution + +# All specific GUROBI parameter (uncomment based on Solver) +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1) + # the scenario MILP keeps the presolve it is given: switching + # it off is a handicap, and this Solver is a competitor here +#NumericFocus 3 # 0 = auto (default), 1..3 = increasing precision focus + +1 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-8 # relative accuracy required to solution + +0 # number of string parameters + +# now all the string parameters +#strOutputFile uc.lp # filename for .lp file +#strLogFileName uc-milp.log # filename for the Solver log + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BSCfg1-IP.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BSCfg1.txt b/pysmspp/data/configs/TSSBlock/BSCfg1.txt new file mode 100644 index 0000000..2049d54 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BSCfg1.txt @@ -0,0 +1,76 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BSCfg1.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for any Block that is a simple +# MILP / MIQP / MIQCQP and can be solved by a :MILPSolver +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +4 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_Preprocessing_Presolve 0 # 0 = off, 1 = on (default) + # disable presolve for reproducibility +#CPXPARAM_Emphasis_Numerical 1 # 0 = off (default), 1 = extreme numerical caution + +# All specific GUROBI parameter (uncomment based on Solver) +Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1) +NumericFocus 3 # 0 = auto (default), 1..3 = increasing precision focus + +1 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-8 # relative accuracy required to solution + +0 # number of string parameters + +# now all the string parameters +#strOutputFile uc.lp # filename for .lp file +#strLogFileName uc-milp.log # filename for the Solver log + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BSCfg1.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/DCNBCfg.txt b/pysmspp/data/configs/TSSBlock/DCNBCfg.txt new file mode 100644 index 0000000..2c672d1 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/DCNBCfg.txt @@ -0,0 +1,51 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - DCNBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockConfig for all the DCNetworkBlock of a UCBlock, +# selecting the network formulation (read by DCNetworkBlock::generate_abstract_ +# variables). A no-op on instances without a DCNetworkBlock. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockConfig # exact type of the Configuration object + +1 # the BlockConfig is a "differential" one + +2 # version of the BlockConfig format + +# the Configuration for the structure, i.e., the tree of sub-Block +* # [none] + +# static constraints Configuration +* # [none] + +# dynamic constraints Configuration +* # [none] + +# static variables Configuration +# a SimpleConfiguration< int > selecting the network formulation +SimpleConfiguration +2 # 0 = PTDF, 1 = CYCLE, 2 = KIRCHHOFF + +# dynamic variables Configuration +* # [none] + +# objective Configuration +* # [none] + +# is_feasible Configuration +* # [none] + +# is_optimal Configuration +* # [none] + +# solution Configuration +* # [none] + +# extra Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END DCNBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBCfg.txt b/pysmspp/data/configs/TSSBlock/InnerBCfg.txt new file mode 100644 index 0000000..fac80f1 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/InnerBCfg.txt @@ -0,0 +1,32 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - InnerBCfg.txt - - - - - - - - - - - - - - - - +# +# A "meta"-BlockConfig: a map from a Block classname() to the BlockConfig to +# apply to every sub-Block of that class. b_config_Block() dispatches it by +# classname over the whole Block tree, so it configures the inner sub-Blocks +# that sit deep inside each scenario's UCBlock regardless of where they sit: +# +# ThermalUnitBlock -> its formulation / P-C parameters (TUBCfg.txt) +# DCNetworkBlock -> its formulation selector (DCNBCfg.txt) +# ACNetworkBlock -> its scaling factors (ACBCfg.txt) +# PolyhedralFunctionBlock -> its "linearized" representation (PFBCfg.txt) +# +# + +# a "meta"-BlockConfig , i.e., a map classname --> its BlockConfig +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +SimpleConfiguration> + +4 # the number of elements in the map + +ThermalUnitBlock *TUBCfg.txt +DCNetworkBlock *DCNBCfg.txt +ACNetworkBlock *ACBCfg.txt +PolyhedralFunctionBlock *PFBCfg.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END InnerBCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt b/pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt new file mode 100644 index 0000000..b0c43b2 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt @@ -0,0 +1,32 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - InnerBSCfg-IP.txt - - - - - - - - - - - - - - - +# +# A "meta"-BlockSolverConfig: a map from a Block classname() to the +# BlockSolverConfig to attach to every sub-Block of that class. s_config_Block() +# dispatches it by classname over the WHOLE Block tree, so it reaches the +# ThermalUnitBlock that sit deep inside each scenario's UCBlock and attaches the +# efficient ThermalUnitExtDPSolver to them: +# +# ThermalUnitBlock -> TUBSCfg-DP.txt (ThermalUnitExtDPSolver, integer) +# * (catch-all) -> BSCfg1-IP.txt (every other "hard" inner unit) +# +# The "*" entry is the default applied to any inner Block whose classname() is +# not listed explicitly (BatteryUnitBlock, IntermittentUnitBlock, ...). +# +# + +# a "meta"-BlockConfig , i.e., a map classname --> its BlockConfig +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +SimpleConfiguration> + +2 # the number of elements in the map + +ThermalUnitBlock *TUBSCfg-DP.txt +* *BSCfg1-IP.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END InnerBSCfg-IP.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBSCfg.txt b/pysmspp/data/configs/TSSBlock/InnerBSCfg.txt new file mode 100644 index 0000000..d21f1ba --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/InnerBSCfg.txt @@ -0,0 +1,32 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - InnerBSCfg.txt - - - - - - - - - - - - - - - - +# +# A "meta"-BlockSolverConfig: a map from a Block classname() to the +# BlockSolverConfig to attach to every sub-Block of that class. s_config_Block() +# dispatches it by classname over the WHOLE Block tree, so it reaches the +# ThermalUnitBlock that sit deep inside each scenario's UCBlock and attaches the +# efficient ThermalUnitExtDPSolver to them: +# +# ThermalUnitBlock -> TUBSCfg-DP.txt (ThermalUnitExtDPSolver, integer) +# * (catch-all) -> BSCfg1.txt (every other "hard" inner unit) +# +# The "*" entry is the default applied to any inner Block whose classname() is +# not listed explicitly (BatteryUnitBlock, IntermittentUnitBlock, ...). +# +# + +# a "meta"-BlockConfig , i.e., a map classname --> its BlockConfig +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +SimpleConfiguration> + +2 # the number of elements in the map + +ThermalUnitBlock *TUBSCfg-DP.txt +* *BSCfg1.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END InnerBSCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/LDCfg.txt b/pysmspp/data/configs/TSSBlock/LDCfg.txt new file mode 100644 index 0000000..864aa0e --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/LDCfg.txt @@ -0,0 +1,84 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - LDCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of the ComputeConfig of a LagrangianDualSolver with a +# BundleSolver 2.0 as the inner Solver, which the templates of the thermal +# family load and change in a few parameters (*LDCfg.txt +). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +16 # number of integer parameters + +# now all the integer parameters +intPushCostToOwner 1 # whether sub-Block Objective are changed +intDoEasy 0 # do easy components for (some) LagBFunction +intMaxIter 10000 # max number of iterations for each call +intMaxThread 1 # MaxThread, max number of new tasks to spawn +intLogVerb 4 # log verbosity of main Bundle algorithm +intWZNorm 2 # which norm to use in the norm-based stopping condition +intBPar1 20 # discard items when they have been useless for iterations +intBPar2 100 # max bundle size per component +intBPar3 1 # max n. of items to fetch from Fi() at each iteration +intBPar4 1 # min n. of items to fetch from Fi() at each iteration +intBPar6 0 # second parameter for dynamic max n. of items per iteration +intBPar7 11 # how to deal with the global pools +intMnSSC 0 # min number of consecutive SS with the same t for a t increase +intMnNSC 1 # min number of consecutive NS with the same t for a t decrease +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) +intMaxNrEvls 2 # maximum number of function evaluations at each iteration + +15 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-6 # relative accuracy required to solution +dblNZEps 1e-2 # stopping parameter: threshold to declare 0 the || residual || +dbltStar -1e+3 # stopping parameter: multiplied to || residual || to estimate gap +dblBPar5 4 # first parameter for dynamic max n. of items per iteration +dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* +dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* +dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || +dblmxIncr 10 # max increase of t +dblmnIncr 1.5 # min increase of t (each time it is increased) +dblmxDecr 0.1 # max decrease of t +dblmnDecr 0.66 # min decrease of t (each time it is decreased) +dbltMaior 1e+6 # maximum value for t +dbltMinor 1e-10 # minimum value for t +dbltInit 1e+1 # initial value for t +dbltSPar2 1e-2 # parameter for the long-term t-strategy + +3 # number of string parameters + +# now all the string parameters +str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver +str_LagBF_BSCfg InnerBSCfg.txt # BlockSolverConfig for the LagBFunctions +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END LDCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt b/pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt new file mode 100644 index 0000000..8e810b1 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt @@ -0,0 +1,80 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - LPBSCfg-LDLD.txt - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for a scenario of a TSSBlock solved +# by a LagrangianDualSolver that relaxes the Constraint tying its units +# together, each thermal unit being solved by its dynamic programming +# (InnerBSCfg.txt). The cap on the iterations is not binding, the dual stopping +# on its own criterion, and it has not to be tuned per instance: its multipliers +# grow with the horizon, and a cap tuned on a short one makes the bound of the +# chain collapse on a long one. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +LagrangianDualSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +3 # number of integer parameters + +# now all the integer parameters +intDoEasy 3 # do easy components for (some) LagBFunction + # (bit 0 + bit 1 = enable easy + ChgCosts) +intMaxIter 1000 # max number of iterations for each call: the cap is not + # binding, the inner dual stops on its own criteria first, + # and it must not be lowered to go faster. The 100 of + # LPBSCfg-LD.txt is tuned on a 24 to 48 period horizon: on + # 40 units over 96 periods it stops the inner duals far + # from their optimum and the bound of the nested dual falls + # to -0.482% of the optimum, against -0.075% with 1000, + # which is 7.4 seconds against 20.5 +intLogVerb 0 # log verbosity of main Bundle algorithm + +2 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-4 # relative accuracy required to solution +dbltInit 1e+0 # initial value for t + +1 # number of string parameters + +# now all the string parameters +str_LagBF_BSCfg InnerBSCfg.txt # BlockSolverConfig for the LagBFunctions + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END LPBSCfg-LDLD.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt new file mode 100644 index 0000000..3747f91 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt @@ -0,0 +1,51 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - MILPCfg-IP.txt - - - - - - - - - - - - - - - - +# +# A txt description of a ComputeConfig for a :MILPSolver solving the +# deterministic equivalent of a TSSBlock with its integer Variable, to a +# relative gap of 1e-6 and within one hour. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +3 # number of integer parameters + +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 0 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints + +2 # number of double parameters + +dblRelAcc 1e-6 # relative accuracy required to solution +dblMaxTime 3600 # maximum time for a call + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END MILPCfg-IP.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/PFBCfg.txt b/pysmspp/data/configs/TSSBlock/PFBCfg.txt new file mode 100644 index 0000000..21a0e40 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/PFBCfg.txt @@ -0,0 +1,51 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - PFBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of the BlockConfig for a PolyhedralFunctionBlock: the +# "linearized" representation of the PolyhedralFunction is used (static +# variables Configuration == 1), plus the is_feasible() tolerances. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockConfig # exact type of the Configuration object + +1 # the BlockConfig is a "differential" one + +2 # version of the BlockConfig format + +# the Configuration for the structure, i.e., the tree of sub-Block +* # [none] + +# static_constraints +* # [none] + +# dynamic_constraints +* # [none] + +# static_variables +SimpleConfiguration +1 # use the "linearized" representation of the PolyhedralFunction + +# dynamic_variables +* # [none] + +# objective +* # [none] + +# is_feasible +SimpleConfiguration> +1e-6 1 # feasibility tolerance, relative violation + +# is_optimal +* # [none] + +# solution +* # [none] + +# extra +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END PFBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt new file mode 100644 index 0000000..08b4fe4 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt @@ -0,0 +1,37 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - TSSBSCfg-IP.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for a TSSBlock solved whole by a +# :MILPSolver, i.e., its deterministic equivalent with the integer Variable as +# they are, configured by MILPCfg-IP.txt. It is the monolithic reference of the +# decompositions of the family of thermal instances (TSSBSCfg-LD-IP.txt, +# TSSBSCfg-LDLD.txt, TSSBSCfg-LDrec.txt), to be used with the BlockConfig +# InnerBCfg.txt (-B). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of 1st Solver +GRBMILPSolver # name of 1st Solver +#SCIPMILPSolver # name of 1st Solver +#HiGHSMILPSolver # name of 1st Solver +# [no second Solver: this configuration times the :MILPSolver alone] + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +*MILPCfg-IP.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END TSSBSCfg-IP.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt new file mode 100644 index 0000000..1ef8692 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt @@ -0,0 +1,71 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - TSSBSCfg-LD-IP.txt - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for a TSSBlock solved by a +# LagrangianDualSolver that relaxes the non-anticipativity Constraint, each +# scenario being solved whole by a :MILPSolver with its integer Variable +# (InnerBSCfg-IP.txt). The management of the targets is off, since the cutoffs +# it passes make the :MILPSolver of a scenario return an error. To be used with +# the BlockConfig InnerBCfg.txt (-B). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +LagrangianDualSolver # name of the Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# the ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +3 # number of integer parameters + +int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied +intLogVerb 1 # log verbosity of main Bundle algorithm +intTrgtMng 0 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +3 # number of double parameters + +dblMaxTime 3600 # maximum time for a call, so that the nested dual is + # given the same budget as the MILP it is compared with + +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dbltInit 1e-3 # initial value for t + +1 # number of string parameters + +str_LagBF_BSCfg InnerBSCfg-IP.txt # BlockSolverConfig for the LagBFunctions + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - END TSSBSCfg-LD-IP.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt index 4814e2c..b183a79 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt @@ -1,21 +1,15 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - TSSBSCfg-LDLD.txt - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a TSSBlock to be solved by a +# A txt description of a BlockSolverConfig for a TSSBlock solved by a # LagrangianDualSolver whose sub-problems are solved by a LagrangianDualSolver -# in turn: the outer dual relaxes the non-anticipativity Constraint, making -# one sub-problem of each scenario, and the inner one relaxes the Constraint -# that tie the units of a scenario together, making one sub-problem of each -# unit. What tells this file from TSSBSCfg-LD.txt, where a scenario goes to a -# :MILPSolver whole, is the BlockSolverConfig it names for the LagBFunctions, -# LPBSCfg-LD.txt instead of BSCfg.txt. -# -# The two ways of decomposing the same tree pay on different sizes: this one -# pays on the scenarios, one sub-problem each, while decomposing the whole -# tree at once [see TSSBSCfg-LDrec.txt] pays on the units and on the horizon. -# -# It needs the BundleSolver 2.0: the 1.0 does not solve a Lagrangian dual -# whose sub-problems are Lagrangian duals in turn. +# in turn: the outer dual relaxes the non-anticipativity Constraint, making one +# sub-problem of each scenario, and the inner one (LPBSCfg-LDLD.txt) relaxes +# the Constraint that tie the units of a scenario together, each thermal unit +# being solved by its dynamic programming. It gives a bound, not a solution. It +# pays on the scenarios and on horizons of a month (see TSSBSCfg-LDrec.txt), +# and it needs the BundleSolver 2.0. To be used with the BlockConfig +# InnerBCfg.txt (-B). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -24,78 +18,50 @@ BlockSolverConfig # exact type of the Configuration object 1 # the BlockSolverConfig is a "differential" one -1 # number of (the names of) Solver in this BlockSolverConfig -# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - -LagrangianDualSolver # name of Solver +1 # number of (the names of) Solver in this BlockSolverConfig -1 # number of ComputeConfig in this BlockSolverConfig +LagrangianDualSolver # name of the Solver -# now all the ComputeConfig -# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +1 # number of ComputeConfig in this BlockSolverConfig + +# the ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ComputeConfig of the LagrangianDualSolver; it mostly is the # ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -19 # number of integer parameters - -# now all the integer parameters -intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized -intPushCostToOwner 1 # whether sub-Block Objective are changed -intDoEasy 0 # do easy components for (some) LagBFunction -intMaxIter 10000 # max number of iterations for each call -intMaxThread 1 # MaxThread, max number of new tasks to spawn -intLogVerb 7 # log verbosity of main Bundle algorithm -intWZNorm 2 # which norm to use in the norm-based stopping condition -intBPar1 20 # discard items when they have been useless for iterations -intBPar2 100 # max bundle size per component -intBPar3 1 # max n. of items to fetch from Fi() at each iteration -intBPar4 1 # min n. of items to fetch from Fi() at each iteration -intBPar6 0 # second parameter for dynamic max n. of items per iteration -intBPar7 11 # how to deal with the global pools -intMnSSC 0 # min number of consecutive SS with the same t for a t increase -intMnNSC 1 # min number of consecutive NS with the same t for a t decrease -inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) -intMaxNrEvls 2 # maximum number of function evaluations at each iteration -intTrgtMng 31 # bit-wise encoding targets and accuracies management: - # bit 0: if lower/upper target is set to each convex/concave component - # bit 1: if upper/lower target is set to each convex/concave component - # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) - # bit 4: if Lipschitz constant is used to compute the upper model - -intRstAlg 2 # parameter to handle the reset of the algorithm - -15 # number of double parameters - -# now all the double parameters -dblRelAcc 1e-6 # relative accuracy required to solution -dblNZEps 1e-2 # stopping parameter: threshold to declare 0 the || residual || -dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap -dblBPar5 4 # first parameter for dynamic max n. of items per iteration -dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* -dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* -dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || -dblmxIncr 10 # max increase of t -dblmnIncr 1.5 # min increase of t (each time it is increased) -dblmxDecr 0.1 # max decrease of t -dblmnDecr 0.66 # min decrease of t (each time it is decreased) -dbltMaior 1e+6 # maximum value for t -dbltMinor 1e-10 # minimum value for t -dbltInit 1e-3 # initial value for t -dbltSPar2 1e-2 # parameter for the long-term t-strategy - -3 # number of string parameters - -# now all the string parameters -#strLogFileName tssb.log # filename for the Solver log -#str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver -str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver -str_LagBF_BSCfg LPBSCfg-LD.txt # BlockSolverConfig for the LagBFunctions -#str_LagBF_BSCfg BSCfg.txt # BlockSolverConfig for the LagBFunctions -strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +3 # number of integer parameters + +int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied +intLogVerb 1 # log verbosity of main Bundle algorithm +intTrgtMng 31 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +7 # number of double parameters + +dblMaxTime 3600 # maximum time for a call, so that the nested dual is + # given the same budget as the MILP it is compared with + +dblMinNrEvls -1 # every component is evaluated at each iteration: a + # component here is an entire inner LagrangianDualSolver, + # so an iteration made on one of the three alone buys + # little and costs a master problem anyway; on the NC + # instances the evaluations go from 865 and 1705 down + # to 132 and 168 +dblRelAcc 1e-5 # relative accuracy required to solution +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dblmxIncr 2 # max increase of t +dbltMaior 1e+9 # maximum value for t +dbltInit 1e-3 # initial value for t + +1 # number of string parameters + +str_LagBF_BSCfg LPBSCfg-LDLD.txt # BlockSolverConfig for the LagBFunctions 0 # number of vector-of-int parameters @@ -112,13 +78,6 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's So # now all the vector-of-string parameters # [none] -# pointer to the "extra" Configuration -* # [none] - -# end of 2nd ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - -# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - END BSPar.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END TSSBSCfg-LDLD.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt index 7c47930..fd7096a 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt @@ -1,21 +1,16 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - TSSBSCfg-LDrec.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - TSSBSCfg-LDrec.txt - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a TSSBlock to be solved by one -# LagrangianDualSolver that decomposes the whole tree instead of its children -# alone: with intRecursive a child that has no Variable and no Objective of -# its own is decomposed in turn, its linking Constraint being relaxed -# together with those of the root, so that the sub-problems are the units of -# every scenario and the multipliers are those of both levels at once. -# -# The chain of two solvers [see TSSBSCfg-LDLD.txt] solves the same dual the -# other way round, one Lagrangian dual per scenario under another, and the -# two pay on different sizes: this one pays on the units and on the horizon, -# where it makes hundreds of iterations whose evaluations cost very little, -# while the chain pays on the scenarios, where it makes two or three -# iterations of which each is a whole dual solved inside. -# -# It needs the BundleSolver 2.0, as the chain does. +# A txt description of a BlockSolverConfig for a TSSBlock solved by one +# LagrangianDualSolver that decomposes the whole tree (intRecursive): the +# non-anticipativity Constraint and those that tie the units of each scenario +# together are relaxed at once, the components being the units of every +# scenario, each thermal one solved by its dynamic programming. It is the dual +# of TSSBSCfg-LDLD.txt solved another way, with the same bound: it pays on the +# units and on horizons up to two weeks, the chain on the scenarios and on +# longer horizons, where the master of the recursive one, with one multiplier +# per node and period of every scenario, becomes the bottleneck. It gives a +# bound, not a solution. To be used with the BlockConfig InnerBCfg.txt (-B). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -24,79 +19,52 @@ BlockSolverConfig # exact type of the Configuration object 1 # the BlockSolverConfig is a "differential" one -1 # number of (the names of) Solver in this BlockSolverConfig -# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - -LagrangianDualSolver # name of Solver +1 # number of (the names of) Solver in this BlockSolverConfig -1 # number of ComputeConfig in this BlockSolverConfig +LagrangianDualSolver # name of the Solver -# now all the ComputeConfig -# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +1 # number of ComputeConfig in this BlockSolverConfig + +# the ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ComputeConfig of the LagrangianDualSolver; it mostly is the # ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -20 # number of integer parameters - -# now all the integer parameters -intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized -intRecursive 1 # decompose the descendants too, and not the children alone -intPushCostToOwner 1 # whether sub-Block Objective are changed -intDoEasy 0 # do easy components for (some) LagBFunction -intMaxIter 10000 # max number of iterations for each call -intMaxThread 1 # MaxThread, max number of new tasks to spawn -intLogVerb 7 # log verbosity of main Bundle algorithm -intWZNorm 2 # which norm to use in the norm-based stopping condition -intBPar1 20 # discard items when they have been useless for iterations -intBPar2 100 # max bundle size per component -intBPar3 1 # max n. of items to fetch from Fi() at each iteration -intBPar4 1 # min n. of items to fetch from Fi() at each iteration -intBPar6 0 # second parameter for dynamic max n. of items per iteration -intBPar7 11 # how to deal with the global pools -intMnSSC 0 # min number of consecutive SS with the same t for a t increase -intMnNSC 1 # min number of consecutive NS with the same t for a t decrease -inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) -intMaxNrEvls 2 # maximum number of function evaluations at each iteration -intTrgtMng 31 # bit-wise encoding targets and accuracies management: - # bit 0: if lower/upper target is set to each convex/concave component - # bit 1: if upper/lower target is set to each convex/concave component - # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) - # bit 4: if Lipschitz constant is used to compute the upper model - -intRstAlg 2 # parameter to handle the reset of the algorithm - -15 # number of double parameters - -# now all the double parameters -dblRelAcc 1e-6 # relative accuracy required to solution -dblNZEps 1e-2 # stopping parameter: threshold to declare 0 the || residual || -dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap -dblBPar5 4 # first parameter for dynamic max n. of items per iteration -dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* -dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* -dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || -dblmxIncr 10 # max increase of t -dblmnIncr 1.5 # min increase of t (each time it is increased) -dblmxDecr 0.1 # max decrease of t -dblmnDecr 0.66 # min decrease of t (each time it is decreased) -dbltMaior 1e+6 # maximum value for t -dbltMinor 1e-10 # minimum value for t -dbltInit 1e-3 # initial value for t -dbltSPar2 1e-2 # parameter for the long-term t-strategy - -3 # number of string parameters - -# now all the string parameters -#strLogFileName tssb.log # filename for the Solver log -#str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver -str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver -#str_LagBF_BSCfg LPBSCfg-LD.txt # BlockSolverConfig for the LagBFunctions -str_LagBF_BSCfg BSCfg.txt # BlockSolverConfig for the LagBFunctions -strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +4 # number of integer parameters + +intRecursive 1 # decompose the descendants too + +int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied +intLogVerb 1 # log verbosity of main Bundle algorithm +intTrgtMng 31 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +7 # number of double parameters + +dblMaxTime 3600 # maximum time for a call, so that the nested dual is + # given the same budget as the MILP it is compared with + +dblMinNrEvls -1 # every component is evaluated at each iteration: a + # component here is an entire inner LagrangianDualSolver, + # so an iteration made on one of the three alone buys + # little and costs a master problem anyway; on the NC + # instances the evaluations go from 865 and 1705 down + # to 132 and 168 +dblRelAcc 1e-5 # relative accuracy required to solution +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dblmxIncr 2 # max increase of t +dbltMaior 1e+9 # maximum value for t +dbltInit 1e-3 # initial value for t + +1 # number of string parameters + +str_LagBF_BSCfg InnerBSCfg.txt # BlockSolverConfig for the LagBFunctions 0 # number of vector-of-int parameters @@ -113,13 +81,6 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's So # now all the vector-of-string parameters # [none] -# pointer to the "extra" Configuration -* # [none] - -# end of 2nd ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - -# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - END BSPar.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - END TSSBSCfg-LDrec.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TUBCfg.txt b/pysmspp/data/configs/TSSBlock/TUBCfg.txt new file mode 100644 index 0000000..3f4c0aa --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TUBCfg.txt @@ -0,0 +1,61 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - TUBCfg.txt - - - - - - - - - - - - - - - - - +# +# A txt description of a BlockConfig for a ThermalUnitBlock that is being +# solved by a :MILPSolver. As such it is relevant: +# +# corresponding tolerances, as controlled by the Configuration of +# dynamic constraints +# +# controlled by the Configuration of static variables +# +# Note that if the latter does not include P/C (+8), then the former is +# actually irrelevant +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockConfig # exact type of the ComputeConfig object + +1 # the BlockConfig is a "differential" one + +2 # version of the BlockConfig format + +# the Configuration for the structure, i.e., the tree of sub-Block +* # [none] + +# static_constraints +* # [none] + +# dynamic_constraints +SimpleConfiguration> +1e-6 # threshold parameter for P/C separation +1e-4 # tolerance value to consider a binary variable + +# static_variables +SimpleConfiguration +1 # 0 = 3bin, 1 = T, 2 = pt, 3 = DP, 4 = SU, 5 = SD, 6 = SUSD (Formulation) +#9 # +8 with Perspective Cuts +#17 # +16: start-up / shut-down variables are continuous + +# dynamic_variables +* # [none] + +# objective +* # [none] + +# is_feasible +* # [none] + +# is_optimal +* # [none] + +# solution +* # [none] + +# extra +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END TUBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt b/pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt new file mode 100644 index 0000000..cc58079 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt @@ -0,0 +1,61 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - TUBSCfg-DP.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for a ThermalUnitBlock that is being +# solved by a ThermalUnitExtDPSolver +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +ThermalUnitExtDPSolver + +0 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +0 # number of integer parameters + +# now all the integer parameters +# [none] + +0 # number of double parameters + +# now all the double parameters +# [none] + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END TUBSCfg-DP.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 71831db3fb760a2fd6c1e88538253d749c1871fe Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 21 Sep 2026 16:13:09 +0200 Subject: [PATCH 08/28] the templates follow the rules of the reviews: one-line release notes, short headers and README, no authors, and a test that every template names files of its folder; the PrimalProximalHeur gets a template that gives a feasible solution --- docs/release_notes.md | 6 +- .../data/configs/InvestmentBlock/MPBCfg.txt | 2 - pysmspp/data/configs/README.md | 6 +- pysmspp/data/configs/SDDPBlock/MPBCfg.txt | 2 - pysmspp/data/configs/SVMBlock/MPBCfg.txt | 2 - pysmspp/data/configs/TSSBlock/ACBCfg.txt | 6 +- pysmspp/data/configs/TSSBlock/BDSMCfg.txt | 5 +- pysmspp/data/configs/TSSBlock/BDSSCfg.txt | 9 +- pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt | 3 +- pysmspp/data/configs/TSSBlock/BSCfg1.txt | 3 +- pysmspp/data/configs/TSSBlock/DCNBCfg.txt | 4 +- pysmspp/data/configs/TSSBlock/InnerBCfg.txt | 15 +-- .../data/configs/TSSBlock/InnerBSCfg-IP.txt | 17 +--- pysmspp/data/configs/TSSBlock/InnerBSCfg.txt | 17 +--- pysmspp/data/configs/TSSBlock/LDCfg.txt | 5 +- .../data/configs/TSSBlock/LPBSCfg-LDLD.txt | 9 +- pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt | 4 +- pysmspp/data/configs/TSSBlock/MPBCfg.txt | 2 - pysmspp/data/configs/TSSBlock/PFBCfg.txt | 4 +- .../data/configs/TSSBlock/TSSBSCfg-BDS.txt | 16 +--- pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt | 7 +- .../data/configs/TSSBlock/TSSBSCfg-LD-IP.txt | 8 +- .../data/configs/TSSBlock/TSSBSCfg-LDLD.txt | 11 +-- .../data/configs/TSSBlock/TSSBSCfg-LDrec.txt | 12 +-- .../data/configs/TSSBlock/TSSBSCfg-PPH.txt | 95 +++++++++++++++++++ pysmspp/data/configs/TSSBlock/TUBCfg.txt | 11 +-- pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt | 3 +- test/test_configs.py | 42 ++++++++ 28 files changed, 176 insertions(+), 150 deletions(-) create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt diff --git a/docs/release_notes.md b/docs/release_notes.md index 2595431..787152b 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -25,9 +25,11 @@ * Give Gurobi, in the `TSSBlock/TSSBSCfg_grb.txt` template, the options PyPSA-Eur gives it (barrier without crossover, a tolerance of 1e-5, no dualization and no fill-in from the aggregation), where it passed none. See [PR #117](https://github.com/SPSUnipi/pySMSpp/pull/117) -* Write the configuration templates that use the BundleSolver for the BundleSolver 2.0, whose master problem is a Block solved by a Solver of its own, configured by the `MPBCfg.txt` now shipped in each of those folders; the parameters of the master of the BundleSolver 1.0 are gone. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) +* Write the templates that use the BundleSolver for the BundleSolver 2.0, whose master is configured by the new `MPBCfg.txt`. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) -* Add `TSSBlock/TSSBSCfg-LDLD.txt` and `TSSBlock/TSSBSCfg-LDrec.txt`, which take the Lagrangian dual of a two-stage stochastic problem down to its units instead of stopping at its scenarios, the first one by giving each scenario a `LagrangianDualSolver` of its own and the second one by decomposing the whole tree at once. They are the same dual written two ways and pay on different sizes, the chain on the scenarios and the recursive one on the units and on the horizon; both need the BundleSolver 2.0. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) +* Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) + +* Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) * Update the shipped `BlockConfig` files to the current format: SMS++ now reads a version number after the differential flag and the structure `Configuration` first, so the shipped file was rejected, with the `-B` option silently having no effect. See [PR #110](https://github.com/SPSUnipi/pySMSpp/pull/110) diff --git a/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt index 7c15020..7ce22f1 100644 --- a/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt +++ b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt @@ -4,8 +4,6 @@ # A txt description of a BlockSolverConfig for the inner :MILPSolver of the # MasterProblemBlock used by the BundleSolver # -# Donato Meoli, Antonio Frangioni -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 55b96b6..76ff291 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -10,9 +10,9 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. -The family of two-stage instances whose scenario is a unit commitment (the thermal instances of pypsa2smspp) has its own templates in TSSBlock/, all to be used with the BlockConfig TSSBlock/InnerBCfg.txt (option -B of tssb_solver, i.e., `B="InnerBCfg.txt"` of TSSBSolver): TSSBSCfg-IP.txt solves the deterministic equivalent with a :MILPSolver and its integer Variable (MILPCfg-IP.txt, relative gap 1e-6), TSSBSCfg-LD-IP.txt takes the Lagrangian dual of the non-anticipativity Constraint with each scenario solved whole by a :MILPSolver, and TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt take the dual down to the units, the first one by giving each scenario a LagrangianDualSolver of its own (LPBSCfg-LDLD.txt), the second one, the recursive Lagrangian dual, by decomposing the whole tree at once (`intRecursive`), each thermal unit being solved by its dynamic programming (InnerBSCfg.txt, TUBSCfg-DP.txt). They all load LDCfg.txt and change a few of its parameters. The two duals down to the units are the same dual written two ways and they pay on different sizes: the chain of two solvers pays on the scenarios and on horizons of a month, where it makes a few iterations (from 2 to a few dozen) of which each is a whole dual solved inside, and the recursive Lagrangian dual pays on the units and on horizons up to 2 weeks, where it makes hundreds of iterations whose evaluations cost very little; when the scenarios or the periods grow the cost moves onto the master, which the recursive one has much larger. A Lagrangian dual gives a bound; option -R of tssb_solver, e.g., `-R BSCfg1-IP.txt`, recovers a feasible solution from it by fixing the design to its mean over the scenarios and solving each scenario alone. The duals need the BundleSolver 2.0. +TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. -TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver in the MILP regime, with one optimality cut per scenario and the scenarios of a round evaluated by 8 threads (`int_BDSlv_MaxThread`, which changes the time and not the run), its master and its subproblems being configured by TSSBlock/BDSMCfg.txt and TSSBlock/BDSSCfg.txt (Gurobi, the subproblems with the presolve off, which a Farkas certificate needs). It applies to the Benders form of a two-stage stochastic problem, i.e., a root with a single copy of the here-and-now Variable and one sub-Block per scenario coupled to it by Constraint of the scenario, which tssb_solver assembles around the extensive form of a TSSBlock when it is given -k (in pySMSpp, `TSSBSolver(..., k=None)`). +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSMCfg.txt and BDSSCfg.txt, to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver). -The configurations that use the BundleSolver, i.e., InvestmentBlock/BSPar.txt, SDDPBlock/BSPar-LD.txt, SDDPBlock/BSPar-greedy-LD.txt, SVMBlock/LDCfg.txt, TSSBlock/TSSBSCfg-LD.txt, TSSBlock/TSSBSCfg-LDLD.txt, TSSBlock/TSSBSCfg-LDrec.txt and TSSBlock/LPBSCfg-LD.txt, are written for the BundleSolver 2.0, whose master problem is a Block of its own: `intMPStbl` chooses its stabilization and `strMPBSolverCfg` names the BlockSolverConfig of its Solver, the MPBCfg.txt of the same folder, which solves it with Gurobi. The parameters of the master of the BundleSolver 1.0 (`intMPName`, `intMPlvl`, `intQPmp1`, `intQPmp2`, `intOSImp1`, `intOSImp2`, `intOSImp3`, `dblCtOff`) are gone, and a name the SMS++ at hand does not know makes its whole ComputeConfig fail to load, so these files do not load with an SMS++ whose bundle is the 1.0. The MPBCfg.txt of SVMBlock is the one of the tests of the SVMBlock, which turns the presolve of the master off; the others leave it on, which the masters of the stochastic and investment problems need. +The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. diff --git a/pysmspp/data/configs/SDDPBlock/MPBCfg.txt b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt index 7c15020..7ce22f1 100644 --- a/pysmspp/data/configs/SDDPBlock/MPBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt @@ -4,8 +4,6 @@ # A txt description of a BlockSolverConfig for the inner :MILPSolver of the # MasterProblemBlock used by the BundleSolver # -# Donato Meoli, Antonio Frangioni -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SVMBlock/MPBCfg.txt b/pysmspp/data/configs/SVMBlock/MPBCfg.txt index eeea8a0..ff925e7 100644 --- a/pysmspp/data/configs/SVMBlock/MPBCfg.txt +++ b/pysmspp/data/configs/SVMBlock/MPBCfg.txt @@ -4,8 +4,6 @@ # A txt description of a BlockSolverConfig for the inner :MILPSolver of # the MasterProblemBlock used by the BundleSolver # -# Donato Meoli, Antonio Frangioni -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/ACBCfg.txt b/pysmspp/data/configs/TSSBlock/ACBCfg.txt index a014004..45c7742 100644 --- a/pysmspp/data/configs/TSSBlock/ACBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/ACBCfg.txt @@ -1,11 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - ACBCfg.txt - - - - - - - - - - - - - - - - - # -# A txt description of a BlockConfig for all the NetworkBlock of a UCBlock -# -# - -# exact type of the Configuration object +# The BlockConfig of an ACNetworkBlock: its scaling factors. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSMCfg.txt b/pysmspp/data/configs/TSSBlock/BDSMCfg.txt index 8d549bd..c6b8bfa 100644 --- a/pysmspp/data/configs/TSSBlock/BDSMCfg.txt +++ b/pysmspp/data/configs/TSSBlock/BDSMCfg.txt @@ -1,10 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - BDSMCfg.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for the master problem of the -# Benders decomposition of TSSBSCfg-BDS.txt, in the MILP regime: a single -# :MILPSolver that solves the master (with the epigraph Variable and the -# dynamically added Benders cuts) at each round of the cut loop. +# The master of TSSBSCfg-BDS.txt: a :MILPSolver. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSSCfg.txt b/pysmspp/data/configs/TSSBlock/BDSSCfg.txt index f6eadc2..6a5706b 100644 --- a/pysmspp/data/configs/TSSBlock/BDSSCfg.txt +++ b/pysmspp/data/configs/TSSBlock/BDSSCfg.txt @@ -1,12 +1,9 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - BDSSCfg.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for the subproblem of one Benders -# component of TSSBSCfg-BDS.txt, i.e., the linear program whose value function -# is being approximated, and whose duals are the Benders cuts. -# -# Two things are asked of the Solver beyond solving it, and only the second -# constrains how it is solved: +# The subproblems of TSSBSCfg-BDS.txt: a :MILPSolver on the linear +# program of a scenario, with the presolve off, which a Farkas +# certificate needs. # # - the duals of an optimal solution, which give the optimality cut: any # optimal dual solution does, basic or not, an interior-point one included; diff --git a/pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt b/pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt index efbf812..4810830 100644 --- a/pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt +++ b/pysmspp/data/configs/TSSBlock/BSCfg1-IP.txt @@ -1,8 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - BSCfg1-IP.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for any Block that is a simple -# MILP / MIQP / MIQCQP and can be solved by a :MILPSolver +# A Block solved by a :MILPSolver with its integer Variable. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BSCfg1.txt b/pysmspp/data/configs/TSSBlock/BSCfg1.txt index 2049d54..74bd44f 100644 --- a/pysmspp/data/configs/TSSBlock/BSCfg1.txt +++ b/pysmspp/data/configs/TSSBlock/BSCfg1.txt @@ -1,8 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - BSCfg1.txt - - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for any Block that is a simple -# MILP / MIQP / MIQCQP and can be solved by a :MILPSolver +# A Block solved by a :MILPSolver as a continuous relaxation. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/DCNBCfg.txt b/pysmspp/data/configs/TSSBlock/DCNBCfg.txt index 2c672d1..2e816d5 100644 --- a/pysmspp/data/configs/TSSBlock/DCNBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/DCNBCfg.txt @@ -1,9 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - DCNBCfg.txt - - - - - - - - - - - - - - - - - # -# A txt description of a BlockConfig for all the DCNetworkBlock of a UCBlock, -# selecting the network formulation (read by DCNetworkBlock::generate_abstract_ -# variables). A no-op on instances without a DCNetworkBlock. +# The BlockConfig of a DCNetworkBlock: its formulation. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBCfg.txt b/pysmspp/data/configs/TSSBlock/InnerBCfg.txt index fac80f1..fd715cc 100644 --- a/pysmspp/data/configs/TSSBlock/InnerBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/InnerBCfg.txt @@ -1,19 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - InnerBCfg.txt - - - - - - - - - - - - - - - - # -# A "meta"-BlockConfig: a map from a Block classname() to the BlockConfig to -# apply to every sub-Block of that class. b_config_Block() dispatches it by -# classname over the whole Block tree, so it configures the inner sub-Blocks -# that sit deep inside each scenario's UCBlock regardless of where they sit: -# -# ThermalUnitBlock -> its formulation / P-C parameters (TUBCfg.txt) -# DCNetworkBlock -> its formulation selector (DCNBCfg.txt) -# ACNetworkBlock -> its scaling factors (ACBCfg.txt) -# PolyhedralFunctionBlock -> its "linearized" representation (PFBCfg.txt) -# -# - -# a "meta"-BlockConfig , i.e., a map classname --> its BlockConfig +# A map from classname to BlockConfig for the units and the networks +# of a UCBlock (TUBCfg.txt, DCNBCfg.txt, ACBCfg.txt, PFBCfg.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt b/pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt index b0c43b2..d79f8f0 100644 --- a/pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt +++ b/pysmspp/data/configs/TSSBlock/InnerBSCfg-IP.txt @@ -1,21 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - InnerBSCfg-IP.txt - - - - - - - - - - - - - - - # -# A "meta"-BlockSolverConfig: a map from a Block classname() to the -# BlockSolverConfig to attach to every sub-Block of that class. s_config_Block() -# dispatches it by classname over the WHOLE Block tree, so it reaches the -# ThermalUnitBlock that sit deep inside each scenario's UCBlock and attaches the -# efficient ThermalUnitExtDPSolver to them: -# -# ThermalUnitBlock -> TUBSCfg-DP.txt (ThermalUnitExtDPSolver, integer) -# * (catch-all) -> BSCfg1-IP.txt (every other "hard" inner unit) -# -# The "*" entry is the default applied to any inner Block whose classname() is -# not listed explicitly (BatteryUnitBlock, IntermittentUnitBlock, ...). -# -# - -# a "meta"-BlockConfig , i.e., a map classname --> its BlockConfig +# A map from classname to BlockSolverConfig: ThermalUnitBlock to +# TUBSCfg-DP.txt, every other Block to BSCfg1-IP.txt. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBSCfg.txt b/pysmspp/data/configs/TSSBlock/InnerBSCfg.txt index d21f1ba..00a888b 100644 --- a/pysmspp/data/configs/TSSBlock/InnerBSCfg.txt +++ b/pysmspp/data/configs/TSSBlock/InnerBSCfg.txt @@ -1,21 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - InnerBSCfg.txt - - - - - - - - - - - - - - - - # -# A "meta"-BlockSolverConfig: a map from a Block classname() to the -# BlockSolverConfig to attach to every sub-Block of that class. s_config_Block() -# dispatches it by classname over the WHOLE Block tree, so it reaches the -# ThermalUnitBlock that sit deep inside each scenario's UCBlock and attaches the -# efficient ThermalUnitExtDPSolver to them: -# -# ThermalUnitBlock -> TUBSCfg-DP.txt (ThermalUnitExtDPSolver, integer) -# * (catch-all) -> BSCfg1.txt (every other "hard" inner unit) -# -# The "*" entry is the default applied to any inner Block whose classname() is -# not listed explicitly (BatteryUnitBlock, IntermittentUnitBlock, ...). -# -# - -# a "meta"-BlockConfig , i.e., a map classname --> its BlockConfig +# A map from classname to BlockSolverConfig: ThermalUnitBlock to +# TUBSCfg-DP.txt, every other Block to BSCfg1.txt. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/LDCfg.txt b/pysmspp/data/configs/TSSBlock/LDCfg.txt index 864aa0e..763d4fb 100644 --- a/pysmspp/data/configs/TSSBlock/LDCfg.txt +++ b/pysmspp/data/configs/TSSBlock/LDCfg.txt @@ -1,9 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - LDCfg.txt - - - - - - - - - - - - - - - - - # -# A txt description of the ComputeConfig of a LagrangianDualSolver with a -# BundleSolver 2.0 as the inner Solver, which the templates of the thermal -# family load and change in a few parameters (*LDCfg.txt +). +# The ComputeConfig of a LagrangianDualSolver with a BundleSolver 2.0, +# which the templates above load and change (*LDCfg.txt +). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt b/pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt index 8e810b1..967f82b 100644 --- a/pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt +++ b/pysmspp/data/configs/TSSBlock/LPBSCfg-LDLD.txt @@ -1,13 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - LPBSCfg-LDLD.txt - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a scenario of a TSSBlock solved -# by a LagrangianDualSolver that relaxes the Constraint tying its units -# together, each thermal unit being solved by its dynamic programming -# (InnerBSCfg.txt). The cap on the iterations is not binding, the dual stopping -# on its own criterion, and it has not to be tuned per instance: its multipliers -# grow with the horizon, and a cap tuned on a short one makes the bound of the -# chain collapse on a long one. +# The Lagrangian dual of the units of a scenario, each thermal unit +# solved by its dynamic programming (InnerBSCfg.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt index 3747f91..87e2351 100644 --- a/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt +++ b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt @@ -1,9 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - MILPCfg-IP.txt - - - - - - - - - - - - - - - - # -# A txt description of a ComputeConfig for a :MILPSolver solving the -# deterministic equivalent of a TSSBlock with its integer Variable, to a -# relative gap of 1e-6 and within one hour. +# A :MILPSolver with integer Variable, relative gap 1e-6, one hour. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/MPBCfg.txt b/pysmspp/data/configs/TSSBlock/MPBCfg.txt index 7c15020..7ce22f1 100644 --- a/pysmspp/data/configs/TSSBlock/MPBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/MPBCfg.txt @@ -4,8 +4,6 @@ # A txt description of a BlockSolverConfig for the inner :MILPSolver of the # MasterProblemBlock used by the BundleSolver # -# Donato Meoli, Antonio Frangioni -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/PFBCfg.txt b/pysmspp/data/configs/TSSBlock/PFBCfg.txt index 21a0e40..48b86c9 100644 --- a/pysmspp/data/configs/TSSBlock/PFBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/PFBCfg.txt @@ -1,9 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - PFBCfg.txt - - - - - - - - - - - - - - - - - # -# A txt description of the BlockConfig for a PolyhedralFunctionBlock: the -# "linearized" representation of the PolyhedralFunction is used (static -# variables Configuration == 1), plus the is_feasible() tolerances. +# The BlockConfig of a PolyhedralFunctionBlock: its linearized form. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt index 0fe4945..0af50d2 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt @@ -1,19 +1,9 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - TSSBSCfg-BDS.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a Block having a single -# BendersDecompositionSolver attached, in the MILP regime, with one optimality -# cut per scenario (multi-cut), which is the fastest of the options of the -# Solver on the TSSB instances of pypsa2smspp. The master and the subproblems -# are configured by BDSMCfg.txt and BDSSCfg.txt, and the subproblems of a -# round are evaluated by several threads. -# -# It applies to the Benders form of a two-stage stochastic problem, i.e., a -# root with a single copy of the here-and-now Variable, one sub-Block per -# scenario, and the coupling written as Constraint of each scenario in which -# those Variable appear linearly, which tssb_solver assembles around the -# extensive form of a TSSBlock when it is given -k (in pySMSpp, the argument -# k=None of TSSBSolver). +# A BendersDecompositionSolver in the MILP regime, one cut per scenario, +# the scenarios of a round evaluated by 8 threads, on the Benders form +# smspp_tssb_solver -k assembles (BDSMCfg.txt, BDSSCfg.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt index 08b4fe4..725c568 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IP.txt @@ -1,12 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - TSSBSCfg-IP.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a TSSBlock solved whole by a -# :MILPSolver, i.e., its deterministic equivalent with the integer Variable as -# they are, configured by MILPCfg-IP.txt. It is the monolithic reference of the -# decompositions of the family of thermal instances (TSSBSCfg-LD-IP.txt, -# TSSBSCfg-LDLD.txt, TSSBSCfg-LDrec.txt), to be used with the BlockConfig -# InnerBCfg.txt (-B). +# A TSSBlock solved whole by a :MILPSolver with its integer Variable. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt index 1ef8692..1853ab2 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP.txt @@ -1,12 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - TSSBSCfg-LD-IP.txt - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a TSSBlock solved by a -# LagrangianDualSolver that relaxes the non-anticipativity Constraint, each -# scenario being solved whole by a :MILPSolver with its integer Variable -# (InnerBSCfg-IP.txt). The management of the targets is off, since the cutoffs -# it passes make the :MILPSolver of a scenario return an error. To be used with -# the BlockConfig InnerBCfg.txt (-B). +# A TSSBlock solved by the Lagrangian dual of its scenarios, each one +# solved whole by a :MILPSolver (InnerBSCfg-IP.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt index b183a79..0fcd088 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD.txt @@ -1,15 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - TSSBSCfg-LDLD.txt - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a TSSBlock solved by a -# LagrangianDualSolver whose sub-problems are solved by a LagrangianDualSolver -# in turn: the outer dual relaxes the non-anticipativity Constraint, making one -# sub-problem of each scenario, and the inner one (LPBSCfg-LDLD.txt) relaxes -# the Constraint that tie the units of a scenario together, each thermal unit -# being solved by its dynamic programming. It gives a bound, not a solution. It -# pays on the scenarios and on horizons of a month (see TSSBSCfg-LDrec.txt), -# and it needs the BundleSolver 2.0. To be used with the BlockConfig -# InnerBCfg.txt (-B). +# A TSSBlock solved by the Lagrangian dual of its scenarios, each one +# solved by the Lagrangian dual of its units (LPBSCfg-LDLD.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt index fd7096a..8a4801e 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec.txt @@ -1,16 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - TSSBSCfg-LDrec.txt - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a TSSBlock solved by one -# LagrangianDualSolver that decomposes the whole tree (intRecursive): the -# non-anticipativity Constraint and those that tie the units of each scenario -# together are relaxed at once, the components being the units of every -# scenario, each thermal one solved by its dynamic programming. It is the dual -# of TSSBSCfg-LDLD.txt solved another way, with the same bound: it pays on the -# units and on horizons up to two weeks, the chain on the scenarios and on -# longer horizons, where the master of the recursive one, with one multiplier -# per node and period of every scenario, becomes the bottleneck. It gives a -# bound, not a solution. To be used with the BlockConfig InnerBCfg.txt (-B). +# A TSSBlock solved by the recursive Lagrangian dual, which relaxes the +# Constraint of the scenarios and of their units at once (intRecursive). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt new file mode 100644 index 0000000..760c826 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt @@ -0,0 +1,95 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - TSSBSCfg-PPH.txt - - - - - - - - - - - - - - - +# +# A TSSBlock solved by the PrimalProximalHeur over the Lagrangian dual of +# its scenarios (LPBSCfg-LDLD.txt), which fixes the design to its mean over +# the scenarios and solves each one alone (BSCfg1-IP.txt, 8 threads). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +PrimalProximalHeur # name of 2nd Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + + +# 2nd ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +6 # number of integer parameters + +intInnerMaxIter 200 # iterations of the Lagrangian Dual at each proximal one +intUseWarmStartPSol 0 # the first iteration solves the plain Lagrangian Dual, + # so its bound is valid for the integer problem and + # stronger than the one of the continuous relaxation + +int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied +intLogVerb 0 # log verbosity of main Bundle algorithm +intTrgtMng 31 +intRecoveryThreads 8 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +9 # number of double parameters + +dbl_penaltyFactor 1e-1 # weight of the proximal term +dblInnerRelAcc 1e-5 # accuracy asked of the Lagrangian Dual + +dblMaxTime 3600 # maximum time for a call, so that the nested dual is + # given the same budget as the MILP it is compared with + +dblMinNrEvls -1 # every component is evaluated at each iteration: a + # component here is an entire inner LagrangianDualSolver, + # so an iteration made on one of the three alone buys + # little and costs a master problem anyway; on the NC + # instances the evaluations go from 865 and 1705 down + # to 132 and 168 +dblRelAcc 1e-5 # relative accuracy required to solution +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dblmxIncr 2 # max increase of t +dbltMaior 1e+9 # maximum value for t +dbltInit 1e-3 # initial value for t + +2 # number of string parameters + +str_LagBF_BSCfg LPBSCfg-LDLD.txt +strRecoveryBSC BSCfg1-IP.txt # BlockSolverConfig for the LagBFunctions + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END TSSBSCfg-PPH.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TUBCfg.txt b/pysmspp/data/configs/TSSBlock/TUBCfg.txt index 3f4c0aa..d7dd257 100644 --- a/pysmspp/data/configs/TSSBlock/TUBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/TUBCfg.txt @@ -1,16 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - TUBCfg.txt - - - - - - - - - - - - - - - - - # -# A txt description of a BlockConfig for a ThermalUnitBlock that is being -# solved by a :MILPSolver. As such it is relevant: -# -# corresponding tolerances, as controlled by the Configuration of -# dynamic constraints -# -# controlled by the Configuration of static variables -# -# Note that if the latter does not include P/C (+8), then the former is -# actually irrelevant +# The BlockConfig of a ThermalUnitBlock: formulation and perspective cuts. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt b/pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt index cc58079..542c172 100644 --- a/pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt +++ b/pysmspp/data/configs/TSSBlock/TUBSCfg-DP.txt @@ -1,8 +1,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - TUBSCfg-DP.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a ThermalUnitBlock that is being -# solved by a ThermalUnitExtDPSolver +# A ThermalUnitBlock solved by a ThermalUnitExtDPSolver. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/test_configs.py b/test/test_configs.py index fc11410..348e4ab 100644 --- a/test/test_configs.py +++ b/test/test_configs.py @@ -1,3 +1,7 @@ +import os + +import pytest + from pysmspp import SMSConfig @@ -21,3 +25,41 @@ def test_get_ucsolverconfig_txt(): assert c.config.endswith("uc_solverconfig.txt") assert str(c).endswith("uc_solverconfig.txt") + + +def _named_files(path): + """The files a template names, i.e., the .txt words out of its comments.""" + names = set() + with open(path) as f: + for line in f: + for word in line.split("#")[0].split(): + if word.endswith(".txt"): + names.add(word.lstrip("*")) + return names + + +@pytest.mark.parametrize( + "template", + [ + "TSSBlock/TSSBSCfg-IP.txt", + "TSSBlock/TSSBSCfg-LD-IP.txt", + "TSSBlock/TSSBSCfg-LDLD.txt", + "TSSBlock/TSSBSCfg-LDrec.txt", + "TSSBlock/TSSBSCfg-BDS.txt", + "TSSBlock/TSSBSCfg-PPH.txt", + "TSSBlock/InnerBCfg.txt", + ], +) +def test_template_names_files_of_its_folder(template): + c = SMSConfig(template=template) + folder = os.path.dirname(c.config) + to_check = [os.path.basename(c.config)] + seen = set() + while to_check: + name = to_check.pop() + if name in seen: + continue + seen.add(name) + path = os.path.join(folder, name) + assert os.path.isfile(path), f"{template} names {name}, which is missing" + to_check.extend(_named_files(path)) From 3e5104c6b92b7f01fc48d39b5ee87e1e975914b7 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Tue, 22 Sep 2026 10:53:31 +0200 Subject: [PATCH 09/28] the InvestmentBlock over a TSSB or an MSSB gets its templates, and the Benders form of tssb_solver -k applies to an MSSB too --- docs/release_notes.md | 2 +- pysmspp/data/configs/README.md | 2 +- pysmspp/data/configs/TSSBlock/BSCfg-IB.txt | 73 ++++++++++++ pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt | 104 ++++++++++++++++++ 4 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 pysmspp/data/configs/TSSBlock/BSCfg-IB.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt diff --git a/docs/release_notes.md b/docs/release_notes.md index 787152b..98f5657 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -29,7 +29,7 @@ * Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) -* Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) +* Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`), and of the InvestmentBlock over a TSSB or an MSSB (`TSSBSCfg-IB.txt`, `BSCfg-IB.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) * Update the shipped `BlockConfig` files to the current format: SMS++ now reads a version number after the differential flag and the structure `Configuration` first, so the shipped file was rejected, with the `-B` option silently having no effect. See [PR #110](https://github.com/SPSUnipi/pySMSpp/pull/110) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 76ff291..41048c3 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -12,7 +12,7 @@ The template configuration option for OSolCfg.txt allows to extract the most inf TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. -TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSMCfg.txt and BDSSCfg.txt, to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver). +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSMCfg.txt and BDSSCfg.txt, to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt. The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. diff --git a/pysmspp/data/configs/TSSBlock/BSCfg-IB.txt b/pysmspp/data/configs/TSSBlock/BSCfg-IB.txt new file mode 100644 index 0000000..088c4b1 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BSCfg-IB.txt @@ -0,0 +1,73 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - BSCfg-IB.txt - - - - - - - - - - - - - - - +# +# The :MILPSolver of the stochastic Block inside an InvestmentBlock +# (TSSBSCfg-IB.txt), on the continuous relaxation, with the cuts of the +# InvestmentFunction as lazy constraints. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +GRBMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +4 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # LogVerb, log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intHomogeneousDirection 1 # the multipliers of an unbounded dual direction are + # - A' y and not c - A' y, the Objective having no part in a + # certificate of infeasibility + +0 # number of double parameters + +# now all the double parameters +# [none] + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END BSCfg-IB.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt new file mode 100644 index 0000000..a11f358 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt @@ -0,0 +1,104 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - TSSBSCfg-IB.txt - - - - - - - - - - - - - - - - +# +# The BundleSolver of InvestmentBlock/BSPar.txt on an InvestmentBlock over a +# TSSB or an MSSB (the investment_outside form of pypsa2smspp), whose inner +# stochastic Block is solved whole at every evaluation by BSCfg-IB.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BundleSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +17 # number of integer parameters + +# now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized +intDoEasy 0 # do easy components for (some) LagBFunction +intMaxIter 10000 # max number of iterations for each call +intMaxThread 6 # MaxThread, max number of new tasks to spawn +intLogVerb 16 # log verbosity of main Bundle algorithm +intWZNorm 2 # which norm to use in the norm-based stopping condition +intBPar1 20 # discard items when they have been useless for iterations +intBPar2 1000 # max bundle size per component +intBPar3 1 # max n. of items to fetch from Fi() at each iteration +intBPar4 1 # min n. of items to fetch from Fi() at each iteration +intBPar6 0 # second parameter for dynamic max n. of items per iteration +intBPar7 15 # how to deal with the global pools +intMnSSC 0 # min number of consecutive SS with the same t for a t increase +intMnNSC 3 # min number of consecutive NS with the same t for a t decrease +inttSPar1 0 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) +intMaxNrEvls 2 # maximum number of function evaluations at each iteration + +intRstAlg 2 # parameter to handle the reset of the algorithm + +15 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-4 # relative accuracy required to solution +dblNZEps 1e-4 # stopping parameter: threshold to declare 0 the || residual || +dbltStar -100 # stopping parameter: multiplied to || residual || to estimate gap +dblBPar5 4 # first parameter for dynamic max n. of items per iteration +dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* +dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* +dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || +dblmxIncr 10 # max increase of t +dblmnIncr 1.5 # min increase of t (each time it is increased) +dblmxDecr 0.1 # max decrease of t +dblmnDecr 0.66 # min decrease of t (each time it is decreased) +dbltMaior 1e+6 # maximum value for t +dbltMinor 1e-10 # minimum value for t +dbltInit 1e+0 # initial value for t +dbltSPar2 1e-2 # parameter for the long-term t-strategy + +2 # number of string parameters + +# now all the string parameters +#str_LagBF_BSCfg LPBSCfg.txt # BlockSolverConfig for the LagBFunctions +# not needed if intDoEasy >= 1 && USE_BundleSolver > 0, this is done "by hand" +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver +strInnerBSC BSCfg-IB.txt # BlockSolverConfig for the inner Block + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - END BSPar.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 79dbf97bec8d0a9791ba6c68b07093f968437975 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Tue, 22 Sep 2026 11:54:10 +0200 Subject: [PATCH 10/28] the three Lagrangian duals of the TSSB also with a ParallelBundleSolver, 8 threads in a fixed order --- docs/release_notes.md | 2 +- pysmspp/data/configs/README.md | 2 +- .../configs/TSSBlock/TSSBSCfg-LD-IP-par.txt | 74 ++++++++++++++++ .../configs/TSSBlock/TSSBSCfg-LDLD-par.txt | 83 ++++++++++++++++++ .../configs/TSSBlock/TSSBSCfg-LDrec-par.txt | 85 +++++++++++++++++++ 5 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP-par.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD-par.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec-par.txt diff --git a/docs/release_notes.md b/docs/release_notes.md index 98f5657..3da0be7 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -27,7 +27,7 @@ * Write the templates that use the BundleSolver for the BundleSolver 2.0, whose master is configured by the new `MPBCfg.txt`. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) -* Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) +* Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`), the three duals also with a ParallelBundleSolver (`-par`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) * Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`), and of the InvestmentBlock over a TSSB or an MSSB (`TSSBSCfg-IB.txt`, `BSCfg-IB.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 41048c3..89fea15 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -10,7 +10,7 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. -TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. +TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. TSSBSCfg-LD-IP-par.txt, TSSBSCfg-LDLD-par.txt and TSSBSCfg-LDrec-par.txt are the same three duals with a ParallelBundleSolver, which evaluates the components of an iteration in 8 threads. TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSMCfg.txt and BDSSCfg.txt, to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt. diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP-par.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP-par.txt new file mode 100644 index 0000000..e3e6092 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LD-IP-par.txt @@ -0,0 +1,74 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - TSSBSCfg-LD-IP-par.txt - - - - - - - - - - - - - +# +# TSSBSCfg-LD-IP.txt with a ParallelBundleSolver as its bundle: the +# components of an iteration are evaluated by 8 threads and consumed in +# a fixed order (intParFrm 1), so that the run does not depend on the +# order the threads finish in. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +LagrangianDualSolver # name of the Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# the ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +5 # number of integer parameters + +intMaxThread 8 # threads evaluating the components of an iteration +intParFrm 1 # futures consumed in a fixed order: deterministic + +int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied +intLogVerb 1 # log verbosity of main Bundle algorithm +intTrgtMng 0 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +3 # number of double parameters + +dblMaxTime 3600 # maximum time for a call, so that the nested dual is + # given the same budget as the MILP it is compared with + +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dbltInit 1e-3 # initial value for t + +2 # number of string parameters + +str_LDSlv_ISName ParallelBundleSolver # the inner Solver of the LagrangianDualSolver + +str_LagBF_BSCfg InnerBSCfg-IP.txt # BlockSolverConfig for the LagBFunctions + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - END TSSBSCfg-LD-IP-par.txt - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD-par.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD-par.txt new file mode 100644 index 0000000..a545595 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDLD-par.txt @@ -0,0 +1,83 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - TSSBSCfg-LDLD-par.txt - - - - - - - - - - - - - +# +# TSSBSCfg-LDLD.txt with a ParallelBundleSolver as its bundle: the +# components of an iteration are evaluated by 8 threads and consumed in +# a fixed order (intParFrm 1), so that the run does not depend on the +# order the threads finish in. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +LagrangianDualSolver # name of the Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# the ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +5 # number of integer parameters + +intMaxThread 8 # threads evaluating the components of an iteration +intParFrm 1 # futures consumed in a fixed order: deterministic + +int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied +intLogVerb 1 # log verbosity of main Bundle algorithm +intTrgtMng 31 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +7 # number of double parameters + +dblMaxTime 3600 # maximum time for a call, so that the nested dual is + # given the same budget as the MILP it is compared with + +dblMinNrEvls -1 # every component is evaluated at each iteration: a + # component here is an entire inner LagrangianDualSolver, + # so an iteration made on one of the three alone buys + # little and costs a master problem anyway; on the NC + # instances the evaluations go from 865 and 1705 down + # to 132 and 168 +dblRelAcc 1e-5 # relative accuracy required to solution +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dblmxIncr 2 # max increase of t +dbltMaior 1e+9 # maximum value for t +dbltInit 1e-3 # initial value for t + +2 # number of string parameters + +str_LDSlv_ISName ParallelBundleSolver # the inner Solver of the LagrangianDualSolver + +str_LagBF_BSCfg LPBSCfg-LDLD.txt # BlockSolverConfig for the LagBFunctions + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - END TSSBSCfg-LDLD-par.txt - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec-par.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec-par.txt new file mode 100644 index 0000000..8791774 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LDrec-par.txt @@ -0,0 +1,85 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - TSSBSCfg-LDrec-par.txt - - - - - - - - - - - - - +# +# TSSBSCfg-LDrec.txt with a ParallelBundleSolver as its bundle: the +# components of an iteration are evaluated by 8 threads and consumed in +# a fixed order (intParFrm 1), so that the run does not depend on the +# order the threads finish in. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +LagrangianDualSolver # name of the Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# the ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the LagrangianDualSolver; it mostly is the +# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver + +*LDCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +6 # number of integer parameters + +intMaxThread 8 # threads evaluating the components of an iteration +intParFrm 1 # futures consumed in a fixed order: deterministic + +intRecursive 1 # decompose the descendants too + +int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied +intLogVerb 1 # log verbosity of main Bundle algorithm +intTrgtMng 31 # bit-wise encoding targets and accuracies management: + # bit 0: if lower/upper target is set to each convex/concave component + # bit 1: if upper/lower target is set to each convex/concave component + # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) + # bit 4: if Lipschitz constant is used to compute the upper model + +7 # number of double parameters + +dblMaxTime 3600 # maximum time for a call, so that the nested dual is + # given the same budget as the MILP it is compared with + +dblMinNrEvls -1 # every component is evaluated at each iteration: a + # component here is an entire inner LagrangianDualSolver, + # so an iteration made on one of the three alone buys + # little and costs a master problem anyway; on the NC + # instances the evaluations go from 865 and 1705 down + # to 132 and 168 +dblRelAcc 1e-5 # relative accuracy required to solution +dbltStar -1e+0 # stopping parameter: multiplied to || residual || to estimate gap +dblmxIncr 2 # max increase of t +dbltMaior 1e+9 # maximum value for t +dbltInit 1e-3 # initial value for t + +2 # number of string parameters + +str_LDSlv_ISName ParallelBundleSolver # the inner Solver of the LagrangianDualSolver + +str_LagBF_BSCfg InnerBSCfg.txt # BlockSolverConfig for the LagBFunctions + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - END TSSBSCfg-LDrec-par.txt - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 31c82bd5a5d65fc8746958853c311a465dc741f4 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Tue, 22 Sep 2026 12:32:36 +0200 Subject: [PATCH 11/28] the continuous relaxation of a TSSB gets its templates, with Gurobi and with PIPS-IPM++ on the same linear program --- docs/release_notes.md | 12 ++--- pysmspp/data/configs/README.md | 2 +- pysmspp/data/configs/TSSBlock/MILPCfg-LP.txt | 49 +++++++++++++++++ pysmspp/data/configs/TSSBlock/PIPSCfg.txt | 54 +++++++++++++++++++ pysmspp/data/configs/TSSBlock/TSSBSCfg-LP.txt | 33 ++++++++++++ .../data/configs/TSSBlock/TSSBSCfg-PIPS.txt | 30 +++++++++++ 6 files changed, 172 insertions(+), 8 deletions(-) create mode 100644 pysmspp/data/configs/TSSBlock/MILPCfg-LP.txt create mode 100644 pysmspp/data/configs/TSSBlock/PIPSCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-LP.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-PIPS.txt diff --git a/docs/release_notes.md b/docs/release_notes.md index 3da0be7..e48f1b4 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -8,7 +8,11 @@ ### Minor Changes and Bug Fixes -* +* Write the templates that use the BundleSolver for the BundleSolver 2.0, whose master is configured by the new `MPBCfg.txt`. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) + +* Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`), the three duals also with a ParallelBundleSolver (`-par`), and the continuous relaxation with Gurobi (`TSSBSCfg-LP.txt`) and with PIPS-IPM++ (`TSSBSCfg-PIPS.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) + +* Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`), and of the InvestmentBlock over a TSSB or an MSSB (`TSSBSCfg-IB.txt`, `BSCfg-IB.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) ## Version v0.0.14 @@ -25,12 +29,6 @@ * Give Gurobi, in the `TSSBlock/TSSBSCfg_grb.txt` template, the options PyPSA-Eur gives it (barrier without crossover, a tolerance of 1e-5, no dualization and no fill-in from the aggregation), where it passed none. See [PR #117](https://github.com/SPSUnipi/pySMSpp/pull/117) -* Write the templates that use the BundleSolver for the BundleSolver 2.0, whose master is configured by the new `MPBCfg.txt`. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) - -* Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`), the three duals also with a ParallelBundleSolver (`-par`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) - -* Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`), and of the InvestmentBlock over a TSSB or an MSSB (`TSSBSCfg-IB.txt`, `BSCfg-IB.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) - * Update the shipped `BlockConfig` files to the current format: SMS++ now reads a version number after the differential flag and the structure `Configuration` first, so the shipped file was rejected, with the `-B` option silently having no effect. See [PR #110](https://github.com/SPSUnipi/pySMSpp/pull/110) * Specify local directory when running solvers through `SMSPPSolverTool`: the current working directory is now set to the network directory. See [PR #112](https://github.com/SPSUnipi/pySMSpp/pull/112) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 89fea15..0600d9a 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -10,7 +10,7 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. -TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. TSSBSCfg-LD-IP-par.txt, TSSBSCfg-LDLD-par.txt and TSSBSCfg-LDrec-par.txt are the same three duals with a ParallelBundleSolver, which evaluates the components of an iteration in 8 threads. +TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. TSSBSCfg-LD-IP-par.txt, TSSBSCfg-LDLD-par.txt and TSSBSCfg-LDrec-par.txt are the same three duals with a ParallelBundleSolver, which evaluates the components of an iteration in 8 threads. TSSBSCfg-LP.txt solves the continuous relaxation with a :MILPSolver, and TSSBSCfg-PIPS.txt (with PIPSCfg.txt) the same linear program with PIPS-IPM++, under mpirun. TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSMCfg.txt and BDSSCfg.txt, to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt. diff --git a/pysmspp/data/configs/TSSBlock/MILPCfg-LP.txt b/pysmspp/data/configs/TSSBlock/MILPCfg-LP.txt new file mode 100644 index 0000000..b2e5d2b --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/MILPCfg-LP.txt @@ -0,0 +1,49 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - MILPCfg-LP.txt - - - - - - - - - - - - - - - +# +# A :MILPSolver on the continuous relaxation, one hour. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +3 # number of integer parameters + +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints + +2 # number of double parameters + +dblRelAcc 1e-6 # relative accuracy required to solution +dblMaxTime 3600 # maximum time for a call + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END MILPCfg-LP.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/PIPSCfg.txt b/pysmspp/data/configs/TSSBlock/PIPSCfg.txt new file mode 100644 index 0000000..3492b7c --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/PIPSCfg.txt @@ -0,0 +1,54 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - PIPSCfg.txt - - - - - - - - - - - - - - - +# +# The ComputeConfig of the PIPSMILPSolver of TSSBSCfg-PIPS.txt: the +# continuous relaxation, Curtis-Reid scaling, no presolve of PIPS-IPM++, the +# linear solvers of the build (MUMPS unless PARDISO is there, in which case +# LINEAR_ROOT_SOLVER and LINEAR_SUB_ROOT_SOLVER pardiso are faster). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +3 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the PIPSMILPSolver +intRelaxIntVars 1 # the continuous relaxation: PIPS-IPM++ solves LPs +PRESOLVE 0 # presolve of PIPS-IPM++ off + +1 # number of double parameters + +# now all the double parameters +IPM_TIMELIMIT 3600 # maximum time of the interior point method + +1 # number of string parameters + +# now all the string parameters +SCALER curtisreid # scaling of the problem + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END PIPSCfg.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-LP.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LP.txt new file mode 100644 index 0000000..37a276c --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-LP.txt @@ -0,0 +1,33 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - TSSBSCfg-LP.txt - - - - - - - - - - - - - - - +# +# The continuous relaxation of a TSSBlock, solved whole by a :MILPSolver, +# i.e., the linear program PIPS-IPM++ solves with TSSBSCfg-PIPS.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of 1st Solver +GRBMILPSolver # name of 1st Solver +#SCIPMILPSolver # name of 1st Solver +#HiGHSMILPSolver # name of 1st Solver +# [no second Solver: this configuration times the :MILPSolver alone] + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +*MILPCfg-LP.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END TSSBSCfg-LP.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-PIPS.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-PIPS.txt new file mode 100644 index 0000000..267b3ef --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-PIPS.txt @@ -0,0 +1,30 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - TSSBSCfg-PIPS.txt - - - - - - - - - - - - - - +# +# A TSSBlock solved whole by PIPS-IPM++, an interior point method for linear +# programs that exploits the block structure of the scenarios; run under +# mpirun, one process per group of scenarios (PIPSCfg.txt). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +PIPSMILPSolver # name of 1st Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the PIPSMILPSolver + +*PIPSCfg.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END TSSBSCfg-PIPS.txt - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 21453019dc0d1839f402509494dd245341626ab6 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Tue, 22 Sep 2026 17:19:34 +0200 Subject: [PATCH 12/28] the thermal units of the TSSB templates are written in the 3bin formulation, which asks Gurobi less work than T --- pysmspp/data/configs/TSSBlock/TUBCfg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysmspp/data/configs/TSSBlock/TUBCfg.txt b/pysmspp/data/configs/TSSBlock/TUBCfg.txt index d7dd257..21e46c4 100644 --- a/pysmspp/data/configs/TSSBlock/TUBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/TUBCfg.txt @@ -25,7 +25,7 @@ SimpleConfiguration> # static_variables SimpleConfiguration -1 # 0 = 3bin, 1 = T, 2 = pt, 3 = DP, 4 = SU, 5 = SD, 6 = SUSD (Formulation) +0 # 0 = 3bin, 1 = T, 2 = pt, 3 = DP, 4 = SU, 5 = SD, 6 = SUSD (Formulation) #9 # +8 with Perspective Cuts #17 # +16: start-up / shut-down variables are continuous From 8b099f7b4dc8989dc39c4e094a7298cd30c78072 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sat, 26 Sep 2026 04:03:04 +0200 Subject: [PATCH 13/28] the templates as measured: BDS tolerates the relaxed binaries of an integer recourse, PIPS-IPM++ scales by equilibrium, the InvestmentBlock stops on a relative threshold and gets the Solver of its inner block from its OBlockConfig --- docs/release_notes.md | 2 +- .../data/configs/InvestmentBlock/IBOCfg.txt | 54 +++++++++++++++++++ .../data/configs/InvestmentBlock/IFCfg.txt | 42 +++++++++++++++ .../configs/InvestmentBlock/InnerBCfg.txt | 18 +++++++ pysmspp/data/configs/TSSBlock/BDSSCfg.txt | 6 ++- pysmspp/data/configs/TSSBlock/IBOCfg.txt | 54 +++++++++++++++++++ pysmspp/data/configs/TSSBlock/IFCfg.txt | 42 +++++++++++++++ pysmspp/data/configs/TSSBlock/InnerBCfg.txt | 10 ++-- pysmspp/data/configs/TSSBlock/PIPSCfg.txt | 11 ++-- pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt | 9 ++-- 10 files changed, 235 insertions(+), 13 deletions(-) create mode 100644 pysmspp/data/configs/InvestmentBlock/IBOCfg.txt create mode 100644 pysmspp/data/configs/InvestmentBlock/IFCfg.txt create mode 100644 pysmspp/data/configs/InvestmentBlock/InnerBCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/IBOCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/IFCfg.txt diff --git a/docs/release_notes.md b/docs/release_notes.md index e48f1b4..471c8d3 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -12,7 +12,7 @@ * Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`), the three duals also with a ParallelBundleSolver (`-par`), and the continuous relaxation with Gurobi (`TSSBSCfg-LP.txt`) and with PIPS-IPM++ (`TSSBSCfg-PIPS.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) -* Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`), and of the InvestmentBlock over a TSSB or an MSSB (`TSSBSCfg-IB.txt`, `BSCfg-IB.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) +* Add the templates of the BendersDecompositionSolver for the Benders form of a two-stage problem (`TSSBSCfg-BDS.txt`, `BDSMCfg.txt`, `BDSSCfg.txt`), and of the InvestmentBlock over a TSSB or an MSSB (`TSSBSCfg-IB.txt`, `BSCfg-IB.txt`). The Solver of the block inside an InvestmentBlock is given by its OBlockConfig (`IBOCfg.txt`, `IFCfg.txt`) through the `InvestmentBlock` entry of `InnerBCfg.txt`, which `smspp_investmentblock_solver` reads by default, in `InvestmentBlock/` and in `TSSBlock/`. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) ## Version v0.0.14 diff --git a/pysmspp/data/configs/InvestmentBlock/IBOCfg.txt b/pysmspp/data/configs/InvestmentBlock/IBOCfg.txt new file mode 100644 index 0000000..9012f9b --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/IBOCfg.txt @@ -0,0 +1,54 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - IBOCfg.txt - - - - - - - - - - - - - - - - +# +# The OBlockConfig of an InvestmentBlock: it reformulates the bounds on the +# investment, and gives the InvestmentFunction its ComputeConfig [see +# IFCfg.txt], which holds the BlockSolverConfig of the inner Block. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OBlockConfig # exact type of the Configuration object + +1 # the BlockConfig is a "differential" one + +2 # version of the BlockConfig format + +# the Configuration for the structure, i.e., the tree of sub-Block +* # [none] + +# static_constraints: the bounds l <= x <= u on the investment are +# reformulated as 0 <= x <= u - l, the only form BundleSolver handles +SimpleConfiguration +1 + +# dynamic_constraints +* # [none] + +# static_variables +* # [none] + +# dynamic_variables +* # [none] + +# objective +* # [none] + +# is_feasible +* # [none] + +# is_optimal +* # [none] + +# solution +* # [none] + +# extra +* # [none] + +# the ComputeConfig of the Objective, i.e., of the InvestmentFunction +*IFCfg.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END IBOCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/InvestmentBlock/IFCfg.txt b/pysmspp/data/configs/InvestmentBlock/IFCfg.txt new file mode 100644 index 0000000..435d1d9 --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/IFCfg.txt @@ -0,0 +1,42 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - IFCfg.txt - - - - - - - - - - - - - - - - - +# +# The ComputeConfig of the InvestmentFunction, which the OBlockConfig of the +# InvestmentBlock gives to its Objective [see IBOCfg.txt]: the file where the +# investments and the values of the Function are output, and, in the extra +# Configuration, the BlockSolverConfig of the inner Block, here a UCBlock (or +# a TwoStageStochasticBlock of UCBlock). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 1 ==> all non-provided parameters are not changed + +0 # number of integer parameters + +0 # number of double parameters + +1 # number of string parameters + +# now all the string parameters +strOutputFilename investment_candidates.txt # where the investment and the + # value of the Function are + # appended at each evaluation + +0 # number of vector-of-int parameters + +0 # number of vector-of-double parameters + +0 # number of vector-of-string parameters + +# pointer to the "extra" Configuration: the BlockSolverConfig of the inner +# Block of the InvestmentFunction +SimpleConfiguration> +1 # the number of elements in the map +BlockSolverConfig *BSCfg.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END IFCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/InvestmentBlock/InnerBCfg.txt b/pysmspp/data/configs/InvestmentBlock/InnerBCfg.txt new file mode 100644 index 0000000..d7436db --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/InnerBCfg.txt @@ -0,0 +1,18 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - InnerBCfg.txt - - - - - - - - - - - - - - - - +# +# A map from classname to BlockConfig, which smspp_investmentblock_solver +# reads by default (-B InnerBCfg.txt): the InvestmentBlock gets IBOCfg.txt, +# which gives the Solver of its inner Block (IFCfg.txt, BSCfg.txt). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +SimpleConfiguration> + +1 # the number of elements in the map +InvestmentBlock *IBOCfg.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END InnerBCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSSCfg.txt b/pysmspp/data/configs/TSSBlock/BDSSCfg.txt index 6a5706b..01d6b7d 100644 --- a/pysmspp/data/configs/TSSBlock/BDSSCfg.txt +++ b/pysmspp/data/configs/TSSBlock/BDSSCfg.txt @@ -43,7 +43,7 @@ ComputeConfig # exact type of the ComputeConfig object 0 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -5 # number of integer parameters +6 # number of integer parameters # now all the integer parameters intLogVerb 0 # LogVerb, log verbosity of the MILPSolver @@ -54,6 +54,10 @@ Method 1 # dual simplex: asked for reproducibility of the duals, # any optimal ones giving a valid optimality cut Presolve 0 # off, or an infeasible subproblem leaves no Farkas # certificate and no feasibility cut can be generated +intThrowReducedCostException 0 # a Variable whose bounds are those of its + # type, as a relaxed binary of a leaf, has no + # OneVarConstraint to take its reduced cost, which the + # cut, read off the coupling rows, does not need 1 # number of double parameters diff --git a/pysmspp/data/configs/TSSBlock/IBOCfg.txt b/pysmspp/data/configs/TSSBlock/IBOCfg.txt new file mode 100644 index 0000000..9012f9b --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/IBOCfg.txt @@ -0,0 +1,54 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - IBOCfg.txt - - - - - - - - - - - - - - - - +# +# The OBlockConfig of an InvestmentBlock: it reformulates the bounds on the +# investment, and gives the InvestmentFunction its ComputeConfig [see +# IFCfg.txt], which holds the BlockSolverConfig of the inner Block. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OBlockConfig # exact type of the Configuration object + +1 # the BlockConfig is a "differential" one + +2 # version of the BlockConfig format + +# the Configuration for the structure, i.e., the tree of sub-Block +* # [none] + +# static_constraints: the bounds l <= x <= u on the investment are +# reformulated as 0 <= x <= u - l, the only form BundleSolver handles +SimpleConfiguration +1 + +# dynamic_constraints +* # [none] + +# static_variables +* # [none] + +# dynamic_variables +* # [none] + +# objective +* # [none] + +# is_feasible +* # [none] + +# is_optimal +* # [none] + +# solution +* # [none] + +# extra +* # [none] + +# the ComputeConfig of the Objective, i.e., of the InvestmentFunction +*IFCfg.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END IBOCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/IFCfg.txt b/pysmspp/data/configs/TSSBlock/IFCfg.txt new file mode 100644 index 0000000..11ac1b6 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/IFCfg.txt @@ -0,0 +1,42 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - IFCfg.txt - - - - - - - - - - - - - - - - - +# +# The ComputeConfig of the InvestmentFunction, which the OBlockConfig of the +# InvestmentBlock gives to its Objective [see IBOCfg.txt]: the file where the +# investments and the values of the Function are output, and, in the extra +# Configuration, the BlockSolverConfig of the inner Block, here a TSSB, an +# MSSB or a UCBlock, whose continuous relaxation Gurobi solves whole. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 1 ==> all non-provided parameters are not changed + +0 # number of integer parameters + +0 # number of double parameters + +1 # number of string parameters + +# now all the string parameters +strOutputFilename investment_candidates.txt # where the investment and the + # value of the Function are + # appended at each evaluation + +0 # number of vector-of-int parameters + +0 # number of vector-of-double parameters + +0 # number of vector-of-string parameters + +# pointer to the "extra" Configuration: the BlockSolverConfig of the inner +# Block of the InvestmentFunction +SimpleConfiguration> +1 # the number of elements in the map +BlockSolverConfig *BSCfg-IB.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END IFCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBCfg.txt b/pysmspp/data/configs/TSSBlock/InnerBCfg.txt index fd715cc..9137526 100644 --- a/pysmspp/data/configs/TSSBlock/InnerBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/InnerBCfg.txt @@ -1,16 +1,18 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - InnerBCfg.txt - - - - - - - - - - - - - - - - # -# A map from classname to BlockConfig for the units and the networks -# of a UCBlock (TUBCfg.txt, DCNBCfg.txt, ACBCfg.txt, PFBCfg.txt). +# A map from classname to BlockConfig: the InvestmentBlock over a TSSB, an +# MSSB or a UCBlock (IBOCfg.txt, which gives the Solver of the inner Block), +# and the units and the networks of a UCBlock (TUBCfg.txt, DCNBCfg.txt, +# ACBCfg.txt, PFBCfg.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SimpleConfiguration> -4 # the number of elements in the map - +5 # the number of elements in the map +InvestmentBlock *IBOCfg.txt ThermalUnitBlock *TUBCfg.txt DCNetworkBlock *DCNBCfg.txt ACNetworkBlock *ACBCfg.txt diff --git a/pysmspp/data/configs/TSSBlock/PIPSCfg.txt b/pysmspp/data/configs/TSSBlock/PIPSCfg.txt index 3492b7c..71b85cb 100644 --- a/pysmspp/data/configs/TSSBlock/PIPSCfg.txt +++ b/pysmspp/data/configs/TSSBlock/PIPSCfg.txt @@ -2,9 +2,9 @@ # - - - - - - - - - - - - - - - - PIPSCfg.txt - - - - - - - - - - - - - - - # # The ComputeConfig of the PIPSMILPSolver of TSSBSCfg-PIPS.txt: the -# continuous relaxation, Curtis-Reid scaling, no presolve of PIPS-IPM++, the -# linear solvers of the build (MUMPS unless PARDISO is there, in which case -# LINEAR_ROOT_SOLVER and LINEAR_SUB_ROOT_SOLVER pardiso are faster). +# continuous relaxation, equilibrium scaling, no presolve of PIPS-IPM++, the +# linear solvers of the build (MUMPS; PARDISO at the root hangs in the +# factorization of the Schur complement with 25 or more processes). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -29,7 +29,10 @@ IPM_TIMELIMIT 3600 # maximum time of the interior point method 1 # number of string parameters # now all the string parameters -SCALER curtisreid # scaling of the problem +SCALER equilibrium # scaling of the problem: with curtisreid the interior + # point stops at its iteration limit on unit commitment + # relaxations, and equilibrium is also 7 to 14% faster + # where both converge 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt index a11f358..e64097d 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt @@ -36,7 +36,11 @@ intDoEasy 0 # do easy components for (some) LagBFunction intMaxIter 10000 # max number of iterations for each call intMaxThread 6 # MaxThread, max number of new tasks to spawn intLogVerb 16 # log verbosity of main Bundle algorithm -intWZNorm 2 # which norm to use in the norm-based stopping condition +intWZNorm 10 # which norm to use in the norm-based stopping condition: + # the 2-norm, dblNZEps being relative to that of the first + # full subgradient; taken as absolute, 1e-4 is below what + # the aggregated subgradient reaches on a design in MW, + # and the bundle goes on long after the optimum intBPar1 20 # discard items when they have been useless for iterations intBPar2 1000 # max bundle size per component intBPar3 1 # max n. of items to fetch from Fi() at each iteration @@ -69,13 +73,12 @@ dbltMinor 1e-10 # minimum value for t dbltInit 1e+0 # initial value for t dbltSPar2 1e-2 # parameter for the long-term t-strategy -2 # number of string parameters +1 # number of string parameters # now all the string parameters #str_LagBF_BSCfg LPBSCfg.txt # BlockSolverConfig for the LagBFunctions # not needed if intDoEasy >= 1 && USE_BundleSolver > 0, this is done "by hand" strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver -strInnerBSC BSCfg-IB.txt # BlockSolverConfig for the inner Block 0 # number of vector-of-int parameters From 41a6b1c619a3c2873e395ba4b7ab3a57eba29cfa Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Fri, 25 Sep 2026 20:36:41 +0200 Subject: [PATCH 14/28] the master of the bundle templates is solved by HiGHS in MPBCfg.txt, and by Gurobi in MPBCfg_grb.txt --- docs/release_notes.md | 2 +- .../data/configs/InvestmentBlock/MPBCfg.txt | 17 +-- .../configs/InvestmentBlock/MPBCfg_grb.txt | 120 ++++++++++++++++++ pysmspp/data/configs/README.md | 2 +- pysmspp/data/configs/SDDPBlock/MPBCfg.txt | 17 +-- pysmspp/data/configs/SDDPBlock/MPBCfg_grb.txt | 120 ++++++++++++++++++ pysmspp/data/configs/SVMBlock/MPBCfg.txt | 23 ++-- pysmspp/data/configs/SVMBlock/MPBCfg_grb.txt | 116 +++++++++++++++++ pysmspp/data/configs/TSSBlock/MPBCfg.txt | 17 +-- pysmspp/data/configs/TSSBlock/MPBCfg_grb.txt | 120 ++++++++++++++++++ 10 files changed, 517 insertions(+), 37 deletions(-) create mode 100644 pysmspp/data/configs/InvestmentBlock/MPBCfg_grb.txt create mode 100644 pysmspp/data/configs/SDDPBlock/MPBCfg_grb.txt create mode 100644 pysmspp/data/configs/SVMBlock/MPBCfg_grb.txt create mode 100644 pysmspp/data/configs/TSSBlock/MPBCfg_grb.txt diff --git a/docs/release_notes.md b/docs/release_notes.md index 471c8d3..06b41d4 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -8,7 +8,7 @@ ### Minor Changes and Bug Fixes -* Write the templates that use the BundleSolver for the BundleSolver 2.0, whose master is configured by the new `MPBCfg.txt`. See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) +* Write the templates that use the BundleSolver for the BundleSolver 2.0, whose master is configured by the new `MPBCfg.txt` (HiGHS) or `MPBCfg_grb.txt` (Gurobi). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) * Add templates for the two-stage instances whose scenario is a unit commitment: the MILP (`TSSBSCfg-IP.txt`), the Lagrangian dual of the scenarios (`TSSBSCfg-LD-IP.txt`), the chain of two duals (`TSSBSCfg-LDLD.txt`), the recursive Lagrangian dual (`TSSBSCfg-LDrec.txt`) and the PrimalProximalHeur, which gives a feasible solution (`TSSBSCfg-PPH.txt`), the three duals also with a ParallelBundleSolver (`-par`), and the continuous relaxation with Gurobi (`TSSBSCfg-LP.txt`) and with PIPS-IPM++ (`TSSBSCfg-PIPS.txt`). See [PR #116](https://github.com/SPSUnipi/pySMSpp/pull/116) diff --git a/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt index 7ce22f1..1b49e06 100644 --- a/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt +++ b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt @@ -16,9 +16,9 @@ BlockSolverConfig # exact type of the Configuration object # now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - #CPXMILPSolver # name of Solver -GRBMILPSolver # name of Solver +#GRBMILPSolver # name of Solver #SCIPMILPSolver # name of Solver -#HiGHSMILPSolver # name of Solver +HiGHSMILPSolver # name of Solver 1 # number of ComputeConfig in this BlockSolverConfig @@ -31,7 +31,7 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -6 # number of integer parameters +4 # number of integer parameters # now all the integer parameters intLogVerb 0 # log verbosity of the MILPSolver @@ -44,14 +44,14 @@ intMaxThread 1 # single-threaded for deterministic master reproducibility #CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis # All specific GUROBI parameter (uncomment based on Solver) -Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers +#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers # of the master ARE the algorithm, and an interior point has # them only to about 1e-7 relative, which the stopping test # of the bundle cannot survive; besides, the barrier cannot # restart from the previous basis, so it re-solves the master # from scratch at every call, while the simplex re-optimises # after the new columns for a fraction of the iterations -NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master +#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # is small and re-solved thousands of times, so whatever # extra care is asked is paid at every one of them, and 3 # costs a factor two. 0 is not an option: with it the @@ -63,7 +63,7 @@ NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # declared infeasible on tolerance when the model is badly # scaled, and the bundle reads that as a numerical error -5 # number of double parameters +3 # number of double parameters # now all the double parameters dblRelAcc 1e-08 # relative accuracy required to solution @@ -75,10 +75,11 @@ dblRAccSol 1e-08 # relative accuracy of the solution pool # vertical row by less than the default 1e-6 is feasible for the master and # infeasible for the subproblem, which answers with the very cut that is # already there, and the same iteration repeats forever. -FeasibilityTol 1e-09 # how much a row of the master may be violated -OptimalityTol 1e-09 # how much a reduced cost of the master may be off +#FeasibilityTol 1e-09 # how much a row of the master may be violated +#OptimalityTol 1e-09 # how much a reduced cost of the master may be off # All specific HiGHS parameter (uncomment based on Solver) +# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) #primal_feasibility_tolerance 1e-9 #dual_feasibility_tolerance 1e-9 diff --git a/pysmspp/data/configs/InvestmentBlock/MPBCfg_grb.txt b/pysmspp/data/configs/InvestmentBlock/MPBCfg_grb.txt new file mode 100644 index 0000000..08ba68a --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/MPBCfg_grb.txt @@ -0,0 +1,120 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - MPBCfg_grb.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of the +# MasterProblemBlock used by the BundleSolver +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +6 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END MPBCfg_grb.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 0600d9a..de83aae 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -14,5 +14,5 @@ TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDr TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSMCfg.txt and BDSSCfg.txt, to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt. -The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. +The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. MPBCfg.txt solves the master with HiGHS, which needs an SMS++ whose HiGHSMILPSolver regularizes the QP of the master (the one of HiGHS 1.15 may otherwise call it non-convex), and the version using Gurobi is provided under name MPBCfg_grb.txt, to be named by `strMPBSolverCfg` in its place. diff --git a/pysmspp/data/configs/SDDPBlock/MPBCfg.txt b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt index 7ce22f1..1b49e06 100644 --- a/pysmspp/data/configs/SDDPBlock/MPBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt @@ -16,9 +16,9 @@ BlockSolverConfig # exact type of the Configuration object # now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - #CPXMILPSolver # name of Solver -GRBMILPSolver # name of Solver +#GRBMILPSolver # name of Solver #SCIPMILPSolver # name of Solver -#HiGHSMILPSolver # name of Solver +HiGHSMILPSolver # name of Solver 1 # number of ComputeConfig in this BlockSolverConfig @@ -31,7 +31,7 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -6 # number of integer parameters +4 # number of integer parameters # now all the integer parameters intLogVerb 0 # log verbosity of the MILPSolver @@ -44,14 +44,14 @@ intMaxThread 1 # single-threaded for deterministic master reproducibility #CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis # All specific GUROBI parameter (uncomment based on Solver) -Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers +#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers # of the master ARE the algorithm, and an interior point has # them only to about 1e-7 relative, which the stopping test # of the bundle cannot survive; besides, the barrier cannot # restart from the previous basis, so it re-solves the master # from scratch at every call, while the simplex re-optimises # after the new columns for a fraction of the iterations -NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master +#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # is small and re-solved thousands of times, so whatever # extra care is asked is paid at every one of them, and 3 # costs a factor two. 0 is not an option: with it the @@ -63,7 +63,7 @@ NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # declared infeasible on tolerance when the model is badly # scaled, and the bundle reads that as a numerical error -5 # number of double parameters +3 # number of double parameters # now all the double parameters dblRelAcc 1e-08 # relative accuracy required to solution @@ -75,10 +75,11 @@ dblRAccSol 1e-08 # relative accuracy of the solution pool # vertical row by less than the default 1e-6 is feasible for the master and # infeasible for the subproblem, which answers with the very cut that is # already there, and the same iteration repeats forever. -FeasibilityTol 1e-09 # how much a row of the master may be violated -OptimalityTol 1e-09 # how much a reduced cost of the master may be off +#FeasibilityTol 1e-09 # how much a row of the master may be violated +#OptimalityTol 1e-09 # how much a reduced cost of the master may be off # All specific HiGHS parameter (uncomment based on Solver) +# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) #primal_feasibility_tolerance 1e-9 #dual_feasibility_tolerance 1e-9 diff --git a/pysmspp/data/configs/SDDPBlock/MPBCfg_grb.txt b/pysmspp/data/configs/SDDPBlock/MPBCfg_grb.txt new file mode 100644 index 0000000..08ba68a --- /dev/null +++ b/pysmspp/data/configs/SDDPBlock/MPBCfg_grb.txt @@ -0,0 +1,120 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - MPBCfg_grb.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of the +# MasterProblemBlock used by the BundleSolver +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +6 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END MPBCfg_grb.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SVMBlock/MPBCfg.txt b/pysmspp/data/configs/SVMBlock/MPBCfg.txt index ff925e7..6090990 100644 --- a/pysmspp/data/configs/SVMBlock/MPBCfg.txt +++ b/pysmspp/data/configs/SVMBlock/MPBCfg.txt @@ -16,9 +16,9 @@ BlockSolverConfig # exact type of the Configuration object # now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - #CPXMILPSolver # name of Solver -GRBMILPSolver # name of Solver +#GRBMILPSolver # name of Solver #SCIPMILPSolver # name of Solver -#HiGHSMILPSolver # name of Solver +HiGHSMILPSolver # name of Solver 1 # number of ComputeConfig in this BlockSolverConfig @@ -31,7 +31,7 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -7 # number of integer parameters +4 # number of integer parameters # now all the integer parameters intLogVerb 0 # log verbosity of the MILPSolver @@ -45,15 +45,15 @@ intMaxThread 1 # single-threaded for deterministic master reproducibility #CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis # All specific GUROBI parameter (uncomment based on Solver) -Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers +#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers # of the master ARE the algorithm, and an interior point has # them only to about 1e-7 relative, which the stopping test # of the bundle cannot survive; besides, the barrier cannot # restart from the previous basis, so it re-solves the master # from scratch at every call, while the simplex re-optimises # after the new columns for a fraction of the iterations -Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1) -NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1) +#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # is small and re-solved thousands of times, so whatever # extra care is asked is paid at every one of them, and 3 # costs a factor two. 0 is not an option: with it the @@ -61,7 +61,7 @@ NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # that has a solution, so this is the least care that # answers right -5 # number of double parameters +3 # number of double parameters # now all the double parameters dblRelAcc 1e-08 # relative accuracy required to solution @@ -73,20 +73,21 @@ dblRAccSol 1e-08 # relative accuracy of the solution pool # vertical row by less than the default 1e-6 is feasible for the master and # infeasible for the subproblem, which answers with the very cut that is # already there, and the same iteration repeats forever. -FeasibilityTol 1e-09 # how much a row of the master may be violated -OptimalityTol 1e-09 # how much a reduced cost of the master may be off +#FeasibilityTol 1e-09 # how much a row of the master may be violated +#OptimalityTol 1e-09 # how much a reduced cost of the master may be off # All specific HiGHS parameter (uncomment based on Solver) +# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) #primal_feasibility_tolerance 1e-9 #dual_feasibility_tolerance 1e-9 -0 # number of string parameters +1 # number of string parameters # now all the string parameters #strOutputFile master.lp # All specific HiGHS parameter (uncomment based on Solver) -#presolve off # disable presolve for reproducibility +presolve off # as Presolve 0 in MPBCfg_grb.txt #solver ipm # interior point: converges to analytic center (unique x*) 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/SVMBlock/MPBCfg_grb.txt b/pysmspp/data/configs/SVMBlock/MPBCfg_grb.txt new file mode 100644 index 0000000..246975a --- /dev/null +++ b/pysmspp/data/configs/SVMBlock/MPBCfg_grb.txt @@ -0,0 +1,116 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - MPBCfg_grb.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of +# the MasterProblemBlock used by the BundleSolver +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +7 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 4 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier, 6 = concurrent +#CPXPARAM_Preprocessing_Presolve 0 # disable presolve for reproducibility +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1) +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END MPBCfg_grb.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/MPBCfg.txt b/pysmspp/data/configs/TSSBlock/MPBCfg.txt index 7ce22f1..1b49e06 100644 --- a/pysmspp/data/configs/TSSBlock/MPBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/MPBCfg.txt @@ -16,9 +16,9 @@ BlockSolverConfig # exact type of the Configuration object # now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - #CPXMILPSolver # name of Solver -GRBMILPSolver # name of Solver +#GRBMILPSolver # name of Solver #SCIPMILPSolver # name of Solver -#HiGHSMILPSolver # name of Solver +HiGHSMILPSolver # name of Solver 1 # number of ComputeConfig in this BlockSolverConfig @@ -31,7 +31,7 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -6 # number of integer parameters +4 # number of integer parameters # now all the integer parameters intLogVerb 0 # log verbosity of the MILPSolver @@ -44,14 +44,14 @@ intMaxThread 1 # single-threaded for deterministic master reproducibility #CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis # All specific GUROBI parameter (uncomment based on Solver) -Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers +#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers # of the master ARE the algorithm, and an interior point has # them only to about 1e-7 relative, which the stopping test # of the bundle cannot survive; besides, the barrier cannot # restart from the previous basis, so it re-solves the master # from scratch at every call, while the simplex re-optimises # after the new columns for a fraction of the iterations -NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master +#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # is small and re-solved thousands of times, so whatever # extra care is asked is paid at every one of them, and 3 # costs a factor two. 0 is not an option: with it the @@ -63,7 +63,7 @@ NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # declared infeasible on tolerance when the model is badly # scaled, and the bundle reads that as a numerical error -5 # number of double parameters +3 # number of double parameters # now all the double parameters dblRelAcc 1e-08 # relative accuracy required to solution @@ -75,10 +75,11 @@ dblRAccSol 1e-08 # relative accuracy of the solution pool # vertical row by less than the default 1e-6 is feasible for the master and # infeasible for the subproblem, which answers with the very cut that is # already there, and the same iteration repeats forever. -FeasibilityTol 1e-09 # how much a row of the master may be violated -OptimalityTol 1e-09 # how much a reduced cost of the master may be off +#FeasibilityTol 1e-09 # how much a row of the master may be violated +#OptimalityTol 1e-09 # how much a reduced cost of the master may be off # All specific HiGHS parameter (uncomment based on Solver) +# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) #primal_feasibility_tolerance 1e-9 #dual_feasibility_tolerance 1e-9 diff --git a/pysmspp/data/configs/TSSBlock/MPBCfg_grb.txt b/pysmspp/data/configs/TSSBlock/MPBCfg_grb.txt new file mode 100644 index 0000000..08ba68a --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/MPBCfg_grb.txt @@ -0,0 +1,120 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - MPBCfg_grb.txt - - - - - - - - - - - - - - - - +# +# A txt description of a BlockSolverConfig for the inner :MILPSolver of the +# MasterProblemBlock used by the BundleSolver +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +#HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +6 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point has + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the master + # from scratch at every call, while the simplex re-optimises + # after the new columns for a fraction of the iterations +NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +5 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +FeasibilityTol 1e-09 # how much a row of the master may be violated +OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END MPBCfg_grb.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From c7d26c5ab0c53581d51fb4a34b317f5779a9ffbb Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sat, 26 Sep 2026 04:05:44 +0200 Subject: [PATCH 15/28] the InvestmentFunction of the templates writes no file, which the test of the configurations takes for one that is missing --- pysmspp/data/configs/InvestmentBlock/IFCfg.txt | 11 +++-------- pysmspp/data/configs/TSSBlock/IFCfg.txt | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/pysmspp/data/configs/InvestmentBlock/IFCfg.txt b/pysmspp/data/configs/InvestmentBlock/IFCfg.txt index 435d1d9..2f5bbc1 100644 --- a/pysmspp/data/configs/InvestmentBlock/IFCfg.txt +++ b/pysmspp/data/configs/InvestmentBlock/IFCfg.txt @@ -2,8 +2,7 @@ # - - - - - - - - - - - - - - - - IFCfg.txt - - - - - - - - - - - - - - - - - # # The ComputeConfig of the InvestmentFunction, which the OBlockConfig of the -# InvestmentBlock gives to its Objective [see IBOCfg.txt]: the file where the -# investments and the values of the Function are output, and, in the extra +# InvestmentBlock gives to its Objective [see IBOCfg.txt]: in the extra # Configuration, the BlockSolverConfig of the inner Block, here a UCBlock (or # a TwoStageStochasticBlock of UCBlock). # @@ -18,12 +17,8 @@ ComputeConfig # exact type of the ComputeConfig object 0 # number of double parameters -1 # number of string parameters - -# now all the string parameters -strOutputFilename investment_candidates.txt # where the investment and the - # value of the Function are - # appended at each evaluation +0 # number of string parameters: no strOutputFilename, so the investments + # and the values of the Function are not written to a file 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/TSSBlock/IFCfg.txt b/pysmspp/data/configs/TSSBlock/IFCfg.txt index 11ac1b6..5c4c27f 100644 --- a/pysmspp/data/configs/TSSBlock/IFCfg.txt +++ b/pysmspp/data/configs/TSSBlock/IFCfg.txt @@ -2,8 +2,7 @@ # - - - - - - - - - - - - - - - - IFCfg.txt - - - - - - - - - - - - - - - - - # # The ComputeConfig of the InvestmentFunction, which the OBlockConfig of the -# InvestmentBlock gives to its Objective [see IBOCfg.txt]: the file where the -# investments and the values of the Function are output, and, in the extra +# InvestmentBlock gives to its Objective [see IBOCfg.txt]: in the extra # Configuration, the BlockSolverConfig of the inner Block, here a TSSB, an # MSSB or a UCBlock, whose continuous relaxation Gurobi solves whole. # @@ -18,12 +17,8 @@ ComputeConfig # exact type of the ComputeConfig object 0 # number of double parameters -1 # number of string parameters - -# now all the string parameters -strOutputFilename investment_candidates.txt # where the investment and the - # value of the Function are - # appended at each evaluation +0 # number of string parameters: no strOutputFilename, so the investments + # and the values of the Function are not written to a file 0 # number of vector-of-int parameters From 5df0f6027d86a240f0f7d15a2a416bc6414b2f1b Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sat, 26 Sep 2026 19:49:59 +0200 Subject: [PATCH 16/28] the threads of the BendersDecompositionSolver template are intMaxThread, as for any other Solver --- pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt index 0af50d2..4087704 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt @@ -30,7 +30,7 @@ ComputeConfig # exact type of the ComputeConfig object # now all the integer parameters int_BDSlv_Regime 1 # 0 = convex master, 1 = MILP master -int_BDSlv_MaxThread 8 # threads evaluating the subproblems of a round, at +intMaxThread 8 # threads evaluating the subproblems of a round, at # most the cores of the machine; the run is the same # for every value, only faster, and 1 evaluates them # one after the other From 6d5250b893091d3e015413352901a2d0c1f532ee Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sat, 26 Sep 2026 19:50:02 +0200 Subject: [PATCH 17/28] the SDDPBlock templates are those of the sddp_solver of SMS++, the Lagrangian recipe being the pair -B SDDPBCfg-LD.txt -S SDDPSCfg-LD.txt, which a test checks on the command line --- pysmspp/data/configs/SDDPBlock/ACBCfg.txt | 8 +- pysmspp/data/configs/SDDPBlock/BCfg.txt | 8 +- pysmspp/data/configs/SDDPBlock/BSCfg-sim.txt | 11 ++- pysmspp/data/configs/SDDPBlock/BSPar-LD.txt | 65 ++++++++++------ .../configs/SDDPBlock/BSPar-greedy-LD.txt | 63 +++++++++++----- pysmspp/data/configs/SDDPBlock/BUBCfg.txt | 8 +- .../data/configs/SDDPBlock/BendersBSCfg.txt | 75 ------------------- pysmspp/data/configs/SDDPBlock/DCNBCfg.txt | 15 ++-- pysmspp/data/configs/SDDPBlock/HSUBSCfg.txt | 40 +++------- pysmspp/data/configs/SDDPBlock/IUBCfg-LD.txt | 8 +- .../data/configs/SDDPBlock/InnerBSCfg-sim.txt | 17 ++--- pysmspp/data/configs/SDDPBlock/InnerBSCfg.txt | 13 ++-- pysmspp/data/configs/SDDPBlock/LPBSCfg.txt | 56 ++------------ pysmspp/data/configs/SDDPBlock/MILPCfg-LP.txt | 65 ++++++++++++++++ pysmspp/data/configs/SDDPBlock/MPBCfg.txt | 22 +++--- pysmspp/data/configs/SDDPBlock/OUBSCfg.txt | 56 ++------------ pysmspp/data/configs/SDDPBlock/PFBCfg.txt | 20 +++-- .../data/configs/SDDPBlock/SDDPBCfg-LD.txt | 30 ++++---- pysmspp/data/configs/SDDPBlock/SDDPBCfg.txt | 20 +++-- .../data/configs/SDDPBlock/SDDPSCfg-LD.txt | 26 ++++--- .../configs/SDDPBlock/SDDPSCfg-greedy-LD.txt | 41 +++++++--- pysmspp/data/configs/SDDPBlock/SDDPSCfg.txt | 18 +++-- pysmspp/data/configs/SDDPBlock/SUBCfg.txt | 8 +- pysmspp/data/configs/SDDPBlock/TUBCfg-LD.txt | 8 +- pysmspp/data/configs/SDDPBlock/TUBCfg-OVC.txt | 8 +- pysmspp/data/configs/SDDPBlock/TUBSCfg-DP.txt | 6 +- pysmspp/data/configs/SDDPBlock/UCBSCfg.txt | 13 ++-- .../SDDPBlock/get_var_solution_bundle.txt | 26 ------- test/test_smspp_tools.py | 31 +++++++- 29 files changed, 370 insertions(+), 415 deletions(-) delete mode 100644 pysmspp/data/configs/SDDPBlock/BendersBSCfg.txt create mode 100644 pysmspp/data/configs/SDDPBlock/MILPCfg-LP.txt delete mode 100644 pysmspp/data/configs/SDDPBlock/get_var_solution_bundle.txt diff --git a/pysmspp/data/configs/SDDPBlock/ACBCfg.txt b/pysmspp/data/configs/SDDPBlock/ACBCfg.txt index 3137c92..02e42d6 100644 --- a/pysmspp/data/configs/SDDPBlock/ACBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/ACBCfg.txt @@ -1,10 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - ACBCfg.txt- - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - ACBCfg.txt - - - - - - - - - - - - - - - - # # A txt description of a BlockConfig for all the NetworkBlock of a UCBlock # -# Antonio Frangioni -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -12,7 +10,9 @@ BlockConfig 1 # the BlockConfig is differential + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -52,5 +52,5 @@ SimpleConfiguration> * # none # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - END ACBCfg.txt- - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END ACBCfg.txt - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/BCfg.txt b/pysmspp/data/configs/SDDPBlock/BCfg.txt index 476706a..c25d3f5 100644 --- a/pysmspp/data/configs/SDDPBlock/BCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/BCfg.txt @@ -1,19 +1,19 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - -BCfg.txt - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - BCfg.txt - - - - - - - - - - - - - - - - # # A txt description of the default BlockConfig for any Block of the inner # Block of each stage of the SDDPBlock for which SDDPBCfg[-LD].txt has no # class-specific entry: it only sets the is_feasible() tolerances. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -46,5 +46,5 @@ SimpleConfiguration> * # [none] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - END BCfg.txt- - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - END BCfg.txt - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/BSCfg-sim.txt b/pysmspp/data/configs/SDDPBlock/BSCfg-sim.txt index c8e0b1b..88252d4 100644 --- a/pysmspp/data/configs/SDDPBlock/BSCfg-sim.txt +++ b/pysmspp/data/configs/SDDPBlock/BSCfg-sim.txt @@ -1,5 +1,5 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - BSCfg-sim.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - BSCfg-sim.txt - - - - - - - - - - - - - - - # # A txt description of a BlockSolverConfig for a SDDPGreedySolver to be used # to simulate the SDDPBlock instances in this directory: the inner Block of @@ -7,8 +7,6 @@ # solved, so that the callback of sddp_solver can still update the data # linking two consecutive stages (e.g. ThermalUnitBlock init up/down time). # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -35,7 +33,8 @@ ComputeConfig # exact type of the ComputeConfig object # now all the integer parameters intLogVerb 1 # log verbosity -intUnregisterSolver 1 # unregister the Solver of the inner Block after solving it +intUnregisterSolver 1 # unregister the Solver of the inner Block after + # solving it 0 # number of double parameters @@ -45,7 +44,7 @@ intUnregisterSolver 1 # unregister the Solver of the inner Block after solving i 1 # number of string parameters # now all the string parameters -strInnerBSC config/UCBSCfg.txt # BlockSolverConfig for the UCBlock +strInnerBSC UCBSCfg.txt # BlockSolverConfig for the UCBlock 0 # number of vector-of-int parameters @@ -70,5 +69,5 @@ strInnerBSC config/UCBSCfg.txt # BlockSolverConfig for the UCBlock # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END BSCfg-sim.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END BSCfg-sim.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt b/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt index 3e80a6f..d9c85b2 100644 --- a/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt @@ -1,11 +1,9 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - BSPar-LD.txt- - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - BSPar-LD.txt - - - - - - - - - - - - - - - # # A txt description of a BlockSolverConfig for a UCBlock to be solved by a # LagrangianDualSolver using a BundleSolver as the inner Solver # -# Enrico Gorgone, Antonio Frangioni, Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -64,37 +62,46 @@ ComputeConfig # exact type of the ComputeConfig object 18 # number of integer parameters # now all the integer parameters -intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly + # stabilized intDoEasy 15 # do easy components for (some) LagBFunction intMaxIter 200 # max number of iterations for each call intMaxThread 1 # MaxThread, max number of new tasks to spawn intLogVerb 15 # log verbosity of main Bundle algorithm intFrcLstSS 2 intWZNorm 10 # which norm to use in the norm-based stopping condition -intBPar1 20 # discard items when they have been useless for iterations +intBPar1 20 # discard items when they have been useless for + # iterations intBPar2 1000 # max bundle size per component intBPar3 1 # max n. of items to fetch from Fi() at each iteration intBPar4 1 # min n. of items to fetch from Fi() at each iteration -intBPar6 0 # second parameter for dynamic max n. of items per iteration +intBPar6 0 # second parameter for dynamic max n. of items per + # iteration intBPar7 15 # how to deal with the global pools -intMnSSC 0 # min number of consecutive SS with the same t for a t increase -intMnNSC 1 # min number of consecutive NS with the same t for a t decrease -inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) +intMnSSC 0 # min number of consecutive SS with the same t for a t + # increase +intMnNSC 1 # min number of consecutive NS with the same t for a t + # decrease +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = + # balancing) intMaxNrEvls 2 # maximum number of function evaluations at each iteration # OSiMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - intRstAlg 2 # parameter to handle the reset of the algorithm -#int_InnerS_WVarSCfg 0 # set by sddp_solver with the -z (hydro-easy) option 15 # number of double parameters # now all the double parameters dblRelAcc 1e-8 # relative accuracy required to solution -dblNZEps 1e-8 # stopping parameter: threshold to declare 0 the || residual || -dbltStar 1e3 # stopping parameter: multiplied to || residual || to estimate gap +dblNZEps 1e-8 # stopping parameter: threshold to declare 0 the || + # residual || +dbltStar 1e3 # stopping parameter: multiplied to || residual || to + # estimate gap dblBPar5 4 # first parameter for dynamic max n. of items per iteration -dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* -dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* +dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | + # m1 | v* +dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - + # m2 ) v* dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || dblmxIncr 10 # max increase of t dblmnIncr 1.5 # min increase of t (each time it is increased) @@ -108,11 +115,15 @@ dbltSPar2 1e-2 # parameter for the long-term t-strategy 3 # number of string parameters # now all the string parameters -str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver -#str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver -str_LagBF_BSCfg config/InnerBSCfg.txt # meta BlockSolverConfig for the LagBFunctions, - # dispatched by inner Block classname() -strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver +str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by + # LagrangianDualSolver +#str_LDSlv_ISName BundleSolver # the inner Solver used by + # LagrangianDualSolver +str_LagBF_BSCfg InnerBSCfg.txt # meta BlockSolverConfig for the + # LagBFunctions, dispatched by inner + # Block classname() +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's + # Solver 0 # number of vector-of-int parameters @@ -124,10 +135,20 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's So # now all the vector-of-double parameters # [none] -0 # number of vector-of-string parameters +3 # number of vector-of-string parameters # now all the vector-of-string parameters -# [none] +# the components that are never "easy": the ThermalUnitBlock, which have +# their own Solver, and the HydroSystemUnitBlock, whose primal solution (the +# final volume of the reservoirs) the SDDPSolver needs and which is not +# provided for the easy components +vstr_LDSl_NoEasy 2 ThermalUnitBlock HydroSystemUnitBlock + +# the only component whose primal and dual solution the SDDPSolver needs: +# the final volume of the reservoirs, and the duals of the constraints of +# the HydroSystemUnitBlock that the BendersBFunction handles +vstr_LDSl_VarSol 1 HydroSystemUnitBlock +vstr_LDSl_DualSol 1 HydroSystemUnitBlock # pointer to the "extra" Configuration * # [none] @@ -137,5 +158,5 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's So # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - -END BSPar-LD.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END BSPar-LD.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt b/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt index 3e8f256..448cec4 100644 --- a/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt @@ -4,8 +4,6 @@ # A txt description of a BlockSolverConfig for a UCBlock to be solved by a # LagrangianDualSolver using a BundleSolver as the inner Solver # -# Enrico Gorgone, Antonio Frangioni, Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -32,22 +30,28 @@ ComputeConfig # exact type of the ComputeConfig object 17 # number of integer parameters # now all the integer parameters -intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly + # stabilized intDoEasy 15 # do easy components for (some) LagBFunction intMaxIter 10000 # max number of iterations for each call intMaxThread 36 # MaxThread, max number of new tasks to spawn intLogVerb 2 # log verbosity of main Bundle algorithm intWZNorm 2 # which norm to use in the norm-based stopping condition -intBPar1 20 # discard items when they have been useless for iterations +intBPar1 20 # discard items when they have been useless for + # iterations intBPar2 1000 # max bundle size per component intBPar3 1 # max n. of items to fetch from Fi() at each iteration intBPar4 1 # min n. of items to fetch from Fi() at each iteration -intBPar6 0 # second parameter for dynamic max n. of items per iteration +intBPar6 0 # second parameter for dynamic max n. of items per + # iteration intBPar7 11 # how to deal with the global pools -intMnSSC 0 # min number of consecutive SS with the same t for a t increase -intMnNSC 1 # min number of consecutive NS with the same t for a t decrease -inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) +intMnSSC 0 # min number of consecutive SS with the same t for a t + # increase +intMnNSC 1 # min number of consecutive NS with the same t for a t + # decrease +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = + # balancing) intMaxNrEvls 2 # maximum number of function evaluations at each iteration # OSiMPSolver's parameters :- - - - - - - - - - - - - - - - - - - - - - - - - @@ -57,11 +61,15 @@ intRstAlg 2 # parameter to handle the reset of the algorithm # now all the double parameters dblRelAcc 1e-4 # relative accuracy required to solution -dblNZEps 1e+4 # stopping parameter: threshold to declare 0 the || residual || -dbltStar -100 # stopping parameter: multiplied to || residual || to estimate gap +dblNZEps 1e+4 # stopping parameter: threshold to declare 0 the || + # residual || +dbltStar -100 # stopping parameter: multiplied to || residual || to + # estimate gap dblBPar5 4 # first parameter for dynamic max n. of items per iteration -dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* -dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* +dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | + # m1 | v* +dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - + # m2 ) v* dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || dblmxIncr 10 # max increase of t dblmnIncr 1.5 # min increase of t (each time it is increased) @@ -75,11 +83,15 @@ dbltSPar2 1e-2 # parameter for the long-term t-strategy 3 # number of string parameters # now all the string parameters -str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by LagrangianDualSolver -#str_LDSlv_ISName BundleSolver # the inner Solver used by LagrangianDualSolver -str_LagBF_BSCfg config/InnerBSCfg-sim.txt # meta BlockSolverConfig for the LagBFunctions, - # dispatched by inner Block classname() -strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver +str_LDSlv_ISName ParallelBundleSolver # the inner Solver used by + # LagrangianDualSolver +#str_LDSlv_ISName BundleSolver # the inner Solver used by + # LagrangianDualSolver +str_LagBF_BSCfg InnerBSCfg-sim.txt # meta BlockSolverConfig for the + # LagBFunctions, dispatched by + # inner Block classname() +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's + # Solver 0 # number of vector-of-int parameters @@ -91,10 +103,21 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's So # now all the vector-of-double parameters # [none] -0 # number of vector-of-string parameters +2 # number of vector-of-string parameters # now all the vector-of-string parameters -# [none] +# the components that are never "easy": the ThermalUnitBlock, which have +# their own Solver, and all those whose primal solution the simulation needs, +# since it is not provided for the easy components: the units that link two +# consecutive stages, and the NetworkBlock, part of the output +vstr_LDSl_NoEasy 9 ThermalUnitBlock HydroSystemUnitBlock BatteryUnitBlock + IntermittentUnitBlock DCNetworkBlock ACNetworkBlock + ECNetworkBlock OTSNetworkBlock DesignNetworkBlock + +# the same components are those whose primal solution the simulation needs +vstr_LDSl_VarSol 9 ThermalUnitBlock HydroSystemUnitBlock BatteryUnitBlock + IntermittentUnitBlock DCNetworkBlock ACNetworkBlock + ECNetworkBlock OTSNetworkBlock DesignNetworkBlock # pointer to the "extra" Configuration * # [none] @@ -104,5 +127,5 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's So # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - -END BSPar-greedy-LD.txt- - - - - - - - - - - - - +# - - - - - - - - - - - - - END BSPar-greedy-LD.txt - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/BUBCfg.txt b/pysmspp/data/configs/SDDPBlock/BUBCfg.txt index 6b84c38..ba3d154 100644 --- a/pysmspp/data/configs/SDDPBlock/BUBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/BUBCfg.txt @@ -1,20 +1,20 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - BUBCfg.txt- - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - BUBCfg.txt - - - - - - - - - - - - - - - - # # A txt description of the BlockConfig for a BatteryUnitBlock: no negative # prices (static variables Configuration == 0), bound constraints generated # as OneVarConstraints (static constraints Configuration == 1), plus the # is_feasible() tolerances. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -49,5 +49,5 @@ SimpleConfiguration> * # [none] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - END BUBCfg.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END BUBCfg.txt - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/BendersBSCfg.txt b/pysmspp/data/configs/SDDPBlock/BendersBSCfg.txt deleted file mode 100644 index 4c0fd58..0000000 --- a/pysmspp/data/configs/SDDPBlock/BendersBSCfg.txt +++ /dev/null @@ -1,75 +0,0 @@ -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - BendersBSCfg.txt- - - - - - - - - - - - - - - - -# -# A txt description of the default BlockSolverConfig for the inner Block of -# each BendersBFunction of the SDDPBlock, used by build_BlockConfig() of -# sddp_solver when no BlockConfig (-B) and no BlockSolverConfig (-S) are -# provided: the continuous relaxation is solved by CPXMILPSolver with -# presolve disabled, throwing an exception if reduced costs are not -# available. -# -# Donato Meoli -# -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -BlockSolverConfig # exact type of the Configuration object - -1 # the BlockSolverConfig is a "differential" one - -1 # number of (the names of) Solver in this BlockSolverConfig -# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - -CPXMILPSolver # name of 1st Solver - -1 # number of ComputeConfig in this BlockSolverConfig - -# now all the ComputeConfig -# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# ComputeConfig of the CPXMILPSolver - -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -2 # number of integer parameters - -# now all the integer parameters -CPXPARAM_Preprocessing_Presolve 0 # disable presolve -intThrowReducedCostException 1 # throw if reduced costs are unavailable - -0 # number of double parameters - -# now all the double parameters -# [none] - -0 # number of string parameters - -# now all the string parameters -# [none] - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] - -# pointer to the "extra" Configuration -* # [none] - -# end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - -# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - END BendersBSCfg.txt- - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/DCNBCfg.txt b/pysmspp/data/configs/SDDPBlock/DCNBCfg.txt index 1f206b5..c200d76 100644 --- a/pysmspp/data/configs/SDDPBlock/DCNBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/DCNBCfg.txt @@ -1,18 +1,19 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - DCNBCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - DCNBCfg.txt - - - - - - - - - - - - - - - - # # A txt description of a BlockConfig for all the DCNetworkBlock of a UCBlock, -# selecting the network formulation (read by DCNetworkBlock::generate_abstract_ -# variables). A no-op on instances without a DCNetworkBlock. -# -# Donato Meoli +# selecting the network formulation (read by +# DCNetworkBlock::generate_abstract_ variables). A no-op on instances without +# a DCNetworkBlock. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -46,5 +47,5 @@ SimpleConfiguration * # [none] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - END DCNBCfg.txt - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file +# - - - - - - - - - - - - - - - END DCNBCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/HSUBSCfg.txt b/pysmspp/data/configs/SDDPBlock/HSUBSCfg.txt index 3652bc4..cff9e5d 100644 --- a/pysmspp/data/configs/SDDPBlock/HSUBSCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/HSUBSCfg.txt @@ -1,11 +1,11 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - HSUBSCfg.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - HSUBSCfg.txt - - - - - - - - - - - - - - - # # A txt description of the BlockSolverConfig for a HydroSystemUnitBlock # inside the Lagrangian decomposition of the UCBlock of each stage of the -# SDDPBlock: the hydro subproblem is solved as an LP by CPXMILPSolver. -# -# Rafael Durbano Lobato, Donato Meoli +# SDDPBlock: the hydro subproblem is solved as an LP by CPXMILPSolver, +# with the ComputeConfig of the shared MILPCfg-LP.txt, of which only +# CPXPARAM_Parallel is overridden here. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -24,36 +24,20 @@ CPXMILPSolver # name of 1st Solver # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ComputeConfig of the CPXMILPSolver -ComputeConfig # exact type of the ComputeConfig object +*MILPCfg-LP.txt + -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed +1 # f_diff == 1 ==> only the entries below are changed -7 # number of integer parameters +1 # number of integer parameters # now all the integer parameters -intLogVerb 0 # log verbosity CPXPARAM_Parallel 0 # parallel mode -CPXPARAM_Threads 1 # number of threads -CPXPARAM_LPMethod 2 # dual simplex -CPXPARAM_Read_Scale 1 # aggressive scaling -CPX_PARAM_NUMERICALEMPHASIS 1 # numerical emphasis -CPXPARAM_SolutionType 2 # basic solution -#CPXPARAM_Preprocessing_Presolve 0 -#intThrowReducedCostException 1 - -1 # number of double parameters +#strOutputFile hydro.lp -# now all the double parameters -CPXPARAM_Simplex_Tolerances_Optimality 1e-9 # optimality tolerance -#dblAAccSol 1e-04 -#dblMaxTime 20000 +0 # number of double parameters 0 # number of string parameters -# now all the string parameters -#strOutputFile hydro.lp - 0 # number of vector-of-int parameters # now all the vector-of-int parameters @@ -69,13 +53,13 @@ CPXPARAM_Simplex_Tolerances_Optimality 1e-9 # optimality tolerance # now all the vector-of-string parameters # [none] -# pointer to the "extra" Configuration -* # [none] +# the "extra" Configuration slot is left out on purpose: an override block +# that ends here keeps the one of the base # end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - END HSUBSCfg.txt- - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END HSUBSCfg.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/IUBCfg-LD.txt b/pysmspp/data/configs/SDDPBlock/IUBCfg-LD.txt index 8f5553e..ea8a1d0 100644 --- a/pysmspp/data/configs/SDDPBlock/IUBCfg-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/IUBCfg-LD.txt @@ -1,20 +1,20 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - IUBCfg-LD.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - IUBCfg-LD.txt - - - - - - - - - - - - - - - # # A txt description of the BlockConfig for an IntermittentUnitBlock when the # SDDPBlock is solved via LagrangianDualSolver: any zero value that the # maximum power may assume is replaced by the (tiny) value given by the # extra Configuration, plus the is_feasible() tolerances. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -48,5 +48,5 @@ SimpleConfiguration 1e-16 # replaces any zero value of the maximum power # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END IUBCfg-LD.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END IUBCfg-LD.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/InnerBSCfg-sim.txt b/pysmspp/data/configs/SDDPBlock/InnerBSCfg-sim.txt index 3aa83f5..1d2e0b0 100644 --- a/pysmspp/data/configs/SDDPBlock/InnerBSCfg-sim.txt +++ b/pysmspp/data/configs/SDDPBlock/InnerBSCfg-sim.txt @@ -1,5 +1,5 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - InnerBSCfg-sim.txt- - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - InnerBSCfg-sim.txt - - - - - - - - - - - - - - # # A "meta" BlockSolverConfig for the LagrangianDualSolver (str_LagBF_BSCfg): # a map from the classname() of the inner Block of each LagBFunction to the @@ -14,8 +14,6 @@ # All filenames are resolved against the directory the tool is run from # (the root of the tools/sddp_solver directory), as in the other tools. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -23,12 +21,13 @@ SimpleConfiguration> 5 # the number of elements in the map -ThermalUnitBlock *config/TUBSCfg-DP.txt # specialized DP solver -HydroSystemUnitBlock *config/HSUBSCfg.txt # hard component (primal solution needed) -BatteryUnitBlock *config/OUBSCfg.txt # hard component (links two stages) -IntermittentUnitBlock *config/OUBSCfg.txt # hard component (links two stages) -* *config/LPBSCfg.txt # everything else +ThermalUnitBlock *TUBSCfg-DP.txt # specialized DP solver +HydroSystemUnitBlock *HSUBSCfg.txt # hard component (primal solution + # needed) +BatteryUnitBlock *OUBSCfg.txt # hard component (links two stages) +IntermittentUnitBlock *OUBSCfg.txt # hard component (links two stages) +* *LPBSCfg.txt # everything else # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - END InnerBSCfg-sim.txt- - - - - - - - - - - - - - +# - - - - - - - - - - - - - END InnerBSCfg-sim.txt - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/InnerBSCfg.txt b/pysmspp/data/configs/SDDPBlock/InnerBSCfg.txt index ed91918..bdf6a5d 100644 --- a/pysmspp/data/configs/SDDPBlock/InnerBSCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/InnerBSCfg.txt @@ -1,5 +1,5 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - InnerBSCfg.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - InnerBSCfg.txt - - - - - - - - - - - - - - - # # A "meta" BlockSolverConfig for the LagrangianDualSolver (str_LagBF_BSCfg): # a map from the classname() of the inner Block of each LagBFunction to the @@ -12,8 +12,6 @@ # All filenames are resolved against the directory the tool is run from # (the root of the tools/sddp_solver directory), as in the other tools. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -21,10 +19,11 @@ SimpleConfiguration> 3 # the number of elements in the map -ThermalUnitBlock *config/TUBSCfg-DP.txt # specialized DP solver -HydroSystemUnitBlock *config/HSUBSCfg.txt # hard component (primal solution needed) -* *config/LPBSCfg.txt # everything else +ThermalUnitBlock *TUBSCfg-DP.txt # specialized DP solver +HydroSystemUnitBlock *HSUBSCfg.txt # hard component (primal solution + # needed) +* *LPBSCfg.txt # everything else # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END InnerBSCfg.txt- - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END InnerBSCfg.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/LPBSCfg.txt b/pysmspp/data/configs/SDDPBlock/LPBSCfg.txt index 0a8fccf..434e77e 100644 --- a/pysmspp/data/configs/SDDPBlock/LPBSCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/LPBSCfg.txt @@ -4,9 +4,8 @@ # A txt description of the default BlockSolverConfig for any other Block # (e.g., a PolyhedralFunctionBlock, a NetworkBlock) inside the Lagrangian # decomposition of the UCBlock of each stage of the SDDPBlock: the -# subproblem is solved as an LP by HiGHSMILPSolver. -# -# Rafael Durbano Lobato, Donato Meoli +# subproblem is solved as an LP by CPXMILPSolver, with the ComputeConfig +# of the shared MILPCfg-LP.txt. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -17,60 +16,15 @@ BlockSolverConfig # exact type of the Configuration object 1 # number of (the names of) Solver in this BlockSolverConfig # now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - -HiGHSMILPSolver # name of 1st Solver +CPXMILPSolver # name of 1st Solver 1 # number of ComputeConfig in this BlockSolverConfig # now all the ComputeConfig # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# ComputeConfig of the HiGHSMILPSolver - -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -0 # number of integer parameters - -# now all the integer parameters -intLogVerb 0 # log verbosity -#CPXPARAM_Threads 1 # number of threads -#CPXPARAM_LPMethod 2 # dual simplex -#CPXPARAM_Read_Scale 1 # aggressive scaling -#CPX_PARAM_NUMERICALEMPHASIS 1 # numerical emphasis -#CPXPARAM_SolutionType 2 # basic solution -#CPXPARAM_Preprocessing_Presolve 0 -#intThrowReducedCostException 1 - -0 # number of double parameters - -# now all the double parameters -#CPXPARAM_Simplex_Tolerances_Optimality 1e-9 # optimality tolerance -#dblAAccSol 1e-04 -#dblMaxTime 20000 - -0 # number of string parameters - -# now all the string parameters -#strOutputFile lp.lp - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] +# ComputeConfig of the CPXMILPSolver -# pointer to the "extra" Configuration -* # [none] +*MILPCfg-LP.txt # end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/MILPCfg-LP.txt b/pysmspp/data/configs/SDDPBlock/MILPCfg-LP.txt new file mode 100644 index 0000000..99cbad8 --- /dev/null +++ b/pysmspp/data/configs/SDDPBlock/MILPCfg-LP.txt @@ -0,0 +1,65 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - MILPCfg-LP.txt - - - - - - - - - - - - - - - +# +# A txt description of the ComputeConfig of the CPXMILPSolver that solves, +# as an LP, the subproblems of the Lagrangian decomposition of the UCBlock +# of each stage of the SDDPBlock. It is the same for every subproblem, so +# the BlockSolverConfig that register that Solver include this file rather +# than repeating it: LPBSCfg.txt and OUBSCfg.txt take it as it is, while +# HSUBSCfg.txt takes it and overrides the one entry it needs on top. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +6 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity +CPXPARAM_Threads 1 # number of threads +CPXPARAM_LPMethod 2 # dual simplex +CPXPARAM_Read_Scale 1 # aggressive scaling +CPX_PARAM_NUMERICALEMPHASIS 1 # numerical emphasis +CPXPARAM_SolutionType 2 # basic solution +#CPXPARAM_Preprocessing_Presolve 0 +#intThrowReducedCostException 1 + +1 # number of double parameters + +# now all the double parameters +CPXPARAM_Simplex_Tolerances_Optimality 1e-9 # optimality tolerance +#dblAAccSol 1e-04 +#dblMaxTime 20000 + +0 # number of string parameters + +# now all the string parameters +#strOutputFile lp.lp + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END MILPCfg-LP.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/MPBCfg.txt b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt index 1b49e06..46b9f02 100644 --- a/pysmspp/data/configs/SDDPBlock/MPBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/MPBCfg.txt @@ -1,5 +1,5 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - MPBCfg.txt- - - - - - - - - - - - - - - - - # # A txt description of a BlockSolverConfig for the inner :MILPSolver of the # MasterProblemBlock used by the BundleSolver @@ -40,17 +40,19 @@ intCutSepPar 7 # separate user cuts + lazy constraints intMaxThread 1 # single-threaded for deterministic master reproducibility # All specific CPLEX parameter (uncomment based on Solver) -#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = + # barrier #CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis # All specific GUROBI parameter (uncomment based on Solver) -#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers - # of the master ARE the algorithm, and an interior point has - # them only to about 1e-7 relative, which the stopping test - # of the bundle cannot survive; besides, the barrier cannot - # restart from the previous basis, so it re-solves the master - # from scratch at every call, while the simplex re-optimises - # after the new columns for a fraction of the iterations +#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the + # multipliers of the master ARE the algorithm, and an + # interior point has them only to about 1e-7 relative, + # which the stopping test of the bundle cannot survive; + # besides, the barrier cannot restart from the previous + # basis, so it re-solves the master from scratch at every + # call, while the simplex re-optimises after the new + # columns for a fraction of the iterations #NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master # is small and re-solved thousands of times, so whatever # extra care is asked is paid at every one of them, and 3 @@ -117,5 +119,5 @@ dblRAccSol 1e-08 # relative accuracy of the solution pool # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END MPBCfg.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END MPBCfg.txt- - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/OUBSCfg.txt b/pysmspp/data/configs/SDDPBlock/OUBSCfg.txt index 1fcbcba..a22564f 100644 --- a/pysmspp/data/configs/SDDPBlock/OUBSCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/OUBSCfg.txt @@ -4,9 +4,8 @@ # A txt description of the BlockSolverConfig for any other UnitBlock (e.g., # BatteryUnitBlock, IntermittentUnitBlock) inside the Lagrangian # decomposition of the UCBlock of each stage of the SDDPBlock: the -# subproblem is solved as an LP by HiGHSMILPSolver. -# -# Rafael Durbano Lobato, Donato Meoli +# subproblem is solved as an LP by CPXMILPSolver, with the ComputeConfig +# of the shared MILPCfg-LP.txt. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -17,60 +16,15 @@ BlockSolverConfig # exact type of the Configuration object 1 # number of (the names of) Solver in this BlockSolverConfig # now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - -HiGHSMILPSolver # name of 1st Solver +CPXMILPSolver # name of 1st Solver 1 # number of ComputeConfig in this BlockSolverConfig # now all the ComputeConfig # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# ComputeConfig of the HiGHSMILPSolver - -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -0 # number of integer parameters - -# now all the integer parameters -intLogVerb 0 # log verbosity -#CPXPARAM_Threads 1 # number of threads -#CPXPARAM_LPMethod 2 # dual simplex -#CPXPARAM_Read_Scale 1 # aggressive scaling -#CPX_PARAM_NUMERICALEMPHASIS 1 # numerical emphasis -#CPXPARAM_SolutionType 2 # basic solution -#CPXPARAM_Preprocessing_Presolve 0 -#intThrowReducedCostException 1 - -0 # number of double parameters - -# now all the double parameters -#CPXPARAM_Simplex_Tolerances_Optimality 1e-9 # optimality tolerance -#dblAAccSol 1e-04 -#dblMaxTime 20000 - -0 # number of string parameters - -# now all the string parameters -#strOutputFile other.lp - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] +# ComputeConfig of the CPXMILPSolver -# pointer to the "extra" Configuration -* # [none] +*MILPCfg-LP.txt # end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/PFBCfg.txt b/pysmspp/data/configs/SDDPBlock/PFBCfg.txt index 4cdb26c..17feaeb 100644 --- a/pysmspp/data/configs/SDDPBlock/PFBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/PFBCfg.txt @@ -1,11 +1,10 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - PFBCfg.txt- - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - PFBCfg.txt - - - - - - - - - - - - - - - - # # A txt description of the BlockConfig for a PolyhedralFunctionBlock: the # "linearized" representation of the PolyhedralFunction is used (static -# variables Configuration == 1), plus the is_feasible() tolerances. -# -# Donato Meoli +# variables Configuration == 1), the is_feasible() tolerances, and the +# cut-processing tolerances of remove_redundant_rows() (extra Configuration). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -13,7 +12,9 @@ BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -43,9 +44,14 @@ SimpleConfiguration> # solution * # [none] -# extra -* # [none] +# extra: the four tolerances of remove_redundant_rows() +SimpleConfiguration> +4 # the number of elements in the vector +0.0 # parallel abs tolerance +0.0 # parallel rel tolerance +0.0 # optimization abs tolerance +0.0 # optimization rel tolerance # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - END PFBCfg.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END PFBCfg.txt - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/SDDPBCfg-LD.txt b/pysmspp/data/configs/SDDPBlock/SDDPBCfg-LD.txt index 980bddf..d37117f 100644 --- a/pysmspp/data/configs/SDDPBlock/SDDPBCfg-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/SDDPBCfg-LD.txt @@ -1,16 +1,12 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - SDDPBCfg-LD.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - SDDPBCfg-LD.txt - - - - - - - - - - - - - - - # # The default "meta" BlockConfig for the inner Block of each stage of the # SDDPBlock when it is solved via LagrangianDualSolver: like SDDPBCfg.txt, # except that the ThermalUnitBlock gets the reserve variables in the # Objective (the reserve demand constraints are dualized) and the -# IntermittentUnitBlock gets the zero-max-power replacement. -# -# All filenames are resolved against the directory the tool is run from -# (the root of the tools/sddp_solver directory), as in the other tools. -# -# Donato Meoli +# IntermittentUnitBlock gets the zero-max-power replacement; also used in +# the simulation (-s -S SDDPSCfg-greedy-LD.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -19,15 +15,17 @@ SimpleConfiguration> 8 # the number of elements in the map -PolyhedralFunctionBlock *config/PFBCfg.txt # linearized representation -SlackUnitBlock *config/SUBCfg.txt # OneVarConstraints -BatteryUnitBlock *config/BUBCfg.txt # OneVarConstraints, no negative prices -ThermalUnitBlock *config/TUBCfg-LD.txt # OneVarConstraints + reserves in Objective -IntermittentUnitBlock *config/IUBCfg-LD.txt # zero-max-power replacement -DCNetworkBlock *config/DCNBCfg.txt # network formulation (KIRCHHOFF) -ACNetworkBlock *config/ACBCfg.txt # AC Network scaling factors -* *config/BCfg.txt # everything else (is_feasible only) +PolyhedralFunctionBlock *PFBCfg.txt # linearized representation +SlackUnitBlock *SUBCfg.txt # OneVarConstraints +BatteryUnitBlock *BUBCfg.txt # OneVarConstraints, no negative + # prices +ThermalUnitBlock *TUBCfg-LD.txt # OneVarConstraints + reserves in + # Objective +IntermittentUnitBlock *IUBCfg-LD.txt # zero-max-power replacement +DCNetworkBlock *DCNBCfg.txt # network formulation (KIRCHHOFF) +ACNetworkBlock *ACBCfg.txt # AC Network scaling factors +* *BCfg.txt # everything else (is_feasible only) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - END SDDPBCfg-LD.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END SDDPBCfg-LD.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/SDDPBCfg.txt b/pysmspp/data/configs/SDDPBlock/SDDPBCfg.txt index 1c5ec6e..a3aaedc 100644 --- a/pysmspp/data/configs/SDDPBlock/SDDPBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/SDDPBCfg.txt @@ -1,5 +1,5 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - SDDPBCfg.txt- - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - SDDPBCfg.txt - - - - - - - - - - - - - - - # # The default "meta" BlockConfig for the inner Block of each stage of the # SDDPBlock: a map from Block classname() to the BlockConfig to be applied @@ -10,8 +10,6 @@ # All filenames are resolved against the directory the tool is run from # (the root of the tools/sddp_solver directory), as in the other tools. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -19,14 +17,14 @@ SimpleConfiguration> 7 # the number of elements in the map -PolyhedralFunctionBlock *PFBCfg.txt # linearized representation -SlackUnitBlock *SUBCfg.txt # OneVarConstraints -BatteryUnitBlock *BUBCfg.txt # OneVarConstraints, no negative prices -ThermalUnitBlock *TUBCfg-OVC.txt # OneVarConstraints -DCNetworkBlock *DCNBCfg.txt # network formulation (KIRCHHOFF) -ACNetworkBlock *ACBCfg.txt # AC Network scaling factors -* *BCfg.txt # everything else (is_feasible only) +PolyhedralFunctionBlock *PFBCfg.txt # linearized representation +SlackUnitBlock *SUBCfg.txt # OneVarConstraints +BatteryUnitBlock *BUBCfg.txt # OneVarConstraints, no negative prices +ThermalUnitBlock *TUBCfg-OVC.txt # OneVarConstraints +DCNetworkBlock *DCNBCfg.txt # network formulation (KIRCHHOFF) +ACNetworkBlock *ACBCfg.txt # AC Network scaling factors +* *BCfg.txt # everything else (is_feasible only) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END SDDPBCfg.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END SDDPBCfg.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt index 9c4fa33..fd49084 100644 --- a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt @@ -1,9 +1,9 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - -SDDPSCfg-LD.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - SDDPSCfg-LD.txt - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a SDDPSolver -# -# Rafael Durbano Lobato +# The BlockSolverConfig of the SDDPBlock whose inner Block of each stage is +# solved via LagrangianDualSolver [see BSPar-LD.txt], to be used with +# -B SDDPBCfg-LD.txt. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -33,10 +33,14 @@ ComputeConfig # exact type of the ComputeConfig object intMaxIter 5 intLogVerb 0 # log verbosity intNStepConv 5 # Frequency at which the convergence is checked -intPrintTime 1 # Indicates whether computational time should be displayed -intNbSimulCheckForConv 5 # Number of simulations considered when checking convergence -intNbSimulForward 5 # Number of simulations considered in the forward pass -intNbSimulBackward 5 # Number of simulations considered in the backward pass +intPrintTime 1 # Indicates whether computational time should be + # displayed +intNbSimulCheckForConv 5 # Number of simulations considered when checking + # convergence +intNbSimulForward 5 # Number of simulations considered in the forward + # pass +intNbSimulBackward 5 # Number of simulations considered in the backward + # pass intOutputFrequency 1 intBackwardSolverIndex 1 intForwardSolverIndex 0 @@ -50,8 +54,8 @@ dblAccuracy 0 # Relative accuracy for declaring a solution optimal 3 # number of string parameters # now all the string parameters -#strInnerBSC config/UCBSCfg.txt # BlockSolverConfig for the UCBlock -strInnerBSC config/BSPar-LD.txt # BlockSolverConfig for the UCBlock +#strInnerBSC UCBSCfg.txt # BlockSolverConfig for the UCBlock +strInnerBSC BSPar-LD.txt # BlockSolverConfig for the UCBlock #strInnerBC uc_blockconfig.txt # BlockConfig for the UCBlock strSubSolverLogFilePrefix sub-log- strOutputFile cuts.txt @@ -79,5 +83,5 @@ strOutputFile cuts.txt # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - -END SDDPSCfg-LD.txt- - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END SDDPSCfg-LD.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt index 0fe2086..d78b9d6 100644 --- a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt @@ -1,9 +1,9 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - SDDPSCfg-greedy-LD.txt- - - - - - - - - - - - - - +# - - - - - - - - - - - - - SDDPSCfg-greedy-LD.txt - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for a SDDPGreedySolver -# -# Rafael Durbano Lobato +# The BlockSolverConfig of the SDDPBlock for the simulation (-s), with the +# inner Block of each stage solved via LagrangianDualSolver [see +# BSPar-greedy-LD.txt], to be used with -B SDDPBCfg-LD.txt. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -33,17 +33,17 @@ ComputeConfig # exact type of the ComputeConfig object # now all the integer parameters intLogVerb 1 # log verbosity # intScenarioId 0 # index of the scenario to be considered -intUnregisterSolver 1 # unregister the Solver of the inner Block after solving it +intUnregisterSolver 1 # unregister the Solver of the inner Block after + # solving it 0 # number of double parameters # now all the double parameters -1 # number of string parameters +0 # number of string parameters # now all the string parameters -strInnerBSC config/BSPar-greedy-LD.txt # BlockSolverConfig for the UCBlock -#strInnerBC uc_blockconfig.txt # BlockConfig for the UCBlock +# [none] 0 # number of vector-of-int parameters @@ -60,13 +60,32 @@ strInnerBSC config/BSPar-greedy-LD.txt # BlockSolverConfig for the UCBloc # now all the vector-of-string parameters # [none] -# pointer to the "extra" Configuration -* # [none] +# pointer to the "extra" Configuration: the Configurations of the inner +# Block of each stage +SimpleConfiguration> +4 # number of elements in this vector + +# the BlockConfig of the inner Block +* # [none] + +# the BlockSolverConfig of the inner Block +*BSPar-greedy-LD.txt + +# the Configuration of get_var_solution(): none, the components whose primal +# solution is needed are named in vstr_LDSl_VarSol of BSPar-greedy-LD.txt +* # [none] + +# the Configuration of get_dual_solution(): only the dual solution of the +# linking constraints of the UCBlock (the -1 not being any sub-Block), those +# of its sub-Blocks are not needed +SimpleConfiguration>> +1 # number of elements in this vector +-1 -1 # end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - END SDDPSCfg-greedy-LD.txt- - - - - - - - - - - - - +# - - - - - - - - - - - - END SDDPSCfg-greedy-LD.txt - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/SDDPSCfg.txt b/pysmspp/data/configs/SDDPBlock/SDDPSCfg.txt index 880a003..86ead4a 100644 --- a/pysmspp/data/configs/SDDPBlock/SDDPSCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/SDDPSCfg.txt @@ -1,10 +1,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - SDDPSCfg.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - SDDPSCfg.txt - - - - - - - - - - - - - - - # # A txt description of a BlockSolverConfig for a SDDPSolver # -# Rafael Durbano Lobato -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -33,10 +31,14 @@ ComputeConfig # exact type of the ComputeConfig object intMaxIter 10 intLogVerb 1 # log verbosity intNStepConv 5 # Frequency at which the convergence is checked -intPrintTime 1 # Indicates whether computational time should be displayed -intNbSimulCheckForConv 5 # Number of simulations considered when checking convergence -intNbSimulForward 1 # Number of simulations considered in the forward pass -intNbSimulBackward 5 # Number of simulations considered in the backward pass +intPrintTime 1 # Indicates whether computational time should be + # displayed +intNbSimulCheckForConv 5 # Number of simulations considered when checking + # convergence +intNbSimulForward 1 # Number of simulations considered in the forward + # pass +intNbSimulBackward 5 # Number of simulations considered in the backward + # pass intOutputFrequency 1 1 # number of double parameters @@ -80,5 +82,5 @@ strFilenameSuffix .0 # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - END SDDPSCfg.txt- - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END SDDPSCfg.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/SUBCfg.txt b/pysmspp/data/configs/SDDPBlock/SUBCfg.txt index 296ffd1..775fd2f 100644 --- a/pysmspp/data/configs/SDDPBlock/SUBCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/SUBCfg.txt @@ -1,19 +1,19 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - SUBCfg.txt- - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - SUBCfg.txt - - - - - - - - - - - - - - - - # # A txt description of the BlockConfig for a SlackUnitBlock: bound # constraints are generated as OneVarConstraints (static constraints # Configuration == 1), plus the is_feasible() tolerances. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -47,5 +47,5 @@ SimpleConfiguration> * # [none] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - END SUBCfg.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END SUBCfg.txt - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/TUBCfg-LD.txt b/pysmspp/data/configs/SDDPBlock/TUBCfg-LD.txt index 8093327..0d09190 100644 --- a/pysmspp/data/configs/SDDPBlock/TUBCfg-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/TUBCfg-LD.txt @@ -1,5 +1,5 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - TUBCfg-LD.txt - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - TUBCfg-LD.txt - - - - - - - - - - - - - - - # # A txt description of the BlockConfig for a ThermalUnitBlock when the # SDDPBlock is solved via LagrangianDualSolver: besides what TUBCfg-OVC.txt @@ -7,15 +7,15 @@ # the Objective (objective Configuration == 3), since the reserve demand # constraints of the UCBlock are dualized. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -50,5 +50,5 @@ SimpleConfiguration> * # [none] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END TUBCfg-LD.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END TUBCfg-LD.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/TUBCfg-OVC.txt b/pysmspp/data/configs/SDDPBlock/TUBCfg-OVC.txt index 12886b4..2b1f946 100644 --- a/pysmspp/data/configs/SDDPBlock/TUBCfg-OVC.txt +++ b/pysmspp/data/configs/SDDPBlock/TUBCfg-OVC.txt @@ -1,19 +1,19 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - TUBCfg-OVC.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - TUBCfg-OVC.txt - - - - - - - - - - - - - - - # # A txt description of the BlockConfig for a ThermalUnitBlock: bound # constraints are generated as OneVarConstraints (static constraints # Configuration == 1), plus the is_feasible() tolerances. # -# Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockConfig # exact type of the Configuration object 1 # the BlockConfig is a "differential" one + 2 # version of the BlockConfig format + # the Configuration for the structure, i.e., the tree of sub-Block * # [none] @@ -47,5 +47,5 @@ SimpleConfiguration> * # [none] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END TUBCfg-OVC.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END TUBCfg-OVC.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/TUBSCfg-DP.txt b/pysmspp/data/configs/SDDPBlock/TUBSCfg-DP.txt index db4273b..d20e7e4 100644 --- a/pysmspp/data/configs/SDDPBlock/TUBSCfg-DP.txt +++ b/pysmspp/data/configs/SDDPBlock/TUBSCfg-DP.txt @@ -1,13 +1,11 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - TUBSCfg-DP.txt- - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - TUBSCfg-DP.txt - - - - - - - - - - - - - - - # # A txt description of the BlockSolverConfig for a ThermalUnitBlock inside # the Lagrangian decomposition of the UCBlock of each stage of the # SDDPBlock: each thermal unit subproblem is solved by the specialized # ThermalUnitExtDPSolver. # -# Rafael Durbano Lobato, Donato Meoli -# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -68,5 +66,5 @@ intLogVerb 0 # log verbosity # end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - END TUBSCfg-DP.txt- - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END TUBSCfg-DP.txt - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/UCBSCfg.txt b/pysmspp/data/configs/SDDPBlock/UCBSCfg.txt index 4f88843..6ae0b97 100644 --- a/pysmspp/data/configs/SDDPBlock/UCBSCfg.txt +++ b/pysmspp/data/configs/SDDPBlock/UCBSCfg.txt @@ -3,9 +3,7 @@ # # A txt description of the BlockSolverConfig for the inner Block (a UCBlock) # of each stage of the SDDPBlock: the continuous relaxation is solved as a -# whole by CPXMILPSolver. -# -# Rafael Durbano Lobato, Donato Meoli +# whole by a :MILPSolver. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -16,13 +14,15 @@ BlockSolverConfig # exact type of the Configuration object 1 # number of (the names of) Solver in this BlockSolverConfig # now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - -HiGHSMILPSolver # name of 1st Solver +#CPXMILPSolver # name of 1st Solver +#GRBMILPSolver # name of 1st Solver +HiGHSMILPSolver # name of 1st Solver 1 # number of ComputeConfig in this BlockSolverConfig # now all the ComputeConfig # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# ComputeConfig of the CPXMILPSolver +# ComputeConfig of the :MILPSolver ComputeConfig # exact type of the ComputeConfig object @@ -34,7 +34,8 @@ ComputeConfig # exact type of the ComputeConfig object # now all the integer parameters intLogVerb 0 # log verbosity intRelaxIntVars 1 # relax the integrality constraints -# CPXPARAM_Threads 1 # number of threads +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_Threads 1 # number of threads 0 # number of double parameters diff --git a/pysmspp/data/configs/SDDPBlock/get_var_solution_bundle.txt b/pysmspp/data/configs/SDDPBlock/get_var_solution_bundle.txt deleted file mode 100644 index 931ab74..0000000 --- a/pysmspp/data/configs/SDDPBlock/get_var_solution_bundle.txt +++ /dev/null @@ -1,26 +0,0 @@ -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - get_var_solution_bundle.txt - - - - - - - - - - - - -# -# A txt description of the Configuration to be passed to get_var_solution() -# of the [Parallel]BundleSolver when the HydroSystemUnitBlock is treated as -# an easy component (see the -z option of sddp_solver): the primal solution -# of the easy component, which lives in the master problem, is recovered for -# the component with the given index. -# -# Note: the component index below assumes that the HydroSystemUnitBlock is -# the first (index 0) sub-Block of the UCBlock of each stage. -# -# Rafael Durbano Lobato, Donato Meoli -# -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SimpleConfiguration>> - -1 # number of elements in this vector - -0 1 # component index, get duals - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - END get_var_solution_bundle.txt - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/test_smspp_tools.py b/test/test_smspp_tools.py index 3d009e4..53e0b4d 100644 --- a/test/test_smspp_tools.py +++ b/test/test_smspp_tools.py @@ -1,9 +1,10 @@ import sys +from pathlib import Path import numpy as np import pytest -from pysmspp import InvestmentBlockSolver, SMSPPSolverTool, UCBlockSolver +from pysmspp import InvestmentBlockSolver, SDDPSolver, SMSPPSolverTool, UCBlockSolver class FakeSolver(SMSPPSolverTool): @@ -87,3 +88,31 @@ def test_investment_status_is_not_the_value(): assert solver.status_code == 18 assert not solver.is_optimal assert solver.status.startswith("Failed") + + +def test_sddp_lagrangian_recipe_passes_its_block_config(): + """The Lagrangian recipe of the SDDPBlock templates is the pair -B -S: + without -B the tool reads its default SDDPBCfg.txt, i.e., the formulation + of the units for the linear programs, whatever -S says.""" + from pysmspp import SMSConfig + + configfile = SMSConfig(template="SDDPBlock/SDDPSCfg-LD.txt") + training = SDDPSolver( + fp_network="net/SDDPBlock.nc4", + configfile=str(configfile), + B="SDDPBCfg-LD.txt", + ).calculate_executable_call() + simulation = SDDPSolver( + fp_network="net/SDDPBlock.nc4", + configfile=str(configfile).replace("SDDPSCfg-LD", "SDDPSCfg-greedy-LD"), + s=None, + B="SDDPBCfg-LD.txt", + ).calculate_executable_call() + + for command in (training, simulation): + assert command[command.index("-B") + 1] == "SDDPBCfg-LD.txt" + configdir = command[command.index("-c") + 1] + for name in ("SDDPBCfg-LD.txt", command[command.index("-S") + 1]): + assert (Path(configdir) / name).is_file() + assert "-s" in simulation + assert simulation[simulation.index("-S") + 1] == "SDDPSCfg-greedy-LD.txt" From c8a32889d26d8853bf24f90978aa1bc802e7897e Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sun, 27 Sep 2026 11:00:16 +0200 Subject: [PATCH 18/28] the nested forms have their templates: BDS whose subproblems are solved by the recursive Lagrangian dual, with a MILP or a bundle master, and the InvestmentBlock with it inside --- pysmspp/data/configs/README.md | 2 +- .../data/configs/TSSBlock/BDSCfg-CVX-LD.txt | 38 ++++++ pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt | 35 ++++++ pysmspp/data/configs/TSSBlock/BDSCfg.txt | 56 +++++++++ pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt | 117 ++++++++++++++++++ pysmspp/data/configs/TSSBlock/IBOCfg-LD.txt | 54 ++++++++ pysmspp/data/configs/TSSBlock/IFCfg-LD.txt | 36 ++++++ .../data/configs/TSSBlock/InnerBCfg-LD.txt | 22 ++++ .../configs/TSSBlock/TSSBSCfg-BDS-CVX-LD.txt | 32 +++++ .../data/configs/TSSBlock/TSSBSCfg-BDS-LD.txt | 32 +++++ .../data/configs/TSSBlock/TSSBSCfg-BDS.txt | 48 +------ 11 files changed, 427 insertions(+), 45 deletions(-) create mode 100644 pysmspp/data/configs/TSSBlock/BDSCfg-CVX-LD.txt create mode 100644 pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt create mode 100644 pysmspp/data/configs/TSSBlock/BDSCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt create mode 100644 pysmspp/data/configs/TSSBlock/IBOCfg-LD.txt create mode 100644 pysmspp/data/configs/TSSBlock/IFCfg-LD.txt create mode 100644 pysmspp/data/configs/TSSBlock/InnerBCfg-LD.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-LD.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-LD.txt diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index de83aae..434aa34 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -12,7 +12,7 @@ The template configuration option for OSolCfg.txt allows to extract the most inf TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. TSSBSCfg-LD-IP-par.txt, TSSBSCfg-LDLD-par.txt and TSSBSCfg-LDrec-par.txt are the same three duals with a ParallelBundleSolver, which evaluates the components of an iteration in 8 threads. TSSBSCfg-LP.txt solves the continuous relaxation with a :MILPSolver, and TSSBSCfg-PIPS.txt (with PIPSCfg.txt) the same linear program with PIPS-IPM++, under mpirun. -TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSMCfg.txt and BDSSCfg.txt, to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt. +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSCfg.txt (whose master and subproblems are those of BDSMCfg.txt and BDSSCfg.txt), to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBSCfg-BDS-LD.txt is the same with the subproblems solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt, and TSSBSCfg-BDS-CVX-LD.txt the latter with the master solved by the BundleSolver of BDSMCfg-CVX.txt (the convex regime). TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt; with the BlockConfig InnerBCfg-LD.txt instead of InnerBCfg.txt the inner Block is solved by the recursive Lagrangian dual (IBOCfg-LD.txt, IFCfg-LD.txt). The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. MPBCfg.txt solves the master with HiGHS, which needs an SMS++ whose HiGHSMILPSolver regularizes the QP of the master (the one of HiGHS 1.15 may otherwise call it non-convex), and the version using Gurobi is provided under name MPBCfg_grb.txt, to be named by `strMPBSolverCfg` in its place. diff --git a/pysmspp/data/configs/TSSBlock/BDSCfg-CVX-LD.txt b/pysmspp/data/configs/TSSBlock/BDSCfg-CVX-LD.txt new file mode 100644 index 0000000..4b50b1b --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSCfg-CVX-LD.txt @@ -0,0 +1,38 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - BDSCfg-CVX-LD.txt - - - - - - - - - - - - - - - +# +# The ComputeConfig of BDSCfg-LD.txt in the convex regime: the master is +# solved by the BundleSolver of BDSMCfg-CVX.txt, the value functions of the +# subproblems being components of its Objective. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*BDSCfg-LD.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +1 # number of integer parameters + +# now all the integer parameters +int_BDSlv_Regime 0 # 0 = convex master, 1 = MILP master + +0 # number of double parameters + +1 # number of string parameters + +# now all the string parameters +str_Mstr_BSCfg BDSMCfg-CVX.txt # BlockSolverConfig of the master + +0 # number of vector-of-int parameters + +0 # number of vector-of-double parameters + +0 # number of vector-of-string parameters + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END BDSCfg-CVX-LD.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt b/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt new file mode 100644 index 0000000..0c8ce86 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt @@ -0,0 +1,35 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BDSCfg-LD.txt - - - - - - - - - - - - - - - - +# +# The ComputeConfig of the BendersDecompositionSolver whose subproblems are +# solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt: that of +# BDSCfg.txt, the Solver of the subproblems apart. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*BDSCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +0 # number of integer parameters + +0 # number of double parameters + +1 # number of string parameters + +# now all the string parameters +str_Bsub_BSCfg TSSBSCfg-LDrec.txt # BlockSolverConfig of the subproblems + +0 # number of vector-of-int parameters + +0 # number of vector-of-double parameters + +0 # number of vector-of-string parameters + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BDSCfg-LD.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSCfg.txt b/pysmspp/data/configs/TSSBlock/BDSCfg.txt new file mode 100644 index 0000000..b6c7610 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSCfg.txt @@ -0,0 +1,56 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - BDSCfg.txt - - - - - - - - - - - - - - - - +# +# The ComputeConfig of the BendersDecompositionSolver of TSSBSCfg-BDS.txt: +# the MILP regime, one cut per scenario, the scenarios of a round evaluated +# by 8 threads, the master of BDSMCfg.txt and the subproblems of BDSSCfg.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +0 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +2 # number of integer parameters + +# now all the integer parameters +int_BDSlv_Regime 1 # 0 = convex master, 1 = MILP master +intMaxThread 8 # threads evaluating the subproblems of a round, at + # most the cores of the machine; the run is the same + # for every value, only faster, and 1 evaluates them + # one after the other + +0 # number of double parameters + +# now all the double parameters +# [none] + +2 # number of string parameters + +# now all the string parameters +str_Bsub_BSCfg BDSSCfg.txt # BlockSolverConfig of the subproblems +str_Mstr_BSCfg BDSMCfg.txt # BlockSolverConfig of the master + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END BDSCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt b/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt new file mode 100644 index 0000000..eaebd25 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt @@ -0,0 +1,117 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BDSMCfg-CVX.txt - - - - - - - - - - - - - - - +# +# The BlockSolverConfig of the master problem of BendersDecompositionSolver +# in the convex regime (BDSCfg-CVX-LD.txt): a BundleSolver, which drives the +# stabilized cutting-plane loop, the value functions of the subproblems +# being components of its Objective; its master problem is solved by the +# Solver of MPBCfg.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one: values are being set + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BundleSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +13 # number of integer parameters + +# now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, + # 2 = doubly stabilized +intMaxIter 100000 # MaxIter, max number of iterations for each call +intLogVerb 0 # LogVerb, log verbosity of main Bundle algorithm +intBPar1 20 # discard items when they have been useless for + # iterations +intBPar2 400 # max bundle size per component +intBPar3 1 # max n. of items to fetch from Fi() at each iteration +intBPar4 1 # min n. of items to fetch from Fi() at each iteration +intBPar6 0 # second parameter for dynamic max n. of items per + # iteration +intBPar7 11 # how to deal with the global pools +intMnSSC 0 # min number of consecutive SS with the same t for a t + # increase +intMnNSC 1 # min number of consecutive NS with the same t for a t + # decrease +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, + # 12 = balancing): the master knows nothing of the scale + # of the design Variable, and letting it balance the + # stabilization against the model is what finds it +intMaxNrEvls 2 # maximum number of function evaluations per iteration + +15 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-8 # relative accuracy required to solution: with 1e-6 + # the bundle may stop short of it where the scenarios + # differ the most, and give an upper bound instead of + # a value +dblNZEps 1e-4 # stopping parameter: threshold to declare 0 the + # || residual ||, below which the lower bound is + # certified: the linearizations of subproblems solved + # by a Lagrangian dual are accurate to its dblRelAcc + # (1e-5 in TSSBSCfg-LDrec.txt), and with a smaller + # threshold the Solver reports the optimum without a + # bound +dbltStar 1e+4 # stopping parameter: multiplied to || residual || to + # estimate gap +dblBPar5 4 # first parameter for dynamic max n. of items per + # iteration +dblm1 -0.01 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + # + | m1 | v* +dblm2 0.99 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + # + ( 1 - m2 ) v* +dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || +dblmxIncr 10 # max increase of t +dblmnIncr 1.5 # min increase of t (each time it is increased) +dblmxDecr 0.1 # max decrease of t +dblmnDecr 0.66 # min decrease of t (each time it is decreased) +dbltMaior 1e+6 # maximum value for t +dbltMinor 1e-4 # minimum value for t +dbltInit 1e+3 # initial value for t, at the scale of a design in MW: + # with 1e+5 the bundle may stop before the optimum +dbltSPar2 0.001 # parameter for the long-term t-strategy + +1 # number of string parameters + +# now all the string parameters +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig of the + # MasterProblemBlock Solver + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BDSMCfg-CVX.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/IBOCfg-LD.txt b/pysmspp/data/configs/TSSBlock/IBOCfg-LD.txt new file mode 100644 index 0000000..e07749a --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/IBOCfg-LD.txt @@ -0,0 +1,54 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - IBOCfg-LD.txt - - - - - - - - - - - - - - - - +# +# The OBlockConfig of IBOCfg.txt, which gives the InvestmentFunction the +# ComputeConfig of IFCfg-LD.txt, i.e., the inner Block solved by the +# recursive Lagrangian dual. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OBlockConfig # exact type of the Configuration object + +1 # the BlockConfig is a "differential" one + +2 # version of the BlockConfig format + +# the Configuration for the structure, i.e., the tree of sub-Block +* # [none] + +# static_constraints: the bounds l <= x <= u on the investment are +# reformulated as 0 <= x <= u - l, the only form BundleSolver handles +SimpleConfiguration +1 + +# dynamic_constraints +* # [none] + +# static_variables +* # [none] + +# dynamic_variables +* # [none] + +# objective +* # [none] + +# is_feasible +* # [none] + +# is_optimal +* # [none] + +# solution +* # [none] + +# extra +* # [none] + +# the ComputeConfig of the Objective, i.e., of the InvestmentFunction +*IFCfg-LD.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END IBOCfg-LD.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/IFCfg-LD.txt b/pysmspp/data/configs/TSSBlock/IFCfg-LD.txt new file mode 100644 index 0000000..5035dd7 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/IFCfg-LD.txt @@ -0,0 +1,36 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - IFCfg-LD.txt - - - - - - - - - - - - - - - - +# +# The ComputeConfig of the InvestmentFunction of IFCfg.txt, whose inner +# Block is solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt +# instead of the linear program of BSCfg-IB.txt: only the extra +# Configuration changes. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*IFCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +0 # number of integer parameters + +0 # number of double parameters + +0 # number of string parameters + +0 # number of vector-of-int parameters + +0 # number of vector-of-double parameters + +0 # number of vector-of-string parameters + +# pointer to the "extra" Configuration: the BlockSolverConfig of the inner +# Block of the InvestmentFunction +SimpleConfiguration> +1 # the number of elements in the map +BlockSolverConfig *TSSBSCfg-LDrec.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END IFCfg-LD.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/InnerBCfg-LD.txt b/pysmspp/data/configs/TSSBlock/InnerBCfg-LD.txt new file mode 100644 index 0000000..31eb39c --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/InnerBCfg-LD.txt @@ -0,0 +1,22 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - InnerBCfg-LD.txt - - - - - - - - - - - - - - - +# +# The map of InnerBCfg.txt, the InvestmentBlock being configured by +# IBOCfg-LD.txt, whose inner Block is solved by the recursive Lagrangian dual +# (IFCfg-LD.txt, TSSBSCfg-LDrec.txt). +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +SimpleConfiguration> + +5 # the number of elements in the map +InvestmentBlock *IBOCfg-LD.txt +ThermalUnitBlock *TUBCfg.txt +DCNetworkBlock *DCNBCfg.txt +ACNetworkBlock *ACBCfg.txt +PolyhedralFunctionBlock *PFBCfg.txt + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END InnerBCfg-LD.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-LD.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-LD.txt new file mode 100644 index 0000000..d9dcf0b --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-LD.txt @@ -0,0 +1,32 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - TSSBSCfg-BDS-CVX-LD.txt - - - - - - - - - - - - - - +# +# The BendersDecompositionSolver of TSSBSCfg-BDS-LD.txt in the convex +# regime (BDSCfg-CVX-LD.txt): a BundleSolver on the master, the subproblems +# solved by the recursive Lagrangian dual. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BendersDecompositionSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*BDSCfg-CVX-LD.txt + +# end of 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - END TSSBSCfg-BDS-CVX-LD.txt - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-LD.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-LD.txt new file mode 100644 index 0000000..f24b781 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-LD.txt @@ -0,0 +1,32 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - TSSBSCfg-BDS-LD.txt - - - - - - - - - - - - - - - +# +# The BendersDecompositionSolver of TSSBSCfg-BDS.txt whose subproblems are +# solved by the recursive Lagrangian dual (BDSCfg-LD.txt): the value and the +# cut of a scenario come from the dual over its units. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BendersDecompositionSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*BDSCfg-LD.txt + +# end of 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - END TSSBSCfg-BDS-LD.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt index 4087704..5a86b14 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS.txt @@ -3,7 +3,8 @@ # # A BendersDecompositionSolver in the MILP regime, one cut per scenario, # the scenarios of a round evaluated by 8 threads, on the Benders form -# smspp_tssb_solver -k assembles (BDSMCfg.txt, BDSSCfg.txt). +# smspp_tssb_solver -k assembles (BDSCfg.txt, whose master and subproblems +# are those of BDSMCfg.txt and BDSSCfg.txt). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -21,50 +22,9 @@ BendersDecompositionSolver # name of Solver # now all the ComputeConfig # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ComputeConfig # exact type of the ComputeConfig object +*BDSCfg.txt -0 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -2 # number of integer parameters - -# now all the integer parameters -int_BDSlv_Regime 1 # 0 = convex master, 1 = MILP master -intMaxThread 8 # threads evaluating the subproblems of a round, at - # most the cores of the machine; the run is the same - # for every value, only faster, and 1 evaluates them - # one after the other - -0 # number of double parameters - -# now all the double parameters -# [none] - -2 # number of string parameters - -# now all the string parameters -str_Bsub_BSCfg BDSSCfg.txt # BlockSolverConfig of the subproblems -str_Mstr_BSCfg BDSMCfg.txt # BlockSolverConfig of the master - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] - -# pointer to the "extra" Configuration -* # [none] - -# end of 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - +# end of 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - # end of BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - From 71beaef3aa6dfc59b55863816ae0d5b295d8c95a Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sun, 27 Sep 2026 13:36:01 +0200 Subject: [PATCH 19/28] the feasible solution comes from the configuration: strRecoveryBSC in the BDS of the Lagrangian subproblems, as in the PrimalProximalHeur, whose comments are right again --- pysmspp/data/configs/README.md | 4 ++-- pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt | 9 +++++++-- pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt | 13 ++++++------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 434aa34..69ee23c 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -10,9 +10,9 @@ For SVMBlock, SVMCfg.txt and SVMCfg-primal.txt are BlockConfig, which is what ch For uc_solverconfig in both folders, the version using Gurobi is also provided under name uc_solverconfig_grb. The template configuration option for OSolCfg.txt allows to extract the most information from tools. -TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and option `-R BSCfg1-IP.txt` of smspp_tssb_solver recovers a feasible solution from it. TSSBSCfg-LD-IP-par.txt, TSSBSCfg-LDLD-par.txt and TSSBSCfg-LDrec-par.txt are the same three duals with a ParallelBundleSolver, which evaluates the components of an iteration in 8 threads. TSSBSCfg-LP.txt solves the continuous relaxation with a :MILPSolver, and TSSBSCfg-PIPS.txt (with PIPSCfg.txt) the same linear program with PIPS-IPM++, under mpirun. +TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and TSSBSCfg-PPH.txt gives a feasible solution with its gap, recovered by the PrimalProximalHeur with the BlockSolverConfig of its strRecoveryBSC. TSSBSCfg-LD-IP-par.txt, TSSBSCfg-LDLD-par.txt and TSSBSCfg-LDrec-par.txt are the same three duals with a ParallelBundleSolver, which evaluates the components of an iteration in 8 threads. TSSBSCfg-LP.txt solves the continuous relaxation with a :MILPSolver, and TSSBSCfg-PIPS.txt (with PIPSCfg.txt) the same linear program with PIPS-IPM++, under mpirun. -TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSCfg.txt (whose master and subproblems are those of BDSMCfg.txt and BDSSCfg.txt), to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBSCfg-BDS-LD.txt is the same with the subproblems solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt, and TSSBSCfg-BDS-CVX-LD.txt the latter with the master solved by the BundleSolver of BDSMCfg-CVX.txt (the convex regime). TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt; with the BlockConfig InnerBCfg-LD.txt instead of InnerBCfg.txt the inner Block is solved by the recursive Lagrangian dual (IBOCfg-LD.txt, IFCfg-LD.txt). +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSCfg.txt (whose master and subproblems are those of BDSMCfg.txt and BDSSCfg.txt), to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBSCfg-BDS-LD.txt is the same with the subproblems solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt and a feasible solution recovered at the design of the master (strRecoveryBSC in BDSCfg-LD.txt, each subproblem a MILP of BSCfg1-IP.txt), and TSSBSCfg-BDS-CVX-LD.txt the latter with the master solved by the BundleSolver of BDSMCfg-CVX.txt (the convex regime). TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt; with the BlockConfig InnerBCfg-LD.txt instead of InnerBCfg.txt the inner Block is solved by the recursive Lagrangian dual (IBOCfg-LD.txt, IFCfg-LD.txt). The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. MPBCfg.txt solves the master with HiGHS, which needs an SMS++ whose HiGHSMILPSolver regularizes the QP of the master (the one of HiGHS 1.15 may otherwise call it non-convex), and the version using Gurobi is provided under name MPBCfg_grb.txt, to be named by `strMPBSolverCfg` in its place. diff --git a/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt b/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt index 0c8ce86..54f8dba 100644 --- a/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt +++ b/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt @@ -3,7 +3,9 @@ # # The ComputeConfig of the BendersDecompositionSolver whose subproblems are # solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt: that of -# BDSCfg.txt, the Solver of the subproblems apart. +# BDSCfg.txt, the Solver of the subproblems apart, and with the recovery of +# a feasible solution at the design of the master (BSCfg1-IP.txt), which +# gives the upper bound in the MILP regime. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -16,10 +18,13 @@ 0 # number of double parameters -1 # number of string parameters +2 # number of string parameters # now all the string parameters str_Bsub_BSCfg TSSBSCfg-LDrec.txt # BlockSolverConfig of the subproblems +strRecoveryBSC BSCfg1-IP.txt # the recovery of a feasible solution: + # each subproblem solved as a MILP at the + # design of the master 0 # number of vector-of-int parameters diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt index 760c826..ff04db4 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-PPH.txt @@ -41,12 +41,10 @@ intUseWarmStartPSol 0 # the first iteration solves the plain Lagrangian Dual, int_LDSlv_iBCopy 0 # 1 if sub-Block must be R3B-copied intLogVerb 0 # log verbosity of main Bundle algorithm -intTrgtMng 31 -intRecoveryThreads 8 # bit-wise encoding targets and accuracies management: - # bit 0: if lower/upper target is set to each convex/concave component - # bit 1: if upper/lower target is set to each convex/concave component - # bit 2-3: if accuracy is set (2 = upper - lower, 3 = using EpsU) - # bit 4: if Lipschitz constant is used to compute the upper model +intTrgtMng 31 # bit-wise targets and accuracies management: lower + # and upper targets, accuracy as upper - lower, and + # the Lipschitz constant in the upper model +intRecoveryThreads 8 # threads solving the scenarios of the recovery 9 # number of double parameters @@ -71,7 +69,8 @@ dbltInit 1e-3 # initial value for t 2 # number of string parameters str_LagBF_BSCfg LPBSCfg-LDLD.txt -strRecoveryBSC BSCfg1-IP.txt # BlockSolverConfig for the LagBFunctions +strRecoveryBSC BSCfg1-IP.txt # BlockSolverConfig of the recovery: each + # scenario a MILP at the fixed design 0 # number of vector-of-int parameters From 3f053e7a9191ceb64b867ba798c6d4b4d7249fcc Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sun, 27 Sep 2026 14:57:16 +0200 Subject: [PATCH 20/28] the BDS with a bundle master recovers the feasible solution too, at the best point of its bundle --- pysmspp/data/configs/README.md | 2 +- pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 69ee23c..23e211c 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -12,7 +12,7 @@ The template configuration option for OSolCfg.txt allows to extract the most inf TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDrec.txt solve a two-stage problem whose scenario is a unit commitment with a :MILPSolver, with the Lagrangian dual of the scenarios, with a chain of two duals down to the units and with the recursive Lagrangian dual, respectively; TSSBSCfg-PPH.txt adds to the dual of the scenarios the PrimalProximalHeur, which gives a feasible solution by fixing the design to its mean over the scenarios. They need the BlockConfig InnerBCfg.txt (option -B, i.e., `B="InnerBCfg.txt"` of TSSBSolver); the duals give a bound, and TSSBSCfg-PPH.txt gives a feasible solution with its gap, recovered by the PrimalProximalHeur with the BlockSolverConfig of its strRecoveryBSC. TSSBSCfg-LD-IP-par.txt, TSSBSCfg-LDLD-par.txt and TSSBSCfg-LDrec-par.txt are the same three duals with a ParallelBundleSolver, which evaluates the components of an iteration in 8 threads. TSSBSCfg-LP.txt solves the continuous relaxation with a :MILPSolver, and TSSBSCfg-PIPS.txt (with PIPSCfg.txt) the same linear program with PIPS-IPM++, under mpirun. -TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSCfg.txt (whose master and subproblems are those of BDSMCfg.txt and BDSSCfg.txt), to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBSCfg-BDS-LD.txt is the same with the subproblems solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt and a feasible solution recovered at the design of the master (strRecoveryBSC in BDSCfg-LD.txt, each subproblem a MILP of BSCfg1-IP.txt), and TSSBSCfg-BDS-CVX-LD.txt the latter with the master solved by the BundleSolver of BDSMCfg-CVX.txt (the convex regime). TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt; with the BlockConfig InnerBCfg-LD.txt instead of InnerBCfg.txt the inner Block is solved by the recursive Lagrangian dual (IBOCfg-LD.txt, IFCfg-LD.txt). +TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSCfg.txt (whose master and subproblems are those of BDSMCfg.txt and BDSSCfg.txt), to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBSCfg-BDS-LD.txt is the same with the subproblems solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt and a feasible solution recovered at the design of the master (strRecoveryBSC in BDSCfg-LD.txt, each subproblem a MILP of BSCfg1-IP.txt), and TSSBSCfg-BDS-CVX-LD.txt the latter with the master solved by the BundleSolver of BDSMCfg-CVX.txt (the convex regime), which recovers the feasible solution at the best point of its bundle. TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt; with the BlockConfig InnerBCfg-LD.txt instead of InnerBCfg.txt the inner Block is solved by the recursive Lagrangian dual (IBOCfg-LD.txt, IFCfg-LD.txt). The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. MPBCfg.txt solves the master with HiGHS, which needs an SMS++ whose HiGHSMILPSolver regularizes the QP of the master (the one of HiGHS 1.15 may otherwise call it non-convex), and the version using Gurobi is provided under name MPBCfg_grb.txt, to be named by `strMPBSolverCfg` in its place. diff --git a/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt b/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt index 54f8dba..315ba6f 100644 --- a/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt +++ b/pysmspp/data/configs/TSSBlock/BDSCfg-LD.txt @@ -5,7 +5,8 @@ # solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt: that of # BDSCfg.txt, the Solver of the subproblems apart, and with the recovery of # a feasible solution at the design of the master (BSCfg1-IP.txt), which -# gives the upper bound in the MILP regime. +# gives the upper bound in both regimes (in the convex one, at the best +# point of the bundle). # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 93d04cde7c2bbd697b00047e88a01b06ff9bc2f8 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sun, 27 Sep 2026 15:42:02 +0200 Subject: [PATCH 21/28] the MILP of the TSSB templates separates nothing: no Block of these networks has cuts, and the lazy constraints only cost Gurobi memory --- pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt index 87e2351..adcb4e9 100644 --- a/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt +++ b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt @@ -15,7 +15,8 @@ ComputeConfig # exact type of the ComputeConfig object intLogVerb 0 # log verbosity of the MILPSolver intRelaxIntVars 0 # nonzero if the continuous relaxation is solved -intCutSepPar 7 # separate user cuts + lazy constraints +intCutSepPar 0 # no separation: no Block here separates, and the lazy + # constraints would only cost Gurobi memory 2 # number of double parameters From a7cc5c379058d41b459e3cb3371de2bfdbcc133a Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 28 Sep 2026 15:12:12 +0200 Subject: [PATCH 22/28] the tests count the arcs of a HydroUnitBlock among the generators of the UCBlock, and the SVM formulations skip a Solver that the build of SMS++ does not have, as with LIBSVM --- test/conftest.py | 5 +- test/test_optimize.py | 987 +++++++++++++++++++++--------------------- 2 files changed, 501 insertions(+), 491 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 46dbca6..9980196 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -294,7 +294,10 @@ def add_hub_to_ucblock(b, name_inner_block="Block_0", **kwargs): ucname = get_new_ucname(ucb) ucb.dimensions["NumberUnits"].value += 1 - ucb.dimensions["NumberElectricalGenerators"].value += 1 + # each arc of a HydroUnitBlock is an electrical generator + ucb.dimensions["NumberElectricalGenerators"].value += hub.dimensions[ + "NumberArcs" + ].value ucb.add("HydroUnitBlock", ucname, block=hub) return b diff --git a/test/test_optimize.py b/test/test_optimize.py index ddd56f6..f5ce8ce 100644 --- a/test/test_optimize.py +++ b/test/test_optimize.py @@ -1,490 +1,497 @@ -import os -import shutil -from pathlib import Path - -import numpy as np -import pytest -from conftest import ( - add_base_ucblock, - add_bub_to_ucblock, - add_hub_to_ucblock, - add_iub_to_ucblock, - add_sub_to_ucblock, - add_tub_to_ucblock, - add_ucblock_with_one_unit, - build_svm_network, - build_tssb_block, - get_network, - get_temp_file, -) - -from pysmspp import ( - InvestmentBlockSolver, - SMSConfig, - SMSFileType, - SMSNetwork, - UCBlockSolver, -) - -RTOL = 1e-4 -ATOL = 1e-2 - - -def test_help_ucblocksolver(force_smspp): - ucs = UCBlockSolver() - - if ucs.is_available() or force_smspp: - help_msg = ucs.help() - - assert ( - "SMS++ unit commitment solver" in help_msg - or "SMS++ UCBlock solver" in help_msg - ) - else: - pytest.skip("UCBlockSolver not available in PATH") - - -def test_shell_ucblocksolver(): - # skip if not linux os - if os.name != "posix": - pytest.skip("Shell command test only applicable on Linux/Unix systems") - - fp_network = get_network("microgrid_ALLbutStore_1N.nc4") - fp_config = SMSConfig(template="UCBlock/uc_solverconfig.txt") - - solver_cmd = "bash -lc \"printf 'Status = Success\\nUpper bound = 123.0\\nLower bound = 120.0\\n'\"" - - ucs = UCBlockSolver( - solver_path=solver_cmd, - fp_network=str(fp_network), - configfile=str(fp_config), - shell=True, - ) - - ucs.optimize(logging=False) - - assert "Success" in ucs.status - assert ucs.objective_value == pytest.approx(123.0) - assert ucs.lower_bound == pytest.approx(120.0) - - -def test_help_investmentblocksolver(force_smspp): - ibts = InvestmentBlockSolver() - - if ibts.is_available() or force_smspp: - help_msg = ibts.help() - - assert "SMS++ investment solver" in help_msg - else: - pytest.skip("InvestmentBlockSolver not available in PATH") - - -def test_optimize_example(force_smspp): - fp_network = get_network() - fp_log = get_temp_file("test_optimize_example.txt") - configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") - - ucs = UCBlockSolver( - configfile=str(configfile), - fp_network=fp_network, - fp_log=fp_log, - ) - - if ucs.is_available() or force_smspp: - ucs.optimize(logging=False) - - assert "Success" in ucs.status - assert np.isclose(ucs.objective_value, 3615.760710, atol=ATOL, rtol=RTOL) - else: - pytest.skip("UCBlockSolver not available in PATH") - - -def test_optimize_example_custom_solver_path(force_smspp): - if not UCBlockSolver().is_available() and not force_smspp: - pytest.skip("UCBlockSolver not available in PATH and --force-smspp not set") - - fp_network = get_network() - fp_log = get_temp_file("test_optimize_example.txt") - configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") - - path_ucsolver = shutil.which("ucblock_solver") - - ucs = UCBlockSolver( - solver_path=Path(path_ucsolver), - configfile=str(configfile), - fp_network=fp_network, - fp_log=fp_log, - ) - - ucs.optimize(logging=False) - - assert "Success" in ucs.status - assert np.isclose(ucs.objective_value, 3615.760710, atol=ATOL, rtol=RTOL) - - -def test_optimize_ucsolver(force_smspp): - b = SMSNetwork(file_type=SMSFileType.eBlockFile) - add_ucblock_with_one_unit(b) - - fp_log = get_temp_file("test_optimize_ucsolver.txt") - fp_temp = get_temp_file("test_optimize_ucsolver.nc") - configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") - - if UCBlockSolver().is_available() or force_smspp: - result = b.optimize(configfile, fp_temp, fp_log) - - assert "Success" in result.status - else: - pytest.skip("UCBlockSolver not available in PATH") - - -def test_optimize_ucsolver_all_components(force_smspp): - b = SMSNetwork(file_type=SMSFileType.eBlockFile) - - # Add uc block and specify demand - add_base_ucblock(b) - - # Add thermal unit block - add_tub_to_ucblock(b) - - # Add battery unit block - add_bub_to_ucblock(b) - - # Add hydro unit block - add_hub_to_ucblock(b) - - # Add intermittent unit block - add_iub_to_ucblock(b) - - # Add slack unit block - add_sub_to_ucblock(b) - - fp_log = get_temp_file("test_optimize_ucsolver_all_components.txt") - fp_temp = get_temp_file("test_optimize_ucsolver_all_components.nc") - configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") - - if UCBlockSolver().is_available() or force_smspp: - result = b.optimize(configfile, fp_temp, fp_log, logging=True) - - assert "success" in result.status.lower() - assert "error" not in result.log.lower() - else: - pytest.skip("UCBlockSolver not available in PATH") - - -def test_investmentsolvertest(force_smspp): - fp_network = get_network("investment_1N.nc4") - fp_log = get_temp_file("test_optimize_investmentsolvertest.txt") - configfile = SMSConfig(template="InvestmentBlock/BSPar.txt") - - ucs = InvestmentBlockSolver( - configfile=str(configfile), - fp_network=fp_network, - fp_log=fp_log, - ) - - if InvestmentBlockSolver().is_available() or force_smspp: - ucs.optimize(logging=True) - - assert "success" in ucs.status.lower() - else: - pytest.skip("InvestmentBlockSolver not available in PATH") - - -def test_is_smspp_installed(force_smspp): - """Test the is_smspp_installed() function.""" - from pysmspp import InvestmentBlockSolver, UCBlockSolver, is_smspp_installed - - # The function should return a boolean - result = is_smspp_installed() - assert isinstance(result, bool) - - # Test with multiple solvers - result_multi = is_smspp_installed([UCBlockSolver(), InvestmentBlockSolver()]) - assert isinstance(result_multi, bool) - - # When force_smspp is True, is_smspp_installed must return True - if force_smspp: - assert result is True, ( - "is_smspp_installed should return True when --force-smspp is set" - ) - assert result_multi is True, ( - "is_smspp_installed should return True for all solvers when --force-smspp is set" - ) - - -def test_optimize_tssbsolver(force_smspp): - fp_network = get_network("TSSB_EC_CO_Test_TUB_simple.nc4") - fp_log = get_temp_file("test_optimize_tssbsolver.txt") - configfile = SMSConfig(template="TSSBlock/TSSBSCfg.txt") - - # Create a new TSSB block from the original network and save to a temp file - fp_tssb_new = get_temp_file("test_tssb_new.nc4") - fp_log_new = get_temp_file("test_optimize_tssbsolver_new.txt") - - build_tssb_block(fp_network).to_netcdf(fp_tssb_new, force=True) - - # Copy the original EC_CO_Test_TUB.nc4 to a temp location - fp_ec = get_network("EC_CO_Test_TUB.nc4") - fp_ec_copy = get_temp_file("EC_CO_Test_TUB.nc4") - shutil.copy(fp_ec, fp_ec_copy) - - from pysmspp import TSSBSolver - - tssb_solver = TSSBSolver( - fp_network=fp_network, - fp_log=fp_log, - configfile=str(configfile), - ) - - tssb_solver_new = TSSBSolver( - fp_network=fp_tssb_new, - fp_log=fp_log_new, - configfile=str(configfile), - ) - - if tssb_solver.is_available() or force_smspp: - tssb_solver.optimize(logging=True) - - assert "success" in tssb_solver.status.lower() - - tssb_solver_new.optimize(logging=True) - - assert "success" in tssb_solver_new.status.lower() - - obj_orig = tssb_solver.objective_value - obj_new = tssb_solver_new.objective_value - assert obj_orig == pytest.approx(obj_new, rel=1e-4), ( - f"Objective values should match between original ({obj_orig:.2f}) and new ({obj_new:.2f}) TSSB blocks" - ) - else: - pytest.skip("TSSBBlockSolver not available in PATH") - - -def test_help_svmsolver(force_smspp): - from pysmspp import SVMSolver - - svm = SVMSolver() - - if svm.is_available() or force_smspp: - assert "SMS++ SVM solver" in svm.help() - else: - pytest.skip("SVMSolver not available in PATH") - - -def test_optimize_svmblock_classification(force_smspp): - """ - Train a SVCBlock with the ad hoc SMOSolver. - """ - from pysmspp import SVMSolver - - b = build_svm_network("SVCBlock", C=10.0) - - fp_log = get_temp_file("test_optimize_svcblock.txt") - fp_temp = get_temp_file("test_optimize_svcblock.nc") - configfile = SMSConfig(template="SVMBlock/SVMSCfg.txt") - - if SVMSolver().is_available() or force_smspp: - result = b.optimize(configfile, fp_temp, fp_log) - - assert "Success" in result.status - assert result.score_name == "accuracy" - assert result.training_score >= 0.9 - else: - pytest.skip("SVMSolver not available in PATH") - - -def test_optimize_svmblock_regression(force_smspp): - """ - Train a SVRBlock with the ad hoc SMOSolver. - """ - from pysmspp import SVMSolver - - b = build_svm_network("SVRBlock", C=100.0, Epsilon=0.1) - - fp_log = get_temp_file("test_optimize_svrblock.txt") - fp_temp = get_temp_file("test_optimize_svrblock.nc") - configfile = SMSConfig(template="SVMBlock/SVMSCfg.txt") - - if SVMSolver().is_available() or force_smspp: - result = b.optimize(configfile, fp_temp, fp_log) - - assert "Success" in result.status - assert result.score_name == "R2" - assert result.training_score >= 0.9 - else: - pytest.skip("SVMSolver not available in PATH") - - -def test_optimize_svmblock_formulations(force_smspp): - """ - The training problem has the same value in every formulation and with - every Solver: the Wolfe dual and the primal solved by a :MILPSolver, the - dual solved by the ad hoc SMOSolver, the consensus structure of the - problem in chunks solved by a LagrangianDualSolver, and LIBSVM, which is - only in the Solver factory when SVMBlock has been built with it. - """ - from pysmspp import SVMSolver - - if not SVMSolver().is_available() and not force_smspp: - pytest.skip("SVMSolver not available in PATH") - - fp_network = get_temp_file("test_svmblock_formulations.nc") - build_svm_network("SVCBlock", C=10.0).to_netcdf(fp_network, force=True) - - runs = { - "dual/SMO": ("SVMBlock/SVMSCfg.txt", {}), - "dual/MILP": ("SVMBlock/SVMSCfg_grb.txt", {}), - "primal/MILP": ("SVMBlock/SVMSCfg_grb.txt", {"B": "SVMCfg-primal.txt"}), - "chunks/LD": ("SVMBlock/SVMSCfg-LD.txt", {"s": 4}), - "dual/LIBSVM": ("SVMBlock/SVMSCfg-libsvm.txt", {}), - } - - values = {} - for name, (template, kwargs) in runs.items(): - svm = SVMSolver( - fp_network=fp_network, - configfile=str(SMSConfig(template=template)), - **kwargs, - ) - svm.optimize(logging=False) - - if name == "dual/LIBSVM" and "Success" not in svm.status: - # LIBSVMSolver is only in the Solver factory when SVMBlock has - # been built with LIBSVM, which is an optional dependency - continue - - assert "Success" in svm.status - values[name] = svm.objective_value - - reference = values["dual/SMO"] - for name, value in values.items(): - assert value == pytest.approx(reference, rel=1e-4), ( - f"the value of the training problem of {name} ({value:.6f}) differs from the " - f"one of dual/SMO ({reference:.6f})" - ) - - -def test_svmsolver_model_selection(force_smspp): - """ - A k-fold cross-validation over a grid of hyper-parameters reports the - score of each point of the grid and the best one. - """ - from pysmspp import SVMSolver - - if not SVMSolver().is_available() and not force_smspp: - pytest.skip("SVMSolver not available in PATH") - - fp_network = get_temp_file("test_svmsolver_model_selection.nc") - build_svm_network("SVCBlock").to_netcdf(fp_network, force=True) - - svm = SVMSolver( - fp_network=fp_network, - configfile=str(SMSConfig(template="SVMBlock/SVMSCfg.txt")), - k=4, - g="C=0.1,1,10", - ) - svm.optimize(logging=False) - - assert "Success" in svm.status - assert len(svm.scores) == 3 - - for point in svm.scores: - assert len(point["scores"]) == 4 # one score per fold - assert set(point["params"]) == {"C"} - - assert svm.best_score == pytest.approx(max(p["score"] for p in svm.scores)) - assert svm.best_params["C"] in (0.1, 1.0, 10.0) - - -def test_svmblock_hyperparameters(force_smspp): - """ - The hyper-parameters reach the solver, i.e., they are scalar variables of - the group and not attributes of it, which SMS++ would silently ignore. - """ - from pysmspp import SVMSolver - - if not SVMSolver().is_available() and not force_smspp: - pytest.skip("SVMSolver not available in PATH") - - configfile = str(SMSConfig(template="SVMBlock/SVMSCfg.txt")) - - def train(**kwargs): - fp_network = get_temp_file("test_svmblock_hyperparameters.nc") - build_svm_network("SVCBlock", **kwargs).to_netcdf(fp_network, force=True) - - svm = SVMSolver(fp_network=fp_network, configfile=configfile) - svm.optimize(logging=False) - - assert "Success" in svm.status - return svm.objective_value - - reference = train(C=1.0) - - # a larger C penalises the training errors more, and a nonlinear kernel, - # a squared loss or a regularised bias are a different problem altogether - assert train(C=10.0) > reference - assert train(C=1.0, Kernel=2, Gamma=0.5) != pytest.approx(reference) - assert train(C=1.0, SquaredLoss=1, RegBias=1) != pytest.approx(reference) - - -def test_svmsolver_trained_model(force_smspp): - """ - The trained model is written to the solution file as a SVMBlockSolution, - i.e., as the multipliers and the bias, and the samples whose multiplier - is nonzero are the support vectors. - """ - from pysmspp import SVMSolver - - if not SVMSolver().is_available() and not force_smspp: - pytest.skip("SVMSolver not available in PATH") - - fp_network = get_temp_file("test_svmsolver_trained_model.nc") - fp_solution = get_temp_file("test_svmsolver_trained_model_sol.nc") - - n_samples = 40 - build_svm_network("SVCBlock", C=10.0).to_netcdf(fp_network, force=True) - - svm = SVMSolver( - fp_network=fp_network, - configfile=str(SMSConfig(template="SVMBlock/SVMSCfg.txt")), - fp_solution=fp_solution, - ) - svm.optimize(logging=False) - - assert "Success" in svm.status - - model = svm.solution.blocks["Solution_0"] - - assert model.attributes["type"].value == "SVMBlockSolution" - - alphas = np.asarray(model.variables["Multipliers"].data) - assert alphas.size == n_samples - assert np.all(alphas >= -1e-9) - assert np.all(alphas <= 10.0 + 1e-9) # the multipliers are bounded by C - - support = np.count_nonzero(alphas) - assert 0 < support < n_samples # some samples support the model, not all - - assert np.isfinite(model.variables["Bias"].data) - - -def test_optimize_sddp(force_smspp): - fp_network = get_network("sddp/SDDPBlock.nc4") - fp_log = get_temp_file("test_optimize_sddp.txt") - configfile = SMSConfig(template="SDDPBlock/SDDPSCfg.txt") - - from pysmspp import SDDPSolver - - sddp_solver = SDDPSolver( - fp_network=fp_network, - fp_log=fp_log, - configfile=str(configfile), - ) - - if sddp_solver.is_available() or force_smspp: - sddp_solver.optimize(logging=True) - - assert "success" in sddp_solver.status.lower() - else: - pytest.skip("SDDPSolver not available in PATH") +import os +import shutil +from pathlib import Path + +import numpy as np +import pytest +from conftest import ( + add_base_ucblock, + add_bub_to_ucblock, + add_hub_to_ucblock, + add_iub_to_ucblock, + add_sub_to_ucblock, + add_tub_to_ucblock, + add_ucblock_with_one_unit, + build_svm_network, + build_tssb_block, + get_network, + get_temp_file, +) + +from pysmspp import ( + InvestmentBlockSolver, + SMSConfig, + SMSFileType, + SMSNetwork, + UCBlockSolver, +) + +RTOL = 1e-4 +ATOL = 1e-2 + + +def test_help_ucblocksolver(force_smspp): + ucs = UCBlockSolver() + + if ucs.is_available() or force_smspp: + help_msg = ucs.help() + + assert ( + "SMS++ unit commitment solver" in help_msg + or "SMS++ UCBlock solver" in help_msg + ) + else: + pytest.skip("UCBlockSolver not available in PATH") + + +def test_shell_ucblocksolver(): + # skip if not linux os + if os.name != "posix": + pytest.skip("Shell command test only applicable on Linux/Unix systems") + + fp_network = get_network("microgrid_ALLbutStore_1N.nc4") + fp_config = SMSConfig(template="UCBlock/uc_solverconfig.txt") + + solver_cmd = "bash -lc \"printf 'Status = Success\\nUpper bound = 123.0\\nLower bound = 120.0\\n'\"" + + ucs = UCBlockSolver( + solver_path=solver_cmd, + fp_network=str(fp_network), + configfile=str(fp_config), + shell=True, + ) + + ucs.optimize(logging=False) + + assert "Success" in ucs.status + assert ucs.objective_value == pytest.approx(123.0) + assert ucs.lower_bound == pytest.approx(120.0) + + +def test_help_investmentblocksolver(force_smspp): + ibts = InvestmentBlockSolver() + + if ibts.is_available() or force_smspp: + help_msg = ibts.help() + + assert "SMS++ investment solver" in help_msg + else: + pytest.skip("InvestmentBlockSolver not available in PATH") + + +def test_optimize_example(force_smspp): + fp_network = get_network() + fp_log = get_temp_file("test_optimize_example.txt") + configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") + + ucs = UCBlockSolver( + configfile=str(configfile), + fp_network=fp_network, + fp_log=fp_log, + ) + + if ucs.is_available() or force_smspp: + ucs.optimize(logging=False) + + assert "Success" in ucs.status + assert np.isclose(ucs.objective_value, 3615.760710, atol=ATOL, rtol=RTOL) + else: + pytest.skip("UCBlockSolver not available in PATH") + + +def test_optimize_example_custom_solver_path(force_smspp): + if not UCBlockSolver().is_available() and not force_smspp: + pytest.skip("UCBlockSolver not available in PATH and --force-smspp not set") + + fp_network = get_network() + fp_log = get_temp_file("test_optimize_example.txt") + configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") + + path_ucsolver = shutil.which("ucblock_solver") + + ucs = UCBlockSolver( + solver_path=Path(path_ucsolver), + configfile=str(configfile), + fp_network=fp_network, + fp_log=fp_log, + ) + + ucs.optimize(logging=False) + + assert "Success" in ucs.status + assert np.isclose(ucs.objective_value, 3615.760710, atol=ATOL, rtol=RTOL) + + +def test_optimize_ucsolver(force_smspp): + b = SMSNetwork(file_type=SMSFileType.eBlockFile) + add_ucblock_with_one_unit(b) + + fp_log = get_temp_file("test_optimize_ucsolver.txt") + fp_temp = get_temp_file("test_optimize_ucsolver.nc") + configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") + + if UCBlockSolver().is_available() or force_smspp: + result = b.optimize(configfile, fp_temp, fp_log) + + assert "Success" in result.status + else: + pytest.skip("UCBlockSolver not available in PATH") + + +def test_optimize_ucsolver_all_components(force_smspp): + b = SMSNetwork(file_type=SMSFileType.eBlockFile) + + # Add uc block and specify demand + add_base_ucblock(b) + + # Add thermal unit block + add_tub_to_ucblock(b) + + # Add battery unit block + add_bub_to_ucblock(b) + + # Add hydro unit block + add_hub_to_ucblock(b) + + # Add intermittent unit block + add_iub_to_ucblock(b) + + # Add slack unit block + add_sub_to_ucblock(b) + + fp_log = get_temp_file("test_optimize_ucsolver_all_components.txt") + fp_temp = get_temp_file("test_optimize_ucsolver_all_components.nc") + configfile = SMSConfig(template="UCBlock/uc_solverconfig.txt") + + if UCBlockSolver().is_available() or force_smspp: + result = b.optimize(configfile, fp_temp, fp_log, logging=True) + + assert "success" in result.status.lower() + assert "error" not in result.log.lower() + else: + pytest.skip("UCBlockSolver not available in PATH") + + +def test_investmentsolvertest(force_smspp): + fp_network = get_network("investment_1N.nc4") + fp_log = get_temp_file("test_optimize_investmentsolvertest.txt") + configfile = SMSConfig(template="InvestmentBlock/BSPar.txt") + + ucs = InvestmentBlockSolver( + configfile=str(configfile), + fp_network=fp_network, + fp_log=fp_log, + ) + + if InvestmentBlockSolver().is_available() or force_smspp: + ucs.optimize(logging=True) + + assert "success" in ucs.status.lower() + else: + pytest.skip("InvestmentBlockSolver not available in PATH") + + +def test_is_smspp_installed(force_smspp): + """Test the is_smspp_installed() function.""" + from pysmspp import InvestmentBlockSolver, UCBlockSolver, is_smspp_installed + + # The function should return a boolean + result = is_smspp_installed() + assert isinstance(result, bool) + + # Test with multiple solvers + result_multi = is_smspp_installed([UCBlockSolver(), InvestmentBlockSolver()]) + assert isinstance(result_multi, bool) + + # When force_smspp is True, is_smspp_installed must return True + if force_smspp: + assert result is True, ( + "is_smspp_installed should return True when --force-smspp is set" + ) + assert result_multi is True, ( + "is_smspp_installed should return True for all solvers when --force-smspp is set" + ) + + +def test_optimize_tssbsolver(force_smspp): + fp_network = get_network("TSSB_EC_CO_Test_TUB_simple.nc4") + fp_log = get_temp_file("test_optimize_tssbsolver.txt") + configfile = SMSConfig(template="TSSBlock/TSSBSCfg.txt") + + # Create a new TSSB block from the original network and save to a temp file + fp_tssb_new = get_temp_file("test_tssb_new.nc4") + fp_log_new = get_temp_file("test_optimize_tssbsolver_new.txt") + + build_tssb_block(fp_network).to_netcdf(fp_tssb_new, force=True) + + # Copy the original EC_CO_Test_TUB.nc4 to a temp location + fp_ec = get_network("EC_CO_Test_TUB.nc4") + fp_ec_copy = get_temp_file("EC_CO_Test_TUB.nc4") + shutil.copy(fp_ec, fp_ec_copy) + + from pysmspp import TSSBSolver + + tssb_solver = TSSBSolver( + fp_network=fp_network, + fp_log=fp_log, + configfile=str(configfile), + ) + + tssb_solver_new = TSSBSolver( + fp_network=fp_tssb_new, + fp_log=fp_log_new, + configfile=str(configfile), + ) + + if tssb_solver.is_available() or force_smspp: + tssb_solver.optimize(logging=True) + + assert "success" in tssb_solver.status.lower() + + tssb_solver_new.optimize(logging=True) + + assert "success" in tssb_solver_new.status.lower() + + obj_orig = tssb_solver.objective_value + obj_new = tssb_solver_new.objective_value + assert obj_orig == pytest.approx(obj_new, rel=1e-4), ( + f"Objective values should match between original ({obj_orig:.2f}) and new ({obj_new:.2f}) TSSB blocks" + ) + else: + pytest.skip("TSSBBlockSolver not available in PATH") + + +def test_help_svmsolver(force_smspp): + from pysmspp import SVMSolver + + svm = SVMSolver() + + if svm.is_available() or force_smspp: + assert "SMS++ SVM solver" in svm.help() + else: + pytest.skip("SVMSolver not available in PATH") + + +def test_optimize_svmblock_classification(force_smspp): + """ + Train a SVCBlock with the ad hoc SMOSolver. + """ + from pysmspp import SVMSolver + + b = build_svm_network("SVCBlock", C=10.0) + + fp_log = get_temp_file("test_optimize_svcblock.txt") + fp_temp = get_temp_file("test_optimize_svcblock.nc") + configfile = SMSConfig(template="SVMBlock/SVMSCfg.txt") + + if SVMSolver().is_available() or force_smspp: + result = b.optimize(configfile, fp_temp, fp_log) + + assert "Success" in result.status + assert result.score_name == "accuracy" + assert result.training_score >= 0.9 + else: + pytest.skip("SVMSolver not available in PATH") + + +def test_optimize_svmblock_regression(force_smspp): + """ + Train a SVRBlock with the ad hoc SMOSolver. + """ + from pysmspp import SVMSolver + + b = build_svm_network("SVRBlock", C=100.0, Epsilon=0.1) + + fp_log = get_temp_file("test_optimize_svrblock.txt") + fp_temp = get_temp_file("test_optimize_svrblock.nc") + configfile = SMSConfig(template="SVMBlock/SVMSCfg.txt") + + if SVMSolver().is_available() or force_smspp: + result = b.optimize(configfile, fp_temp, fp_log) + + assert "Success" in result.status + assert result.score_name == "R2" + assert result.training_score >= 0.9 + else: + pytest.skip("SVMSolver not available in PATH") + + +def test_optimize_svmblock_formulations(force_smspp): + """ + The training problem has the same value in every formulation and with + every Solver: the Wolfe dual and the primal solved by a :MILPSolver, the + dual solved by the ad hoc SMOSolver, the consensus structure of the + problem in chunks solved by a LagrangianDualSolver, and LIBSVM, which is + only in the Solver factory when SVMBlock has been built with it. + """ + from pysmspp import SVMSolver + + if not SVMSolver().is_available() and not force_smspp: + pytest.skip("SVMSolver not available in PATH") + + fp_network = get_temp_file("test_svmblock_formulations.nc") + build_svm_network("SVCBlock", C=10.0).to_netcdf(fp_network, force=True) + + runs = { + "dual/SMO": ("SVMBlock/SVMSCfg.txt", {}), + "dual/MILP": ("SVMBlock/SVMSCfg_grb.txt", {}), + "primal/MILP": ("SVMBlock/SVMSCfg_grb.txt", {"B": "SVMCfg-primal.txt"}), + "chunks/LD": ("SVMBlock/SVMSCfg-LD.txt", {"s": 4}), + "dual/LIBSVM": ("SVMBlock/SVMSCfg-libsvm.txt", {}), + } + + values = {} + for name, (template, kwargs) in runs.items(): + svm = SVMSolver( + fp_network=fp_network, + configfile=str(SMSConfig(template=template)), + **kwargs, + ) + try: + svm.optimize(logging=False) + except ValueError as e: + # a Solver of an optional dependency, e.g., GRBMILPSolver in a + # build of SMS++ without Gurobi, is not in the Solver factory + if "not present in Solver factory" in str(e): + continue + raise + + if name == "dual/LIBSVM" and "Success" not in svm.status: + # LIBSVMSolver is only in the Solver factory when SVMBlock has + # been built with LIBSVM, which is an optional dependency + continue + + assert "Success" in svm.status + values[name] = svm.objective_value + + reference = values["dual/SMO"] + for name, value in values.items(): + assert value == pytest.approx(reference, rel=1e-4), ( + f"the value of the training problem of {name} ({value:.6f}) differs from the " + f"one of dual/SMO ({reference:.6f})" + ) + + +def test_svmsolver_model_selection(force_smspp): + """ + A k-fold cross-validation over a grid of hyper-parameters reports the + score of each point of the grid and the best one. + """ + from pysmspp import SVMSolver + + if not SVMSolver().is_available() and not force_smspp: + pytest.skip("SVMSolver not available in PATH") + + fp_network = get_temp_file("test_svmsolver_model_selection.nc") + build_svm_network("SVCBlock").to_netcdf(fp_network, force=True) + + svm = SVMSolver( + fp_network=fp_network, + configfile=str(SMSConfig(template="SVMBlock/SVMSCfg.txt")), + k=4, + g="C=0.1,1,10", + ) + svm.optimize(logging=False) + + assert "Success" in svm.status + assert len(svm.scores) == 3 + + for point in svm.scores: + assert len(point["scores"]) == 4 # one score per fold + assert set(point["params"]) == {"C"} + + assert svm.best_score == pytest.approx(max(p["score"] for p in svm.scores)) + assert svm.best_params["C"] in (0.1, 1.0, 10.0) + + +def test_svmblock_hyperparameters(force_smspp): + """ + The hyper-parameters reach the solver, i.e., they are scalar variables of + the group and not attributes of it, which SMS++ would silently ignore. + """ + from pysmspp import SVMSolver + + if not SVMSolver().is_available() and not force_smspp: + pytest.skip("SVMSolver not available in PATH") + + configfile = str(SMSConfig(template="SVMBlock/SVMSCfg.txt")) + + def train(**kwargs): + fp_network = get_temp_file("test_svmblock_hyperparameters.nc") + build_svm_network("SVCBlock", **kwargs).to_netcdf(fp_network, force=True) + + svm = SVMSolver(fp_network=fp_network, configfile=configfile) + svm.optimize(logging=False) + + assert "Success" in svm.status + return svm.objective_value + + reference = train(C=1.0) + + # a larger C penalises the training errors more, and a nonlinear kernel, + # a squared loss or a regularised bias are a different problem altogether + assert train(C=10.0) > reference + assert train(C=1.0, Kernel=2, Gamma=0.5) != pytest.approx(reference) + assert train(C=1.0, SquaredLoss=1, RegBias=1) != pytest.approx(reference) + + +def test_svmsolver_trained_model(force_smspp): + """ + The trained model is written to the solution file as a SVMBlockSolution, + i.e., as the multipliers and the bias, and the samples whose multiplier + is nonzero are the support vectors. + """ + from pysmspp import SVMSolver + + if not SVMSolver().is_available() and not force_smspp: + pytest.skip("SVMSolver not available in PATH") + + fp_network = get_temp_file("test_svmsolver_trained_model.nc") + fp_solution = get_temp_file("test_svmsolver_trained_model_sol.nc") + + n_samples = 40 + build_svm_network("SVCBlock", C=10.0).to_netcdf(fp_network, force=True) + + svm = SVMSolver( + fp_network=fp_network, + configfile=str(SMSConfig(template="SVMBlock/SVMSCfg.txt")), + fp_solution=fp_solution, + ) + svm.optimize(logging=False) + + assert "Success" in svm.status + + model = svm.solution.blocks["Solution_0"] + + assert model.attributes["type"].value == "SVMBlockSolution" + + alphas = np.asarray(model.variables["Multipliers"].data) + assert alphas.size == n_samples + assert np.all(alphas >= -1e-9) + assert np.all(alphas <= 10.0 + 1e-9) # the multipliers are bounded by C + + support = np.count_nonzero(alphas) + assert 0 < support < n_samples # some samples support the model, not all + + assert np.isfinite(model.variables["Bias"].data) + + +def test_optimize_sddp(force_smspp): + fp_network = get_network("sddp/SDDPBlock.nc4") + fp_log = get_temp_file("test_optimize_sddp.txt") + configfile = SMSConfig(template="SDDPBlock/SDDPSCfg.txt") + + from pysmspp import SDDPSolver + + sddp_solver = SDDPSolver( + fp_network=fp_network, + fp_log=fp_log, + configfile=str(configfile), + ) + + if sddp_solver.is_available() or force_smspp: + sddp_solver.optimize(logging=True) + + assert "success" in sddp_solver.status.lower() + else: + pytest.skip("SDDPSolver not available in PATH") From 3c684d7fba634677ae1f1cdb92bb50f1300f9d81 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Mon, 28 Sep 2026 23:44:43 +0200 Subject: [PATCH 23/28] the SDDPBlock templates name the hard components with vstrNoEasy, and the components whose primal and dual solution is needed in the Configurations of get_var_solution() and get_dual_solution() of the SDDPSolver, as the LagrangianDualSolver no longer has vstr_LDSl_NoEasy, vstr_LDSl_VarSol and vstr_LDSl_DualSol --- pysmspp/data/configs/SDDPBlock/BSPar-LD.txt | 19 +++++------- .../configs/SDDPBlock/BSPar-greedy-LD.txt | 22 ++++++------- .../data/configs/SDDPBlock/SDDPSCfg-LD.txt | 31 +++++++++++++++++-- .../configs/SDDPBlock/SDDPSCfg-greedy-LD.txt | 17 ++++++++-- 4 files changed, 58 insertions(+), 31 deletions(-) diff --git a/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt b/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt index d9c85b2..e17e9ed 100644 --- a/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/BSPar-LD.txt @@ -135,20 +135,15 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's # now all the vector-of-double parameters # [none] -3 # number of vector-of-string parameters +1 # number of vector-of-string parameters # now all the vector-of-string parameters -# the components that are never "easy": the ThermalUnitBlock, which have -# their own Solver, and the HydroSystemUnitBlock, whose primal solution (the -# final volume of the reservoirs) the SDDPSolver needs and which is not -# provided for the easy components -vstr_LDSl_NoEasy 2 ThermalUnitBlock HydroSystemUnitBlock - -# the only component whose primal and dual solution the SDDPSolver needs: -# the final volume of the reservoirs, and the duals of the constraints of -# the HydroSystemUnitBlock that the BendersBFunction handles -vstr_LDSl_VarSol 1 HydroSystemUnitBlock -vstr_LDSl_DualSol 1 HydroSystemUnitBlock +# the components that the inner BundleSolver never treats as "easy": the +# ThermalUnitBlock, which have their own Solver, and the +# HydroSystemUnitBlock, whose primal solution (the final volume of the +# reservoirs) the SDDPSolver needs and which is not provided for the easy +# components +vstrNoEasy 2 ThermalUnitBlock HydroSystemUnitBlock # pointer to the "extra" Configuration * # [none] diff --git a/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt b/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt index 448cec4..48e0b13 100644 --- a/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/BSPar-greedy-LD.txt @@ -103,21 +103,17 @@ strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's # now all the vector-of-double parameters # [none] -2 # number of vector-of-string parameters +1 # number of vector-of-string parameters # now all the vector-of-string parameters -# the components that are never "easy": the ThermalUnitBlock, which have -# their own Solver, and all those whose primal solution the simulation needs, -# since it is not provided for the easy components: the units that link two -# consecutive stages, and the NetworkBlock, part of the output -vstr_LDSl_NoEasy 9 ThermalUnitBlock HydroSystemUnitBlock BatteryUnitBlock - IntermittentUnitBlock DCNetworkBlock ACNetworkBlock - ECNetworkBlock OTSNetworkBlock DesignNetworkBlock - -# the same components are those whose primal solution the simulation needs -vstr_LDSl_VarSol 9 ThermalUnitBlock HydroSystemUnitBlock BatteryUnitBlock - IntermittentUnitBlock DCNetworkBlock ACNetworkBlock - ECNetworkBlock OTSNetworkBlock DesignNetworkBlock +# the components that the inner BundleSolver never treats as "easy": the +# ThermalUnitBlock, which have their own Solver, and all those whose primal +# solution the simulation needs, since it is not provided for the easy +# components: the units that link two consecutive stages, and the +# NetworkBlock, part of the output +vstrNoEasy 9 ThermalUnitBlock HydroSystemUnitBlock BatteryUnitBlock + IntermittentUnitBlock DCNetworkBlock ACNetworkBlock + ECNetworkBlock OTSNetworkBlock DesignNetworkBlock # pointer to the "extra" Configuration * # [none] diff --git a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt index fd49084..db0a648 100644 --- a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-LD.txt @@ -3,7 +3,8 @@ # # The BlockSolverConfig of the SDDPBlock whose inner Block of each stage is # solved via LagrangianDualSolver [see BSPar-LD.txt], to be used with -# -B SDDPBCfg-LD.txt. +# -B SDDPBCfg-LD.txt. The extra Configuration tells the LagrangianDualSolver +# which components have their primal and dual solution written. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -75,8 +76,32 @@ strOutputFile cuts.txt # now all the vector-of-string parameters # [none] -# pointer to the "extra" Configuration -* # [none] +# pointer to the "extra" Configuration: the Configurations of the inner +# Block of each stage +SimpleConfiguration> +4 # number of elements in this vector + +# the BlockConfig of the inner Block +* # [none] + +# the BlockSolverConfig of the inner Block: none here, it is strInnerBSC +* # [none] + +# the Configuration of get_var_solution(): the only component whose primal +# solution the SDDPSolver needs, by class, is the HydroSystemUnitBlock (the +# final volume of the reservoirs) +SimpleConfiguration> +1 # the number of elements in the map +HydroSystemUnitBlock * # all of its solution + +# the Configuration of get_dual_solution(), which the BendersBFunction of +# each stage passes on: the duals it needs are those of the constraints of +# the HydroSystemUnitBlock (the volume of the reservoirs) and those of the +# relaxed constraints (key "relaxed"), the other components are skipped +SimpleConfiguration> +2 # the number of elements in the map +HydroSystemUnitBlock * # all of its dual solution +relaxed * # the duals of the relaxed constraints # end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt index d78b9d6..003ef3c 100644 --- a/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt +++ b/pysmspp/data/configs/SDDPBlock/SDDPSCfg-greedy-LD.txt @@ -71,9 +71,20 @@ SimpleConfiguration> # the BlockSolverConfig of the inner Block *BSPar-greedy-LD.txt -# the Configuration of get_var_solution(): none, the components whose primal -# solution is needed are named in vstr_LDSl_VarSol of BSPar-greedy-LD.txt -* # [none] +# the Configuration of get_var_solution(): the components whose primal +# solution the simulation needs, by class, which are the hard ones of +# BSPar-greedy-LD.txt +SimpleConfiguration> +9 # the number of elements in the map +ThermalUnitBlock * # all of its solution +HydroSystemUnitBlock * # all of its solution +BatteryUnitBlock * # all of its solution +IntermittentUnitBlock * # all of its solution +DCNetworkBlock * # all of its solution +ACNetworkBlock * # all of its solution +ECNetworkBlock * # all of its solution +OTSNetworkBlock * # all of its solution +DesignNetworkBlock * # all of its solution # the Configuration of get_dual_solution(): only the dual solution of the # linking constraints of the UCBlock (the -1 not being any sub-Block), those From 793cdf9b8dea8a00af0ffaf3dcc3a47a5808cb52 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Thu, 1 Oct 2026 06:13:38 +0200 Subject: [PATCH 24/28] an integer design, e.g., the modules of a modular asset, is solved by the BundleSolver keeping it integer: InvestmentBlock/BSPar-int.txt and TSSBlock/TSSBSCfg-BDS-CVX-int.txt, the ComputeConfigs of the bundle and of its master shared as fragments --- pysmspp/data/blocks/InvestmentBlock.csv | 1 + .../configs/InvestmentBlock/BSPar-int.txt | 72 ++++++++++++++ .../data/configs/InvestmentBlock/BSPar.txt | 83 +--------------- .../configs/InvestmentBlock/BundleCfg.txt | 82 +++++++++++++++ .../configs/InvestmentBlock/MPBCfg-IP.txt | 71 +++++++++++++ .../data/configs/InvestmentBlock/MPBCfg.txt | 94 +----------------- .../data/configs/InvestmentBlock/MPCfg.txt | 97 ++++++++++++++++++ pysmspp/data/configs/README.md | 4 +- .../data/configs/TSSBlock/BDSCfg-CVX-int.txt | 39 ++++++++ .../data/configs/TSSBlock/BDSMBundleCfg.txt | 99 +++++++++++++++++++ .../data/configs/TSSBlock/BDSMCfg-CVX-int.txt | 70 +++++++++++++ pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt | 87 +--------------- pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt | 72 ++++++++++++++ pysmspp/data/configs/TSSBlock/MPBCfg.txt | 88 +---------------- pysmspp/data/configs/TSSBlock/MPCfg.txt | 99 +++++++++++++++++++ .../configs/TSSBlock/TSSBSCfg-BDS-CVX-int.txt | 33 +++++++ 16 files changed, 750 insertions(+), 341 deletions(-) create mode 100644 pysmspp/data/configs/InvestmentBlock/BSPar-int.txt create mode 100644 pysmspp/data/configs/InvestmentBlock/BundleCfg.txt create mode 100644 pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt create mode 100644 pysmspp/data/configs/InvestmentBlock/MPCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/BDSCfg-CVX-int.txt create mode 100644 pysmspp/data/configs/TSSBlock/BDSMBundleCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/BDSMCfg-CVX-int.txt create mode 100644 pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt create mode 100644 pysmspp/data/configs/TSSBlock/MPCfg.txt create mode 100644 pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-int.txt diff --git a/pysmspp/data/blocks/InvestmentBlock.csv b/pysmspp/data/blocks/InvestmentBlock.csv index 4c8925a..b95db65 100644 --- a/pysmspp/data/blocks/InvestmentBlock.csv +++ b/pysmspp/data/blocks/InvestmentBlock.csv @@ -10,6 +10,7 @@ InvestmentBlock,DisinvestmentCost,Variable,Variable,double,-|NumAssets,-,,requir InvestmentBlock,LowerBound,Variable,Variable,double,-|NumAssets,-,,optional,Minimum capacity of each asset InvestmentBlock,UpperBound,Variable,Variable,double,-|NumAssets,-,,optional,Maximum capacity of each asset InvestmentBlock,InstalledQuantity,Variable,Variable,double,-|NumAssets,-,,optional,Installed capacity of each asset +InvestmentBlock,Integer,Variable,Variable,int,-|NumAssets,-,,optional,Nonzero if the design of the asset is integer (e.g. the number of its modules) InvestmentBlock,Constraints_LowerBound,Variable,Variable,double,-|NumConstraints,-,,optional,Lower bound of each constraint InvestmentBlock,Constraints_UpperBound,Variable,Variable,double,-|NumConstraints,-,,optional,Upper bound of each constraint InvestmentBlock,Constraints_A,Variable,Variable,double,-|NumConstraints-NumAssets,-,,optional,Coefficients of matrix of the linear constraints diff --git a/pysmspp/data/configs/InvestmentBlock/BSPar-int.txt b/pysmspp/data/configs/InvestmentBlock/BSPar-int.txt new file mode 100644 index 0000000..8354f9a --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/BSPar-int.txt @@ -0,0 +1,72 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BSPar-int.txt - - - - - - - - - - - - - - - +# +# A BlockSolverConfig for an InvestmentBlock whose design is integer, e.g., +# the number of modules of a modular asset: the BundleSolver of BSPar.txt +# keeping it integer, with a trust region of radius 1 and a master that is a +# mixed-integer linear problem [see intIntVars]. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BundleSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the BundleSolver + +*BundleCfg.txt + + +1 # f_diff == 1 ==> only the entries below are changed + +5 # number of integer parameters + +# now all the integer parameters +intIntVars 1 # the integer design, e.g., the modules, stay integer +intMPPrimal 1 # the primal master, where the design is the Variable +intMPV2Form 1 # raw form: the Variable of the master are the design itself +intMPStbl 4 # 4 = trust region || x - x_bar ||_inf <= t, a MILP master +intRstAlg 2 # parameter to handle the reset of the algorithm + +1 # number of double parameters + +# now all the double parameters +dbltInit 1 # radius of the trust region, in modules + +1 # number of string parameters + +# now all the string parameters +strMPBSolverCfg MPBCfg-IP.txt # the master, which keeps the integers + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BSPar-int.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/InvestmentBlock/BSPar.txt b/pysmspp/data/configs/InvestmentBlock/BSPar.txt index 635e226..c796987 100644 --- a/pysmspp/data/configs/InvestmentBlock/BSPar.txt +++ b/pysmspp/data/configs/InvestmentBlock/BSPar.txt @@ -1,12 +1,9 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - BSPar.txt - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - BSPar.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for an InvestmentBlock to be -# solved by a BundleSolver +# A BlockSolverConfig for an InvestmentBlock to be solved by a +# BundleSolver [see BundleCfg.txt]. # -# Antonio Frangioni -# -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockSolverConfig # exact type of the Configuration object @@ -21,79 +18,9 @@ BundleSolver # name of Solver # now all the ComputeConfig # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# ComputeConfig of the LagrangianDualSolver; it mostly is the -# ComputeConfig of the inner Solver, which is a [Parallel]BundleSolver - -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -17 # number of integer parameters - -# now all the integer parameters -intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly stabilized -intDoEasy 0 # do easy components for (some) LagBFunction -intMaxIter 10000 # max number of iterations for each call -intMaxThread 6 # MaxThread, max number of new tasks to spawn -intLogVerb 16 # log verbosity of main Bundle algorithm -intWZNorm 2 # which norm to use in the norm-based stopping condition -intBPar1 20 # discard items when they have been useless for iterations -intBPar2 1000 # max bundle size per component -intBPar3 1 # max n. of items to fetch from Fi() at each iteration -intBPar4 1 # min n. of items to fetch from Fi() at each iteration -intBPar6 0 # second parameter for dynamic max n. of items per iteration -intBPar7 15 # how to deal with the global pools -intMnSSC 0 # min number of consecutive SS with the same t for a t increase -intMnNSC 3 # min number of consecutive NS with the same t for a t decrease -inttSPar1 0 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = balancing) -intMaxNrEvls 2 # maximum number of function evaluations at each iteration - -intRstAlg 2 # parameter to handle the reset of the algorithm - -15 # number of double parameters - -# now all the double parameters -dblRelAcc 1e-4 # relative accuracy required to solution -dblNZEps 1e-4 # stopping parameter: threshold to declare 0 the || residual || -dbltStar -100 # stopping parameter: multiplied to || residual || to estimate gap -dblBPar5 4 # first parameter for dynamic max n. of items per iteration -dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* -dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - m2 ) v* -dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || -dblmxIncr 10 # max increase of t -dblmnIncr 1.5 # min increase of t (each time it is increased) -dblmxDecr 0.1 # max decrease of t -dblmnDecr 0.66 # min decrease of t (each time it is decreased) -dbltMaior 1e+6 # maximum value for t -dbltMinor 1e-10 # minimum value for t -dbltInit 1e+0 # initial value for t -dbltSPar2 1e-2 # parameter for the long-term t-strategy - -1 # number of string parameters - -# now all the string parameters -#str_LagBF_BSCfg LPBSCfg.txt # BlockSolverConfig for the LagBFunctions -# not needed if intDoEasy >= 1 && USE_BundleSolver > 0, this is done "by hand" -strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's Solver - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] +# ComputeConfig of the BundleSolver -# pointer to the "extra" Configuration -* # [none] +*BundleCfg.txt # end of 1st ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/InvestmentBlock/BundleCfg.txt b/pysmspp/data/configs/InvestmentBlock/BundleCfg.txt new file mode 100644 index 0000000..78608bb --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/BundleCfg.txt @@ -0,0 +1,82 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - BundleCfg.txt - - - - - - - - - - - - - - - +# +# The ComputeConfig of the BundleSolver that solves an InvestmentBlock, +# shared by BSPar.txt and BSPar-int.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +17 # number of integer parameters + +# now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, 2 = doubly +intDoEasy 0 # do easy components for (some) LagBFunction +intMaxIter 10000 # max number of iterations for each call +intMaxThread 6 # MaxThread, max number of new tasks to spawn +intLogVerb 16 # log verbosity of main Bundle algorithm +intWZNorm 2 # which norm to use in the norm-based stopping condition +intBPar1 20 # discard items when they have been useless for +intBPar2 1000 # max bundle size per component +intBPar3 1 # max n. of items to fetch from Fi() at each iteration +intBPar4 1 # min n. of items to fetch from Fi() at each iteration +intBPar6 0 # second parameter for dynamic max n. of items per +intBPar7 15 # how to deal with the global pools +intMnSSC 0 # min number of consecutive SS with the same t for a t +intMnNSC 3 # min number of consecutive NS with the same t for a t +inttSPar1 0 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = +intMaxNrEvls 2 # maximum number of function evaluations at each iteration + +intRstAlg 2 # parameter to handle the reset of the algorithm + +15 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-4 # relative accuracy required to solution +dblNZEps 1e-4 # stopping parameter: threshold to declare 0 the || +dbltStar -100 # stopping parameter: multiplied to || residual || to +dblBPar5 4 # first parameter for dynamic max n. of items per iteration +dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | +dblm2 0.90 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + ( 1 - +dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || +dblmxIncr 10 # max increase of t +dblmnIncr 1.5 # min increase of t (each time it is increased) +dblmxDecr 0.1 # max decrease of t +dblmnDecr 0.66 # min decrease of t (each time it is decreased) +dbltMaior 1e+6 # maximum value for t +dbltMinor 1e-10 # minimum value for t +dbltInit 1e+0 # initial value for t +dbltSPar2 1e-2 # parameter for the long-term t-strategy + +1 # number of string parameters + +# now all the string parameters +#str_LagBF_BSCfg LPBSCfg.txt # BlockSolverConfig for the LagBFunctions +# not needed if intDoEasy >= 1 && USE_BundleSolver > 0, this is done "by +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig for the MasterProblemBlock's + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END BundleCfg.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt b/pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt new file mode 100644 index 0000000..2460632 --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt @@ -0,0 +1,71 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - MPBCfg-IP.txt - - - - - - - - - - - - - - - +# +# A BlockSolverConfig for the :MILPSolver of the MasterProblemBlock of +# BSPar-int.txt, which keeps the integer Variable integer [see MPCfg.txt]. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +#GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +*MPCfg.txt + + +1 # f_diff == 1 ==> only the entries below are changed + +2 # number of integer parameters + +# now all the integer parameters +intRelaxIntVars 0 # the integer design stays integer +intCutSepPar 0 # no Block separates cuts in the master + +0 # number of double parameters + +# now all the double parameters +# [none] + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END MPBCfg-IP.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt index 1b49e06..036b14d 100644 --- a/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt +++ b/pysmspp/data/configs/InvestmentBlock/MPBCfg.txt @@ -1,12 +1,10 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - # -# A txt description of a BlockSolverConfig for the inner :MILPSolver of the -# MasterProblemBlock used by the BundleSolver +# A BlockSolverConfig for the inner :MILPSolver of the MasterProblemBlock +# used by the BundleSolver [see MPCfg.txt]. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BlockSolverConfig # exact type of the Configuration object @@ -26,91 +24,7 @@ HiGHSMILPSolver # name of Solver # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ComputeConfig of the :MILPSolver -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -4 # number of integer parameters - -# now all the integer parameters -intLogVerb 0 # log verbosity of the MILPSolver -intRelaxIntVars 1 # nonzero if the continuous relaxation is solved -intCutSepPar 7 # separate user cuts + lazy constraints -intMaxThread 1 # single-threaded for deterministic master reproducibility - -# All specific CPLEX parameter (uncomment based on Solver) -#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier -#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis - -# All specific GUROBI parameter (uncomment based on Solver) -#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers - # of the master ARE the algorithm, and an interior point has - # them only to about 1e-7 relative, which the stopping test - # of the bundle cannot survive; besides, the barrier cannot - # restart from the previous basis, so it re-solves the master - # from scratch at every call, while the simplex re-optimises - # after the new columns for a fraction of the iterations -#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master - # is small and re-solved thousands of times, so whatever - # extra care is asked is paid at every one of them, and 3 - # costs a factor two. 0 is not an option: with it the - # Lagrangian dual answers Unfeas on a hydrothermal instance - # that has a solution, so this is the least care that - # answers right -#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): - # left off deliberately, a master the presolve reduces is - # declared infeasible on tolerance when the model is badly - # scaled, and the bundle reads that as a numerical error - -3 # number of double parameters - -# now all the double parameters -dblRelAcc 1e-08 # relative accuracy required to solution -dblAAccSol 1e-08 # absolute accuracy required to solution -dblRAccSol 1e-08 # relative accuracy of the solution pool - -# The master has to satisfy its own rows *tighter* than the oracle satisfies -# its own feasibility, or the loop cannot end: a step that violates a -# vertical row by less than the default 1e-6 is feasible for the master and -# infeasible for the subproblem, which answers with the very cut that is -# already there, and the same iteration repeats forever. -#FeasibilityTol 1e-09 # how much a row of the master may be violated -#OptimalityTol 1e-09 # how much a reduced cost of the master may be off - -# All specific HiGHS parameter (uncomment based on Solver) -# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) -#primal_feasibility_tolerance 1e-9 -#dual_feasibility_tolerance 1e-9 - -0 # number of string parameters - -# now all the string parameters -# [none] - -#strOutputFile master.lp - -# All specific HiGHS parameter (uncomment based on Solver) -#presolve off # disable presolve for reproducibility -#solver ipm # interior point: converges to analytic center (unique x*) - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] - -# pointer to the "extra" Configuration -* # [none] +*MPCfg.txt # end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/InvestmentBlock/MPCfg.txt b/pysmspp/data/configs/InvestmentBlock/MPCfg.txt new file mode 100644 index 0000000..c95a5c8 --- /dev/null +++ b/pysmspp/data/configs/InvestmentBlock/MPCfg.txt @@ -0,0 +1,97 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - MPCfg.txt - - - - - - - - - - - - - - - - +# +# The ComputeConfig of the :MILPSolver of the MasterProblemBlock used by +# the BundleSolver, shared by MPBCfg.txt and MPBCfg-IP.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +4 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +# CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +# Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers + # of the master ARE the algorithm, and an interior point + # them only to about 1e-7 relative, which the stopping test + # of the bundle cannot survive; besides, the barrier cannot + # restart from the previous basis, so it re-solves the + # from scratch at every call, while the simplex + # after the new columns for a fraction of the iterations +#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +3 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +#FeasibilityTol 1e-09 # how much a row of the master may be violated +#OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END MPCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/README.md b/pysmspp/data/configs/README.md index 23e211c..25ec1cd 100644 --- a/pysmspp/data/configs/README.md +++ b/pysmspp/data/configs/README.md @@ -1,7 +1,7 @@ # Description of available configuration files - UCBlock/{uc_solverconfig.txt, OSolCfg.txt} copied from smspp-project/tools/ucblock_solver. -- InvestmentBlock/{BSPar.txt, uc_solverconfig.txt}, copied from smspp-project/InvestmentBlock/test/config. +- InvestmentBlock/{BSPar.txt, BSPar-int.txt, uc_solverconfig.txt}, copied from smspp-project/InvestmentBlock/test/config. - TSSBlock/* copied from smspp-project/tools/tssb_solver. - SVMBlock/* copied from smspp-project/tests/SVMBlock and smspp-project/tools/svm_solver. @@ -14,5 +14,7 @@ TSSBlock/TSSBSCfg-IP.txt, TSSBSCfg-LD-IP.txt, TSSBSCfg-LDLD.txt and TSSBSCfg-LDr TSSBlock/TSSBSCfg-BDS.txt attaches a BendersDecompositionSolver, configured by BDSCfg.txt (whose master and subproblems are those of BDSMCfg.txt and BDSSCfg.txt), to the Benders form of a two-stage problem, which smspp_tssb_solver assembles when given -k (`k=None` of TSSBSolver), also around a MultiStageStochasticBlock, whose leaves are then the subproblems. TSSBSCfg-BDS-LD.txt is the same with the subproblems solved by the recursive Lagrangian dual of TSSBSCfg-LDrec.txt and a feasible solution recovered at the design of the master (strRecoveryBSC in BDSCfg-LD.txt, each subproblem a MILP of BSCfg1-IP.txt), and TSSBSCfg-BDS-CVX-LD.txt the latter with the master solved by the BundleSolver of BDSMCfg-CVX.txt (the convex regime), which recovers the feasible solution at the best point of its bundle. TSSBlock/TSSBSCfg-IB.txt is the ad hoc Benders decomposition of the same problem: a BundleSolver on an InvestmentBlock over the TSSB or the MSSB (the `investment_outside` form of pypsa2smspp), whose inner Block is solved whole at every evaluation by BSCfg-IB.txt; with the BlockConfig InnerBCfg-LD.txt instead of InnerBCfg.txt the inner Block is solved by the recursive Lagrangian dual (IBOCfg-LD.txt, IFCfg-LD.txt). +InvestmentBlock/BSPar-int.txt solves an InvestmentBlock whose design is integer, e.g., the number of modules of a modular asset (the `Integer` variable of the InvestmentBlock), with the BundleSolver of BSPar.txt keeping the design integer (`intIntVars`), a trust region of radius 1 and a master that is a mixed-integer linear problem (MPBCfg-IP.txt), which HiGHS solves; BSPar.txt and BSPar-int.txt share the ComputeConfig of the BundleSolver (BundleCfg.txt), and MPBCfg.txt and MPBCfg-IP.txt that of the master (MPCfg.txt). TSSBlock/TSSBSCfg-BDS-CVX-int.txt does the same for the Benders form of a two-stage problem whose design is integer: the BendersDecompositionSolver of TSSBSCfg-BDS.txt in the convex regime (BDSCfg-CVX-int.txt), whose master is solved by the BundleSolver of BDSMCfg-CVX-int.txt, which keeps the design integer in the same way (the ComputeConfig BDSMBundleCfg.txt being shared with BDSMCfg-CVX.txt, and MPCfg.txt with MPBCfg.txt), and gives the same value as the MILP regime of TSSBSCfg-BDS.txt. + The templates that use the BundleSolver are written for the BundleSolver 2.0: `strMPBSolverCfg` names MPBCfg.txt, the BlockSolverConfig of the Solver of its master, and they do not load with an SMS++ whose bundle is the 1.0. MPBCfg.txt solves the master with HiGHS, which needs an SMS++ whose HiGHSMILPSolver regularizes the QP of the master (the one of HiGHS 1.15 may otherwise call it non-convex), and the version using Gurobi is provided under name MPBCfg_grb.txt, to be named by `strMPBSolverCfg` in its place. diff --git a/pysmspp/data/configs/TSSBlock/BDSCfg-CVX-int.txt b/pysmspp/data/configs/TSSBlock/BDSCfg-CVX-int.txt new file mode 100644 index 0000000..09f1973 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSCfg-CVX-int.txt @@ -0,0 +1,39 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - BDSCfg-CVX-int.txt - - - - - - - - - - - - - - +# +# The ComputeConfig of BDSCfg.txt in the convex regime when the design is +# integer: the master is solved by the BundleSolver of BDSMCfg-CVX-int.txt, +# which keeps the design integer, the value functions of the subproblems +# being components of its Objective. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*BDSCfg.txt + + +1 # f_diff == 1 ==> only the entries listed below are changed + +1 # number of integer parameters + +# now all the integer parameters +int_BDSlv_Regime 0 # 0 = convex master, 1 = MILP master + +0 # number of double parameters + +1 # number of string parameters + +# now all the string parameters +str_Mstr_BSCfg BDSMCfg-CVX-int.txt # BlockSolverConfig of the master + +0 # number of vector-of-int parameters + +0 # number of vector-of-double parameters + +0 # number of vector-of-string parameters + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END BDSCfg-CVX-int.txt - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSMBundleCfg.txt b/pysmspp/data/configs/TSSBlock/BDSMBundleCfg.txt new file mode 100644 index 0000000..04f7b1f --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSMBundleCfg.txt @@ -0,0 +1,99 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - BDSMBundleCfg.txt - - - - - - - - - - - - - - +# +# The ComputeConfig of the BundleSolver on the master problem of +# BendersDecompositionSolver in the convex regime, shared by +# BDSMCfg-CVX.txt and BDSMCfg-CVX-int.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +13 # number of integer parameters + +# now all the integer parameters +intMPStbl 0 # stabilization: 0 = proximal, 1 = level, + # 2 = doubly stabilized +intMaxIter 100000 # MaxIter, max number of iterations for each call +intLogVerb 0 # LogVerb, log verbosity of main Bundle algorithm +intBPar1 20 # discard items when they have been useless for + # iterations +intBPar2 400 # max bundle size per component +intBPar3 1 # max n. of items to fetch from Fi() at each iteration +intBPar4 1 # min n. of items to fetch from Fi() at each iteration +intBPar6 0 # second parameter for dynamic max n. of items per + # iteration +intBPar7 11 # how to deal with the global pools +intMnSSC 0 # min number of consecutive SS with the same t for a t + # increase +intMnNSC 1 # min number of consecutive NS with the same t for a t + # decrease +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, + # 12 = balancing): the master knows nothing of the scale + # of the design Variable, and letting it balance the + # stabilization against the model is what finds it +intMaxNrEvls 2 # maximum number of function evaluations per iteration + +15 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-8 # relative accuracy required to solution: with 1e-6 + # the bundle may stop short of it where the scenarios + # differ the most, and give an upper bound instead of + # a value +dblNZEps 1e-4 # stopping parameter: threshold to declare 0 the + # || residual ||, below which the lower bound is + # certified: the linearizations of subproblems solved + # by a Lagrangian dual are accurate to its dblRelAcc + # (1e-5 in TSSBSCfg-LDrec.txt), and with a smaller + # threshold the Solver reports the optimum without a + # bound +dbltStar 1e+4 # stopping parameter: multiplied to || residual || to + # estimate gap +dblBPar5 4 # first parameter for dynamic max n. of items per + # iteration +dblm1 -0.01 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + # + | m1 | v* +dblm2 0.99 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) + # + ( 1 - m2 ) v* +dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || +dblmxIncr 10 # max increase of t +dblmnIncr 1.5 # min increase of t (each time it is increased) +dblmxDecr 0.1 # max decrease of t +dblmnDecr 0.66 # min decrease of t (each time it is decreased) +dbltMaior 1e+6 # maximum value for t +dbltMinor 1e-4 # minimum value for t +dbltInit 1e+3 # initial value for t, at the scale of a design in MW: + # with 1e+5 the bundle may stop before the optimum +dbltSPar2 0.001 # parameter for the long-term t-strategy + +1 # number of string parameters + +# now all the string parameters +strMPBSolverCfg MPBCfg.txt # BlockSolverConfig of the + # MasterProblemBlock Solver + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END BDSMBundleCfg.txt - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX-int.txt b/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX-int.txt new file mode 100644 index 0000000..bc76182 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX-int.txt @@ -0,0 +1,70 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - BDSMCfg-CVX-int.txt - - - - - - - - - - - - - - +# +# The BlockSolverConfig of the master problem of BendersDecompositionSolver +# in the convex regime when the design is integer, e.g., the number of +# modules of a modular asset: the BundleSolver of BDSMCfg-CVX.txt keeping +# it integer, with a trust region of radius 1 and a master that is a +# mixed-integer linear problem [see intIntVars]. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one: values are being set + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BundleSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*BDSMBundleCfg.txt + + +1 # f_diff == 1 ==> only the entries below are changed + +4 # number of integer parameters + +# now all the integer parameters +intIntVars 1 # the integer design, e.g., the modules, stay integer +intMPPrimal 1 # the primal master, where the design is the Variable +intMPV2Form 1 # raw form: the Variable of the master are the design itself +intMPStbl 4 # 4 = trust region || x - x_bar ||_inf <= t, a MILP master + +1 # number of double parameters + +# now all the double parameters +dbltInit 1 # radius of the trust region, in modules + +1 # number of string parameters + +# now all the string parameters +strMPBSolverCfg MPBCfg-IP.txt # the master, which keeps the integers + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - END BDSMCfg-CVX-int.txt - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt b/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt index eaebd25..b6ae701 100644 --- a/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt +++ b/pysmspp/data/configs/TSSBlock/BDSMCfg-CVX.txt @@ -23,92 +23,7 @@ BundleSolver # name of Solver # now all the ComputeConfig # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -13 # number of integer parameters - -# now all the integer parameters -intMPStbl 0 # stabilization: 0 = proximal, 1 = level, - # 2 = doubly stabilized -intMaxIter 100000 # MaxIter, max number of iterations for each call -intLogVerb 0 # LogVerb, log verbosity of main Bundle algorithm -intBPar1 20 # discard items when they have been useless for - # iterations -intBPar2 400 # max bundle size per component -intBPar3 1 # max n. of items to fetch from Fi() at each iteration -intBPar4 1 # min n. of items to fetch from Fi() at each iteration -intBPar6 0 # second parameter for dynamic max n. of items per - # iteration -intBPar7 11 # how to deal with the global pools -intMnSSC 0 # min number of consecutive SS with the same t for a t - # increase -intMnNSC 1 # min number of consecutive NS with the same t for a t - # decrease -inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, - # 12 = balancing): the master knows nothing of the scale - # of the design Variable, and letting it balance the - # stabilization against the model is what finds it -intMaxNrEvls 2 # maximum number of function evaluations per iteration - -15 # number of double parameters - -# now all the double parameters -dblRelAcc 1e-8 # relative accuracy required to solution: with 1e-6 - # the bundle may stop short of it where the scenarios - # differ the most, and give an upper bound instead of - # a value -dblNZEps 1e-4 # stopping parameter: threshold to declare 0 the - # || residual ||, below which the lower bound is - # certified: the linearizations of subproblems solved - # by a Lagrangian dual are accurate to its dblRelAcc - # (1e-5 in TSSBSCfg-LDrec.txt), and with a smaller - # threshold the Solver reports the optimum without a - # bound -dbltStar 1e+4 # stopping parameter: multiplied to || residual || to - # estimate gap -dblBPar5 4 # first parameter for dynamic max n. of items per - # iteration -dblm1 -0.01 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) - # + | m1 | v* -dblm2 0.99 # a SS is possible if Fi( Lambda1 ) <= Fi( Lambda ) - # + ( 1 - m2 ) v* -dblm3 0.99 # a NR is computed if \sigma^* < - t * m3 * || z* || -dblmxIncr 10 # max increase of t -dblmnIncr 1.5 # min increase of t (each time it is increased) -dblmxDecr 0.1 # max decrease of t -dblmnDecr 0.66 # min decrease of t (each time it is decreased) -dbltMaior 1e+6 # maximum value for t -dbltMinor 1e-4 # minimum value for t -dbltInit 1e+3 # initial value for t, at the scale of a design in MW: - # with 1e+5 the bundle may stop before the optimum -dbltSPar2 0.001 # parameter for the long-term t-strategy - -1 # number of string parameters - -# now all the string parameters -strMPBSolverCfg MPBCfg.txt # BlockSolverConfig of the - # MasterProblemBlock Solver - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] - -# pointer to the "extra" Configuration -* # [none] +*BDSMBundleCfg.txt # end 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt b/pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt new file mode 100644 index 0000000..0306424 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt @@ -0,0 +1,72 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - MPBCfg-IP.txt - - - - - - - - - - - - - - - +# +# A BlockSolverConfig for the :MILPSolver of the MasterProblemBlock of +# BDSMCfg-CVX-int.txt, which keeps the integer Variable integer [see +# MPCfg.txt]. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +1 # the BlockSolverConfig is a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig + +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +#CPXMILPSolver # name of Solver +#GRBMILPSolver # name of Solver +#SCIPMILPSolver # name of Solver +HiGHSMILPSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ComputeConfig of the :MILPSolver + +*MPCfg.txt + + +1 # f_diff == 1 ==> only the entries below are changed + +2 # number of integer parameters + +# now all the integer parameters +intRelaxIntVars 0 # the integer design stays integer +intCutSepPar 0 # no Block separates cuts in the master + +0 # number of double parameters + +# now all the double parameters +# [none] + +0 # number of string parameters + +# now all the string parameters +# [none] + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig- - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - END MPBCfg-IP.txt - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/MPBCfg.txt b/pysmspp/data/configs/TSSBlock/MPBCfg.txt index 1b49e06..dd3804b 100644 --- a/pysmspp/data/configs/TSSBlock/MPBCfg.txt +++ b/pysmspp/data/configs/TSSBlock/MPBCfg.txt @@ -2,7 +2,7 @@ # - - - - - - - - - - - - - - - MPBCfg.txt - - - - - - - - - - - - - - - - - # # A txt description of a BlockSolverConfig for the inner :MILPSolver of the -# MasterProblemBlock used by the BundleSolver +# MasterProblemBlock used by the BundleSolver [see MPCfg.txt] # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -26,91 +26,7 @@ HiGHSMILPSolver # name of Solver # 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ComputeConfig of the :MILPSolver -ComputeConfig # exact type of the ComputeConfig object - -1 # f_diff == 0 ==> all non-provided parameters are set to the default value - # f_diff == 1 ==> all non-provided parameters are not changed - -4 # number of integer parameters - -# now all the integer parameters -intLogVerb 0 # log verbosity of the MILPSolver -intRelaxIntVars 1 # nonzero if the continuous relaxation is solved -intCutSepPar 7 # separate user cuts + lazy constraints -intMaxThread 1 # single-threaded for deterministic master reproducibility - -# All specific CPLEX parameter (uncomment based on Solver) -#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = barrier -#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis - -# All specific GUROBI parameter (uncomment based on Solver) -#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the multipliers - # of the master ARE the algorithm, and an interior point has - # them only to about 1e-7 relative, which the stopping test - # of the bundle cannot survive; besides, the barrier cannot - # restart from the previous basis, so it re-solves the master - # from scratch at every call, while the simplex re-optimises - # after the new columns for a fraction of the iterations -#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master - # is small and re-solved thousands of times, so whatever - # extra care is asked is paid at every one of them, and 3 - # costs a factor two. 0 is not an option: with it the - # Lagrangian dual answers Unfeas on a hydrothermal instance - # that has a solution, so this is the least care that - # answers right -#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): - # left off deliberately, a master the presolve reduces is - # declared infeasible on tolerance when the model is badly - # scaled, and the bundle reads that as a numerical error - -3 # number of double parameters - -# now all the double parameters -dblRelAcc 1e-08 # relative accuracy required to solution -dblAAccSol 1e-08 # absolute accuracy required to solution -dblRAccSol 1e-08 # relative accuracy of the solution pool - -# The master has to satisfy its own rows *tighter* than the oracle satisfies -# its own feasibility, or the loop cannot end: a step that violates a -# vertical row by less than the default 1e-6 is feasible for the master and -# infeasible for the subproblem, which answers with the very cut that is -# already there, and the same iteration repeats forever. -#FeasibilityTol 1e-09 # how much a row of the master may be violated -#OptimalityTol 1e-09 # how much a reduced cost of the master may be off - -# All specific HiGHS parameter (uncomment based on Solver) -# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) -#primal_feasibility_tolerance 1e-9 -#dual_feasibility_tolerance 1e-9 - -0 # number of string parameters - -# now all the string parameters -# [none] - -#strOutputFile master.lp - -# All specific HiGHS parameter (uncomment based on Solver) -#presolve off # disable presolve for reproducibility -#solver ipm # interior point: converges to analytic center (unique x*) - -0 # number of vector-of-int parameters - -# now all the vector-of-int parameters -# [none] - -0 # number of vector-of-double parameters - -# now all the vector-of-double parameters -# [none] - -0 # number of vector-of-string parameters - -# now all the vector-of-string parameters -# [none] - -# pointer to the "extra" Configuration -* # [none] +*MPCfg.txt # end of ComputeConfig- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/MPCfg.txt b/pysmspp/data/configs/TSSBlock/MPCfg.txt new file mode 100644 index 0000000..0a4c2f7 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/MPCfg.txt @@ -0,0 +1,99 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - MPCfg.txt - - - - - - - - - - - - - - - - +# +# The ComputeConfig of the :MILPSolver of the MasterProblemBlock used by +# the BundleSolver, shared by MPBCfg.txt and MPBCfg-IP.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ComputeConfig # exact type of the ComputeConfig object + +1 # f_diff == 0 ==> all non-provided parameters are set to the default value + # f_diff == 1 ==> all non-provided parameters are not changed + +4 # number of integer parameters + +# now all the integer parameters +intLogVerb 0 # log verbosity of the MILPSolver +intRelaxIntVars 1 # nonzero if the continuous relaxation is solved +intCutSepPar 7 # separate user cuts + lazy constraints +intMaxThread 1 # single-threaded for deterministic master reproducibility + +# All specific CPLEX parameter (uncomment based on Solver) +#CPXPARAM_LPMethod 1 # 0 = auto, 1 = primal, 2 = dual, 4 = + # barrier +#CPXPARAM_Emphasis_Numerical 1 # numerical precision emphasis + +# All specific GUROBI parameter (uncomment based on Solver) +#Method 1 # 0 = primal, 1 = dual simplex, 2 = barrier: the + # multipliers of the master ARE the algorithm, and an + # interior point has them only to about 1e-7 relative, + # which the stopping test of the bundle cannot survive; + # besides, the barrier cannot restart from the previous + # basis, so it re-solves the master from scratch at every + # call, while the simplex re-optimises after the new + # columns for a fraction of the iterations +#NumericFocus 1 # 0 = auto, 1..3 = increasing precision focus: the master + # is small and re-solved thousands of times, so whatever + # extra care is asked is paid at every one of them, and 3 + # costs a factor two. 0 is not an option: with it the + # Lagrangian dual answers Unfeas on a hydrothermal instance + # that has a solution, so this is the least care that + # answers right +#Presolve 0 # 0 = off, 1 = conservative, 2 = aggressive (default -1): + # left off deliberately, a master the presolve reduces is + # declared infeasible on tolerance when the model is badly + # scaled, and the bundle reads that as a numerical error + +3 # number of double parameters + +# now all the double parameters +dblRelAcc 1e-08 # relative accuracy required to solution +dblAAccSol 1e-08 # absolute accuracy required to solution +dblRAccSol 1e-08 # relative accuracy of the solution pool + +# The master has to satisfy its own rows *tighter* than the oracle satisfies +# its own feasibility, or the loop cannot end: a step that violates a +# vertical row by less than the default 1e-6 is feasible for the master and +# infeasible for the subproblem, which answers with the very cut that is +# already there, and the same iteration repeats forever. +#FeasibilityTol 1e-09 # how much a row of the master may be violated +#OptimalityTol 1e-09 # how much a reduced cost of the master may be off + +# All specific HiGHS parameter (uncomment based on Solver) +# (not tighter: at 1e-9 the QP solver of HiGHS fails on the master) +#primal_feasibility_tolerance 1e-9 +#dual_feasibility_tolerance 1e-9 + +0 # number of string parameters + +# now all the string parameters +# [none] + +#strOutputFile master.lp + +# All specific HiGHS parameter (uncomment based on Solver) +#presolve off # disable presolve for reproducibility +#solver ipm # interior point: converges to analytic center (unique x*) + +0 # number of vector-of-int parameters + +# now all the vector-of-int parameters +# [none] + +0 # number of vector-of-double parameters + +# now all the vector-of-double parameters +# [none] + +0 # number of vector-of-string parameters + +# now all the vector-of-string parameters +# [none] + +# pointer to the "extra" Configuration +* # [none] + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - END MPCfg.txt - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-int.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-int.txt new file mode 100644 index 0000000..a6542a6 --- /dev/null +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-BDS-CVX-int.txt @@ -0,0 +1,33 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - TSSBSCfg-BDS-CVX-int.txt - - - - - - - - - - - - - +# +# The BendersDecompositionSolver of TSSBSCfg-BDS.txt in the convex regime +# when the design is integer (BDSCfg-CVX-int.txt): a BundleSolver on the +# master that keeps the design integer, the subproblems those of +# BDSSCfg.txt. +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BlockSolverConfig # exact type of the Configuration object + +0 # the BlockSolverConfig is not a "differential" one + +1 # number of (the names of) Solver in this BlockSolverConfig +# now all the names of the Solver - - - - - - - - - - - - - - - - - - - - - - +BendersDecompositionSolver # name of Solver + +1 # number of ComputeConfig in this BlockSolverConfig + +# now all the ComputeConfig +# 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +*BDSCfg-CVX-int.txt + +# end of 1st ComputeConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# end of BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - END TSSBSCfg-BDS-CVX-int.txt - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From d149b14cf7de21643da00642104081e8bfe4053c Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Thu, 1 Oct 2026 17:43:43 +0200 Subject: [PATCH 25/28] the InvestmentBlock over a stochastic Block asks its bundle for dblNZEps 1e-9 and dblRelAcc 1e-6: dblNZEps is relative to the first full subgradient, which at a design of 0 is millions, and with 1e-4 the bundle stopped 2.9% above the optimum --- pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt index e64097d..7374928 100644 --- a/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt +++ b/pysmspp/data/configs/TSSBlock/TSSBSCfg-IB.txt @@ -57,8 +57,12 @@ intRstAlg 2 # parameter to handle the reset of the algorithm 15 # number of double parameters # now all the double parameters -dblRelAcc 1e-4 # relative accuracy required to solution -dblNZEps 1e-4 # stopping parameter: threshold to declare 0 the || residual || +dblRelAcc 1e-6 # relative accuracy required to solution +dblNZEps 1e-9 # stopping parameter: threshold to declare 0 the || residual ||, + # relative to the first full subgradient (intWZNorm 10), + # which at a design of 0 is millions: with 1e-4 the bundle + # stops where the residual is still a few units, far from + # the optimum (2.9% above it on a TSSB of 9 scenarios) dbltStar -100 # stopping parameter: multiplied to || residual || to estimate gap dblBPar5 4 # first parameter for dynamic max n. of items per iteration dblm1 -0.30 # a NS is possible if (~) Fi( Lambda1 ) >= Fi( Lambda ) + | m1 | v* From c91864b8bf3eb3aa58ec8012efc0f86d375a6d11 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Fri, 2 Oct 2026 13:48:37 +0200 Subject: [PATCH 26/28] the integer masters ask HiGHS for an integrality tolerance of 1e-10: the bundle rounds the point of the master before evaluating it, and with the default 1e-6 the linearization there may not cut it away --- pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt | 6 ++++-- pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt b/pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt index 2460632..32536d0 100644 --- a/pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt +++ b/pysmspp/data/configs/InvestmentBlock/MPBCfg-IP.txt @@ -34,10 +34,12 @@ HiGHSMILPSolver # name of Solver intRelaxIntVars 0 # the integer design stays integer intCutSepPar 0 # no Block separates cuts in the master -0 # number of double parameters +1 # number of double parameters # now all the double parameters -# [none] +mip_feasibility_tolerance 1e-10 + # integrality as tight as HiGHS allows: the bundle + # rounds the point of the master before evaluating it 0 # number of string parameters diff --git a/pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt b/pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt index 0306424..f722a9d 100644 --- a/pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt +++ b/pysmspp/data/configs/TSSBlock/MPBCfg-IP.txt @@ -35,10 +35,12 @@ HiGHSMILPSolver # name of Solver intRelaxIntVars 0 # the integer design stays integer intCutSepPar 0 # no Block separates cuts in the master -0 # number of double parameters +1 # number of double parameters # now all the double parameters -# [none] +mip_feasibility_tolerance 1e-10 + # integrality as tight as HiGHS allows: the bundle + # rounds the point of the master before evaluating it 0 # number of string parameters From 5115bb6e2b4fddfc6fdda1139384b2ea7fba7ef7 Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Fri, 2 Oct 2026 18:07:18 +0200 Subject: [PATCH 27/28] the InvestmentBlock bundle has the balancing long-term t-strategy, and its Gurobi variant solves the inner LP with the default presolve and numerical focus: on a deterministic capacity expansion with 20 nodes it reaches the optimum in 20 minutes instead of not closing in 50 --- .../data/configs/InvestmentBlock/BSCfg_grb.txt | 16 ++++++---------- .../data/configs/InvestmentBlock/BundleCfg.txt | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/pysmspp/data/configs/InvestmentBlock/BSCfg_grb.txt b/pysmspp/data/configs/InvestmentBlock/BSCfg_grb.txt index 792032c..d395524 100644 --- a/pysmspp/data/configs/InvestmentBlock/BSCfg_grb.txt +++ b/pysmspp/data/configs/InvestmentBlock/BSCfg_grb.txt @@ -3,13 +3,11 @@ # # Gurobi variant of BSCfg.txt: a BlockSolverConfig for the inner UCBlock-style # block of an InvestmentBlock, to be solved by GRBMILPSolver as the LP -# relaxation (intRelaxIntVars 1) of the underlying MIP. Presolve is disabled -# for reproducibility (it can transform the model and shift the optimal vertex -# on degenerate LPs), and NumericFocus is raised because the InvestmentBlock -# inner LPs are badly scaled (capacities, snapshot-weighted costs and VOLL span -# many orders of magnitude), which makes HiGHS fail on some iterates. -# -# Antonio Frangioni, Donato Meoli +# relaxation (intRelaxIntVars 1) of the underlying MIP, with the presolve and +# the numerical focus of Gurobi left at their default: the inner LP is solved +# at every evaluation of the InvestmentFunction, and with Presolve 0 and +# NumericFocus 3 each evaluation cost 2.5 times as much, which the badly +# scaled LPs that make HiGHS fail (see BSCfg.txt) do not need with Gurobi. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # BlockSolverConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -33,7 +31,7 @@ ComputeConfig # exact type of the ComputeConfig object 1 # f_diff == 0 ==> all non-provided parameters are set to the default value # f_diff == 1 ==> all non-provided parameters are not changed -5 # number of integer parameters +3 # number of integer parameters # now all the integer parameters intLogVerb 0 # LogVerb, log verbosity of the MILPSolver @@ -41,8 +39,6 @@ intRelaxIntVars 1 # nonzero if the continuous relaxation is solved intCutSepPar 7 # separate user cuts + lazy constraints # All specific GUROBI parameter -Presolve 0 # disable presolve for reproducibility -NumericFocus 3 # maximum numerical precision focus 0 # number of double parameters diff --git a/pysmspp/data/configs/InvestmentBlock/BundleCfg.txt b/pysmspp/data/configs/InvestmentBlock/BundleCfg.txt index 78608bb..94df851 100644 --- a/pysmspp/data/configs/InvestmentBlock/BundleCfg.txt +++ b/pysmspp/data/configs/InvestmentBlock/BundleCfg.txt @@ -28,7 +28,7 @@ intBPar6 0 # second parameter for dynamic max n. of items per intBPar7 15 # how to deal with the global pools intMnSSC 0 # min number of consecutive SS with the same t for a t intMnNSC 3 # min number of consecutive NS with the same t for a t -inttSPar1 0 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = +inttSPar1 12 # long-term t-strategy (0 = none, 4 = soft, 8 = hard, 12 = intMaxNrEvls 2 # maximum number of function evaluations at each iteration intRstAlg 2 # parameter to handle the reset of the algorithm From 15e16c93646397aae7e953961e40334bb51b75bf Mon Sep 17 00:00:00 2001 From: Donato Meoli Date: Sun, 4 Oct 2026 23:18:57 +0200 Subject: [PATCH 28/28] the MILP of the TSSB templates keeps intCutSepPar 7: its callback makes Gurobi 1.4 to 5.4 times faster on these networks than 0, measured on the same machine --- pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt index adcb4e9..548f5d3 100644 --- a/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt +++ b/pysmspp/data/configs/TSSBlock/MILPCfg-IP.txt @@ -15,8 +15,9 @@ ComputeConfig # exact type of the ComputeConfig object intLogVerb 0 # log verbosity of the MILPSolver intRelaxIntVars 0 # nonzero if the continuous relaxation is solved -intCutSepPar 0 # no separation: no Block here separates, and the lazy - # constraints would only cost Gurobi memory +intCutSepPar 7 # separate user cuts + lazy constraints: no Block here + # separates, but the callback that comes with them makes + # Gurobi faster on these MILPs (1.4 to 5.4 times than 0) 2 # number of double parameters