diff --git a/CHANGELOG.md b/CHANGELOG.md index 83710c9a69..b14badf4fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Load` and `LoadWeight` keys in the `time_domain_reduction_settings.yml` file are renamed to `Demand`, `DemandWeight`. - The `New_Build` column in `Generators_data.csv` has been separated into two: `New_Build` and `Can_Retire` (#392). Values in each column are {0,1}. +- Separate proprietary JuMP solvers from the GenX package. + This allows users of Gurobi or CPLEX to use them without modifying + the source code of the GenX package directly. This is a key step in publishing + GenX as a proper Julia package. This does require change to the Run.jl files, + to specify the solver. (#531) ### Deprecated - The above `load` keys, which generally refer to electrical demand, are being deprecated. @@ -52,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 except for a few places such as the common term "value of lost load" which refers to non-served demand (#397). - `New_Build = -1` in `Generators_data.csv`: instead, use `New_Build = 0` and `Can_Retire = 0`. + ## [0.3.6] - 2023-08-01 ### Fixed diff --git a/Example_Systems/Electrolyzer_Example/Settings/genx_settings.yml b/Example_Systems/Electrolyzer_Example/Settings/genx_settings.yml index 36b1441359..8a8206feeb 100644 --- a/Example_Systems/Electrolyzer_Example/Settings/genx_settings.yml +++ b/Example_Systems/Electrolyzer_Example/Settings/genx_settings.yml @@ -62,11 +62,8 @@ StorageLosses: 1 # 1 = yes HydrogenHourlyMatching: 1 -## Solver settings -# ---------------- - -# Available solvers: Gurobi, CPLEX, Clps -# Solver: HiGHS +## Solution settings +# ------------------ # Internally scale demand, capacity and power variables in GW rather than MW. # 0 = not active diff --git a/Example_Systems/MethodofMorrisExample/OneZone/Settings/genx_settings.yml b/Example_Systems/MethodofMorrisExample/OneZone/Settings/genx_settings.yml index 263ab8189a..470534eee4 100644 --- a/Example_Systems/MethodofMorrisExample/OneZone/Settings/genx_settings.yml +++ b/Example_Systems/MethodofMorrisExample/OneZone/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 0 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, Clp, Cbc ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 0 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/PiecewiseFuel_CO2_Example/Settings/genx_settings.yml b/Example_Systems/PiecewiseFuel_CO2_Example/Settings/genx_settings.yml index 53646d1cd3..f24ebf08da 100644 --- a/Example_Systems/PiecewiseFuel_CO2_Example/Settings/genx_settings.yml +++ b/Example_Systems/PiecewiseFuel_CO2_Example/Settings/genx_settings.yml @@ -60,14 +60,11 @@ CO2Cap: 1 # Hydrogen electrolyzer hourly supply matching required? # 0 = constraint ot active # 1 = constraint active for all electrolyzer resources -#HydrogenHourlyMatching: 0 +# HydrogenHourlyMatching: 0 -## Solver settings +## Solution settings # ---------------- -# Available solvers: Gurobi, CPLEX, Clps -#Solver: HiGHS - # Internally scale demand, capacity and power variables in GW rather than MW. # 0 = not active # 1 = active systemwide @@ -76,11 +73,11 @@ ParameterScale: 1 # Time domain reduce (i.e. cluster) inputs based on demand, resource availability profiles, and fuel prices; # 0 = not active (use input data as provided) # 1 = active (cluster input data, or use data that has already been clustered) -#TimeDomainReduction: 0 +# TimeDomainReduction: 0 # Directory where results from time domain reduction will be saved. # If results already exist, these will be used without running time domain reduction script again. -#TimeDomainReductionFolder: "TDR_Results" +# TimeDomainReductionFolder: "TDR_Results" ## Output settings # ---------------- diff --git a/Example_Systems/ProprietarySolver/CO2_cap.csv b/Example_Systems/ProprietarySolver/CO2_cap.csv new file mode 100644 index 0000000000..1b5869ce2e --- /dev/null +++ b/Example_Systems/ProprietarySolver/CO2_cap.csv @@ -0,0 +1,2 @@ +,Network_zones,CO_2_Cap_Zone_1,CO_2_Max_tons_MWh_1,CO_2_Max_Mtons_1 +NE,z1,1,0.05,0.018 diff --git a/Example_Systems/ProprietarySolver/Capacity_reserve_margin.csv b/Example_Systems/ProprietarySolver/Capacity_reserve_margin.csv new file mode 100644 index 0000000000..1cda938c80 --- /dev/null +++ b/Example_Systems/ProprietarySolver/Capacity_reserve_margin.csv @@ -0,0 +1,2 @@ +,Network_zones,CapRes_1 +NE,z1,0.156 diff --git a/Example_Systems/ProprietarySolver/Demand_data.csv b/Example_Systems/ProprietarySolver/Demand_data.csv new file mode 100644 index 0000000000..a8a2c224e7 --- /dev/null +++ b/Example_Systems/ProprietarySolver/Demand_data.csv @@ -0,0 +1,25 @@ +Voll,Demand_Segment,Cost_of_Demand_Curtailment_per_MW,Max_Demand_Curtailment,Rep_Periods,Timesteps_per_Rep_Period,Sub_Weights,Time_Index,Demand_MW_z1 +50000,1,1,1,1,24,8760,1,11162 +,,,,,,,2,10556 +,,,,,,,3,10105 +,,,,,,,4,9878 +,,,,,,,5,9843 +,,,,,,,6,10017 +,,,,,,,7,10390 +,,,,,,,8,10727 +,,,,,,,9,11298 +,,,,,,,10,11859 +,,,,,,,11,12196 +,,,,,,,12,12321 +,,,,,,,13,12381 +,,,,,,,14,12270 +,,,,,,,15,12149 +,,,,,,,16,12219 +,,,,,,,17,13410 +,,,,,,,18,14539 +,,,,,,,19,14454 +,,,,,,,20,14012 +,,,,,,,21,13494 +,,,,,,,22,12772 +,,,,,,,23,11877 +,,,,,,,24,10874 diff --git a/Example_Systems/ProprietarySolver/Fuels_data.csv b/Example_Systems/ProprietarySolver/Fuels_data.csv new file mode 100644 index 0000000000..64ea2d8074 --- /dev/null +++ b/Example_Systems/ProprietarySolver/Fuels_data.csv @@ -0,0 +1,26 @@ +Time_Index,NG +0,0.05306 +1,5.28 +2,5.28 +3,5.28 +4,5.28 +5,5.28 +6,5.28 +7,5.28 +8,5.28 +9,5.28 +10,5.28 +11,5.28 +12,5.28 +13,5.28 +14,5.28 +15,5.28 +16,5.28 +17,5.28 +18,5.28 +19,5.28 +20,5.28 +21,5.28 +22,5.28 +23,5.28 +24,5.28 diff --git a/Example_Systems/ProprietarySolver/Generators_data.csv b/Example_Systems/ProprietarySolver/Generators_data.csv new file mode 100644 index 0000000000..8f0d856757 --- /dev/null +++ b/Example_Systems/ProprietarySolver/Generators_data.csv @@ -0,0 +1,5 @@ +Resource,Zone,THERM,MUST_RUN,STOR,FLEX,HYDRO,VRE,LDS,Num_VRE_Bins,New_Build,Can_Retire,Existing_Cap_MW,Existing_Cap_MWh,Existing_Charge_Cap_MW,Max_Cap_MW,Max_Cap_MWh,Max_Charge_Cap_MW,Min_Cap_MW,Min_Cap_MWh,Min_Charge_Cap_MW,Inv_Cost_per_MWyr,Inv_Cost_per_MWhyr,Inv_Cost_Charge_per_MWyr,Fixed_OM_Cost_per_MWyr,Fixed_OM_Cost_per_MWhyr,Fixed_OM_Cost_Charge_per_MWyr,Var_OM_Cost_per_MWh,Var_OM_Cost_per_MWh_In,Heat_Rate_MMBTU_per_MWh,Fuel,Cap_Size,Start_Cost_per_MW,Start_Fuel_MMBTU_per_MW,Up_Time,Down_Time,Ramp_Up_Percentage,Ramp_Dn_Percentage,Min_Power,Self_Disch,Eff_Up,Eff_Down,Min_Duration,Max_Duration,MaxCapTag_1,MaxCapTag_2,MaxCapTag_3,Resource_Type,CapRes_1,region,cluster +natural_gas_combined_cycle,1,1,0,0,0,0,0,0,0,1,0,0,0,0,-1,-1,-1,0,0,0,65400,0,0,10287,0,0,3.55,0,7.43,NG,250,91,2,6,6,0.64,0.64,0.468,0,1,1,0,0,0,0,0,natural_gas_fired_combined_cycle,0.93,NE,1 +solar_pv,1,0,0,0,0,0,1,0,1,1,0,0,0,0,-1,-1,-1,0,0,0,85300,0,0,18760,0,0,0,0,9.13,None,0,0,0,0,0,1,1,0,0,1,1,0,0,1,0,0,solar_photovoltaic,0.8,NE,1 +onshore_wind,1,0,0,0,0,0,1,0,1,1,0,0,0,0,-1,-1,-1,0,0,0,97200,0,0,43205,0,0,0.1,0,9.12,None,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,0,onshore_wind_turbine,0.8,NE,1 +battery,1,0,0,1,0,0,0,0,0,1,0,0,0,0,-1,-1,-1,0,0,0,19584,22494,0,4895,5622,0,0.15,0.15,0,None,0,0,0,0,0,1,1,0,0,0.92,0.92,1,10,0,0,1,battery_mid,0.95,NE,0 diff --git a/Example_Systems/ProprietarySolver/Generators_variability.csv b/Example_Systems/ProprietarySolver/Generators_variability.csv new file mode 100644 index 0000000000..b2d9669ee8 --- /dev/null +++ b/Example_Systems/ProprietarySolver/Generators_variability.csv @@ -0,0 +1,25 @@ +Time_Index,solar_pv,onshore_wind +1,0,0.889717042 +2,0,0.877715468 +3,0,0.903424203 +4,0,0.895153165 +5,0,0.757258117 +6,0,0.630928695 +7,0,0.557177782 +8,0,0.6072492 +9,0.1779,0.423417866 +10,0.429,0.007470775 +11,0.5748,0.002535942 +12,0.6484,0.002153709 +13,0.6208,0.00445132 +14,0.596,0.007711587 +15,0.5013,0.100848213 +16,0.3311,0.201802149 +17,0.0642,0.141933054 +18,0,0.567022562 +19,0,0.946024895 +20,0,0.923394203 +21,0,0.953386247 +22,0,0.929205418 +23,0,0.849528909 +24,0,0.665570974 diff --git a/Example_Systems/ProprietarySolver/Maximum_capacity_requirement.csv b/Example_Systems/ProprietarySolver/Maximum_capacity_requirement.csv new file mode 100644 index 0000000000..ddf55ebace --- /dev/null +++ b/Example_Systems/ProprietarySolver/Maximum_capacity_requirement.csv @@ -0,0 +1,4 @@ +MaxCapReqConstraint,ConstraintDescription,Max_MW +1,PV,50000 +2,Wind,100000 +3,Batteries,60000 diff --git a/Example_Systems/ProprietarySolver/README.md b/Example_Systems/ProprietarySolver/README.md new file mode 100644 index 0000000000..89cd020325 --- /dev/null +++ b/Example_Systems/ProprietarySolver/README.md @@ -0,0 +1,5 @@ +# Proprietary solver example + +This demonstrates how to use a proprietary solver such as Gurobi or CPLEX, instead of the default solver HiGHS. + +See `Run.jl` and the `Solver` setting in `Settings/genx_settings.yml`. diff --git a/Example_Systems/ProprietarySolver/Run.jl b/Example_Systems/ProprietarySolver/Run.jl new file mode 100644 index 0000000000..793ad469fb --- /dev/null +++ b/Example_Systems/ProprietarySolver/Run.jl @@ -0,0 +1,5 @@ +using GenX, Gurobi + +optimizer = Gurobi.Optimizer + +run_genx_case!(dirname(@__FILE__),optimizer) diff --git a/Example_Systems/ProprietarySolver/Settings/cplex_settings.yml b/Example_Systems/ProprietarySolver/Settings/cplex_settings.yml new file mode 100644 index 0000000000..8d37873eef --- /dev/null +++ b/Example_Systems/ProprietarySolver/Settings/cplex_settings.yml @@ -0,0 +1,10 @@ +# CPLEX Solver Parameters +Feasib_Tol: 1.0e-05 # Constraint (primal) feasibility tolerances. +Optimal_Tol: 1e-5 # Dual feasibility tolerances. +Pre_Solve: 1 # Controls presolve level. +TimeLimit: 110000 # Limits total time solver. +MIPGap: 1e-3 # Relative (p.u. of optimal) mixed integer optimality tolerance for MIP problems (ignored otherwise). +Method: 2 # Algorithm used to solve continuous models (including MIP root relaxation). +BarConvTol: 1.0e-08 # Barrier convergence tolerance (determines when barrier terminates). +NumericFocus: 0 # Numerical precision emphasis. +SolutionType: 2 # Solution type for LP or QP. diff --git a/Example_Systems/ProprietarySolver/Settings/genx_settings.yml b/Example_Systems/ProprietarySolver/Settings/genx_settings.yml new file mode 100644 index 0000000000..d997679749 --- /dev/null +++ b/Example_Systems/ProprietarySolver/Settings/genx_settings.yml @@ -0,0 +1,98 @@ +## Model settings +# -------------- + +# Number of segments used in piecewise linear approximation of transmission losses; +# 1 = linear +# >2 = piecewise quadratic +Trans_Loss_Segments: 1 + +# Unit committment of thermal power plants; +# 0 = not active +# 1 = active using integer clustering +# 2 = active using linearized clustering +UCommit: 2 + +## Policy settings +# --------------- + +# Regulation (primary) and operating (secondary) reserves +# 0 = not active +# 1 = active systemwide +# Reserves: 0 + +# Minimum qualifying renewables penetration +# 0 = not active +# 1 = active systemwide +# EnergyShareRequirement: 0 + +# Number of capacity reserve margin constraints +# 0 = not active +# 1 = active systemwide +CapacityReserveMargin: 1 + +# CO2 emissions cap +# 0 = not active (no CO2 emission limit) +# 1 = mass-based emission limit constraint +# 2 = demand + rate-based emission limit constraint +# 3 = generation + rate-based emission limit constraint +CO2Cap: 2 + +# Let lost energy be accounted for in Energy Share Requirement and CO2 constraints +# 0 = not active (DO NOT account for energy lost); +# 1 = active systemwide (DO account for energy lost) +StorageLosses: 1 + +# Activate minimum technology carveout constraints +# 0 = not active +# 1 = active +# MinCapReq: 0 + +# Activate maximum technology limits +# 0 = not active +# 1 = active +MaxCapReq: 1 +# +# Transmission network expansion +# 0 = not active +# 1 = active systemwide +# NetworkExpansion: 0 + +# Hydrogen electrolyzer hourly supply matching required? +# 0 = no +# 1 = yes +# HydrogenHourlyMatching: 0 + +## Solution settings +# ---------------- + +# Internally scale demand, capacity and power variables in GW rather than MW. +# 0 = not active +# 1 = active systemwide +ParameterScale: 1 + +# Time domain reduce (i.e. cluster) inputs based on demand, resource availability profiles, and fuel prices; +# 0 = not active (use input data as provided) +# 1 = active (cluster input data, or use data that has already been clustered) +# TimeDomainReduction: 0 + +# Directory where results from time domain reduction will be saved. +# If results already exist, these will be used without running time domain reduction script again. +# TimeDomainReductionFolder: "TDR_Results" + +## Output settings +# ---------------- + +# Write shadow prices of LP or relaxed MILP +# 0 = not active +# 1 = active +WriteShadowPrices: 1 + +# Overwrite existing results in output folder or create a new one; +# 0 = create new folder +# 1 = overwrite existing results +# OverwriteResults: 0 + +# Write the model formulation as an output; +# 0 = active +# 1 = not active +# PrintModel: 0 diff --git a/Example_Systems/ProprietarySolver/Settings/gurobi_settings.yml b/Example_Systems/ProprietarySolver/Settings/gurobi_settings.yml new file mode 100644 index 0000000000..0aa53a56d3 --- /dev/null +++ b/Example_Systems/ProprietarySolver/Settings/gurobi_settings.yml @@ -0,0 +1,15 @@ +# Gurobi Solver Parameters +# Common solver settings +Feasib_Tol: 1.0e-05 # Constraint (primal) feasibility tolerances. +Optimal_Tol: 1e-5 # Dual feasibility tolerances. +TimeLimit: 110000 # Limits total time solver. +Pre_Solve: 1 # Controls presolve level. +Method: 2 # Algorithm used to solve continuous models (including MIP root relaxation). + +#Gurobi-specific solver settings +MIPGap: 1e-3 # Relative (p.u. of optimal) mixed integer optimality tolerance for MIP problems (ignored otherwise). +BarConvTol: 1.0e-08 # Barrier convergence tolerance (determines when barrier terminates). +NumericFocus: 0 # Numerical precision emphasis. +Crossover: 0 # Barrier crossver strategy. +PreDual: 0 # Decides whether presolve should pass the primal or dual linear programming problem to the LP optimization algorithm. +AggFill: 10 # Allowed fill during presolve aggregation. diff --git a/Example_Systems/ProprietarySolver/Settings/highs_settings.yml b/Example_Systems/ProprietarySolver/Settings/highs_settings.yml new file mode 100644 index 0000000000..e244a0b4cf --- /dev/null +++ b/Example_Systems/ProprietarySolver/Settings/highs_settings.yml @@ -0,0 +1,13 @@ +# HiGHS Solver Parameters +# Common solver settings +Feasib_Tol: 1.0e-05 # Primal feasibility tolerance # [type: double, advanced: false, range: [1e-10, inf], default: 1e-07] +Optimal_Tol: 1.0e-05 # Dual feasibility tolerance # [type: double, advanced: false, range: [1e-10, inf], default: 1e-07] +TimeLimit: 1.0e23 # Time limit # [type: double, advanced: false, range: [0, inf], default: inf] +Pre_Solve: choose # Presolve option: "off", "choose" or "on" # [type: string, advanced: false, default: "choose"] +Method: choose #HiGHS-specific solver settings # Solver option: "simplex", "choose" or "ipm" # [type: string, advanced: false, default: "choose"] + +#highs-specific solver settings + +# run the crossover routine for ipx +# [type: string, advanced: "on", range: {"off", "on"}, default: "off"] +run_crossover: "on" diff --git a/Example_Systems/RealSystemExample/ISONE_Singlezone/Settings/genx_settings.yml b/Example_Systems/RealSystemExample/ISONE_Singlezone/Settings/genx_settings.yml index b1d5794bf1..044864cf44 100644 --- a/Example_Systems/RealSystemExample/ISONE_Singlezone/Settings/genx_settings.yml +++ b/Example_Systems/RealSystemExample/ISONE_Singlezone/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 1 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 1 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS #Windows users, please make sure to install SCIP solver if using SCIP here; # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/RealSystemExample/ISONE_Trizone/Settings/genx_settings.yml b/Example_Systems/RealSystemExample/ISONE_Trizone/Settings/genx_settings.yml index 941e0cfa93..5fd394e64e 100644 --- a/Example_Systems/RealSystemExample/ISONE_Trizone/Settings/genx_settings.yml +++ b/Example_Systems/RealSystemExample/ISONE_Trizone/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 1 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 1 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS #Windows users, please make sure to install SCIP solver if using SCIP here; # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/RealSystemExample/ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml b/Example_Systems/RealSystemExample/ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml index 35d76b1ae1..a4c29f8a01 100644 --- a/Example_Systems/RealSystemExample/ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml +++ b/Example_Systems/RealSystemExample/ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 1 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 1 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 0 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/RealSystemExample/ISONE_Trizone_MultiStage/Settings/genx_settings.yml b/Example_Systems/RealSystemExample/ISONE_Trizone_MultiStage/Settings/genx_settings.yml index 7da769a17b..6972337a02 100644 --- a/Example_Systems/RealSystemExample/ISONE_Trizone_MultiStage/Settings/genx_settings.yml +++ b/Example_Systems/RealSystemExample/ISONE_Trizone_MultiStage/Settings/genx_settings.yml @@ -10,7 +10,6 @@ CO2Cap: 0 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, CLPs ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/RealSystemExample/MGA_ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml b/Example_Systems/RealSystemExample/MGA_ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml index 7f7197e051..88b4fe9e9f 100644 --- a/Example_Systems/RealSystemExample/MGA_ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml +++ b/Example_Systems/RealSystemExample/MGA_ISONE_Trizone_FullTimeseries/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 1 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 1 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 0 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/RetrofitExample/RetrofitExample_MultiStage/Settings/genx_settings.yml b/Example_Systems/RetrofitExample/RetrofitExample_MultiStage/Settings/genx_settings.yml index 3e16bc8201..28e19171a1 100644 --- a/Example_Systems/RetrofitExample/RetrofitExample_MultiStage/Settings/genx_settings.yml +++ b/Example_Systems/RetrofitExample/RetrofitExample_MultiStage/Settings/genx_settings.yml @@ -10,7 +10,6 @@ CO2Cap: 2 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: Gurobi # Available solvers: Gurobi, CPLEX, Clp, Cbc ParameterScale: 0 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/SmallNewEngland/OneZone/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/OneZone/Settings/genx_settings.yml index 3fe33ccd2a..fc1d6bf582 100644 --- a/Example_Systems/SmallNewEngland/OneZone/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/OneZone/Settings/genx_settings.yml @@ -9,8 +9,7 @@ CO2Cap: 2 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 1 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 1 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, Clps -ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide +ParameterScale: 1 # Turn on parameter scaling wherein load, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering TimeDomainReductionFolder: "TDR_Results" # Directory name where results from time domain reduction will be saved. If results already exist here, these will be used without running time domain reduction script again. diff --git a/Example_Systems/SmallNewEngland/OneZone_3VREBin/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/OneZone_3VREBin/Settings/genx_settings.yml index 8bccf3b090..c7577b5510 100644 --- a/Example_Systems/SmallNewEngland/OneZone_3VREBin/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/OneZone_3VREBin/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 2 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/SmallNewEngland/OneZone_MultiStage/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/OneZone_MultiStage/Settings/genx_settings.yml index 4f70417ffb..541e88e3c1 100644 --- a/Example_Systems/SmallNewEngland/OneZone_MultiStage/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/OneZone_MultiStage/Settings/genx_settings.yml @@ -10,7 +10,6 @@ CO2Cap: 2 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, Clp, Cbc ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/SmallNewEngland/Simple_Test_Case/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/Simple_Test_Case/Settings/genx_settings.yml index 704cea0516..8c42defa08 100644 --- a/Example_Systems/SmallNewEngland/Simple_Test_Case/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/Simple_Test_Case/Settings/genx_settings.yml @@ -1,4 +1,3 @@ StorageLosses: 0 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) -Solver: HiGHS #Windows users, please make sure to install SCIP solver if using SCIP here; Let us know of bugs # Available solvers: Gurobi, CPLEX, CLP, SCIP UCommit: 0 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering MethodofMorris: 0 diff --git a/Example_Systems/SmallNewEngland/Test_Down_Time/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/Test_Down_Time/Settings/genx_settings.yml index bf6da5b1ee..69a819478e 100644 --- a/Example_Systems/SmallNewEngland/Test_Down_Time/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/Test_Down_Time/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 0 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 0 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS #Windows users, please make sure to install SCIP solver if using SCIP here; Let us know of bugs # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 0 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 1 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/SmallNewEngland/Test_Up_Time/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/Test_Up_Time/Settings/genx_settings.yml index bf6da5b1ee..69a819478e 100644 --- a/Example_Systems/SmallNewEngland/Test_Up_Time/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/Test_Up_Time/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 0 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 0 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS #Windows users, please make sure to install SCIP solver if using SCIP here; Let us know of bugs # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 0 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 1 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/SmallNewEngland/ThreeZones/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/ThreeZones/Settings/genx_settings.yml index 5b629e4cc8..4536e68897 100644 --- a/Example_Systems/SmallNewEngland/ThreeZones/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/ThreeZones/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 2 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 1 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/SmallNewEngland/ThreeZones_MultiStage/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/ThreeZones_MultiStage/Settings/genx_settings.yml index 7cf6848ca9..b4641ca2a3 100644 --- a/Example_Systems/SmallNewEngland/ThreeZones_MultiStage/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/ThreeZones_MultiStage/Settings/genx_settings.yml @@ -10,7 +10,6 @@ CO2Cap: 2 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: HiGHS # Available solvers: Gurobi, CPLEX, CLP, Cbc ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 0 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/SmallNewEngland/ThreeZones_Slack_Variables_Example/Settings/genx_settings.yml b/Example_Systems/SmallNewEngland/ThreeZones_Slack_Variables_Example/Settings/genx_settings.yml index 6d79af4c98..68c2b0b382 100644 --- a/Example_Systems/SmallNewEngland/ThreeZones_Slack_Variables_Example/Settings/genx_settings.yml +++ b/Example_Systems/SmallNewEngland/ThreeZones_Slack_Variables_Example/Settings/genx_settings.yml @@ -9,7 +9,6 @@ CO2Cap: 2 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass- StorageLosses: 1 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost) MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active -Solver: Gurobi # Available solvers: Gurobi, CPLEX, CLP, SCIP ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering diff --git a/Example_Systems/VREStor_Example/Settings/genx_settings.yml b/Example_Systems/VREStor_Example/Settings/genx_settings.yml index 704043c8e8..25289e4c53 100644 --- a/Example_Systems/VREStor_Example/Settings/genx_settings.yml +++ b/Example_Systems/VREStor_Example/Settings/genx_settings.yml @@ -8,7 +8,6 @@ TimeDomainReduction: 0 Trans_Loss_Segments: 1 CapacityReserveMargin: 1 ModelingtoGenerateAlternativeSlack: 0.1 -Solver: "HiGHS" MethodofMorris: 0 Reserves: 0 StorageLosses: 1 diff --git a/Project.toml b/Project.toml index 421c43cc01..17a2404f8c 100644 --- a/Project.toml +++ b/Project.toml @@ -5,8 +5,6 @@ version = "0.3.6" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" -Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76" -Clp = "e2554f3b-3117-50c0-817c-e040a3ddf72d" Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" @@ -25,8 +23,6 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" [compat] CSV = "0.10.4" -Cbc = "1.0.1" -Clp = "1.0.1" Clustering = "0.14.2, 0.15" Combinatorics = "1.0.2" DataFrames = "1.3.4" @@ -42,9 +38,8 @@ YAML = "0.4.7" julia = "1" [extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" - +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Test", "Logging"] diff --git a/README.md b/README.md index 3a27fc657a..5e63622ed0 100644 --- a/README.md +++ b/README.md @@ -148,21 +148,29 @@ If your needs are more complex, it is possible to use a customized run script in If you want to use the commercial solvers Gurobi or CPLEX: 1. Make sure you have a valid license and the actual solvers for either of Gurobi or CPLEX installed on your machine -2. Add Gurobi or CPLEX to the Julia Project. +2. Add Gurobi or CPLEX to your Julia installation ``` -> julia --project=/home/youruser/GenX +> julia julia> -(GenX) pkg> add Gurobi +(@v1.9) pkg> add Gurobi -or- -(GenX) pkg> add CPLEX +(@v1.9) pkg> add CPLEX ``` -3. At the beginning of the `GenX/src/GenX.jl` file, uncomment `using Gurobi` and/or `using CPLEX`. -4. Set the appropriate solver in the `genx_settings.yml` file of your case +3. Set the appropriate solver in the `genx_settings.yml` file of your case +4. In the `Run.jl` file for your case, add `using Gurobi` or `using CPLEX` to the dependencies at the top, and specify the optimizer object as the second argument to `run_genx_case!`. Below is an example `Run.jl` file for a case using the Gurobi optimizer: -Note that if you have not already installed the required Julia packages or you do not have a valid Gurobi license on your host machine, you will receive an error message and Run.jl will not run to completion. +``` +using GenX, Gurobi + +optimizer = Gurobi.Optimizer + +run_genx_case!(dirname(@__FILE__),optimizer) +``` + +A full example case with Gurobi as an optimizer is given in `Example_Systems/SmallNewEngland/OneZone_Gurobi`. Note that if you have not already installed the required Julia packages or you do not have a valid Gurobi/CPLEX license on your host machine, you will receive an error message and Run.jl will not run to completion. ## Running Modeling to Generate Alternatives with GenX diff --git a/docs/src/data_documentation.md b/docs/src/data_documentation.md index 3754482288..1931325814 100644 --- a/docs/src/data_documentation.md +++ b/docs/src/data_documentation.md @@ -51,7 +51,6 @@ Note that all settings parameters are case sensitive. || 1 = if one or more maximum technology capacity constraints are specified| || 0 = otherwise| |**Solution strategy and outputs**|| -|Solver | Specifies the solver name (This is not case sensitive i.e. CPLEX/cplex, Gurobi/gurobi, Clp/clp indicate the same solvers, respectively). | |ParameterScale | Flag to turn on parameter scaling wherein demand, capacity and power variables defined in GW rather than MW. This flag aides in improving the computational performance of the model. | ||1 = Scaling is activated. | ||0 = Scaling is not activated. | diff --git a/src/GenX.jl b/src/GenX.jl index 9e828c1e7a..d9ed8e70a3 100644 --- a/src/GenX.jl +++ b/src/GenX.jl @@ -32,20 +32,10 @@ using Dates using Clustering using Distances using Combinatorics - using Random using RecursiveArrayTools using Statistics - -# Uncomment if Gurobi or CPLEX active license and installations are there and the user intends to use either of them -#using CPLEX -#using Gurobi -#using CPLEX -#using MOI -#using SCIP using HiGHS -using Clp -using Cbc # Global scaling factor used when ParameterScale is on to shift values from MW to GW # DO NOT CHANGE THIS (Unless you do so very carefully) diff --git a/src/case_runners/case_runner.jl b/src/case_runners/case_runner.jl index a1ecc05a29..6c7eb593e6 100644 --- a/src/case_runners/case_runner.jl +++ b/src/case_runners/case_runner.jl @@ -13,14 +13,14 @@ end @doc raw"""Run the GenX in the given folder case - folder for the case """ -function run_genx_case!(case::AbstractString) +function run_genx_case!(case::AbstractString, optimizer::Any=HiGHS.Optimizer) genx_settings = get_settings_path(case, "genx_settings.yml") #Settings YAML file path mysetup = configure_settings(genx_settings) # mysetup dictionary stores settings and GenX-specific parameters if mysetup["MultiStage"] == 0 - run_genx_case_simple!(case, mysetup) + run_genx_case_simple!(case, mysetup, optimizer) else - run_genx_case_multistage!(case, mysetup) + run_genx_case_multistage!(case, mysetup, optimizer) end end @@ -31,7 +31,7 @@ function time_domain_reduced_files_exist(tdrpath) return (tdr_demand && tdr_genvar && tdr_fuels) end -function run_genx_case_simple!(case::AbstractString, mysetup::Dict) +function run_genx_case_simple!(case::AbstractString, mysetup::Dict, optimizer::Any) settings_path = get_settings_path(case) ### Cluster time series inputs if necessary and if specified by the user @@ -49,7 +49,7 @@ function run_genx_case_simple!(case::AbstractString, mysetup::Dict) ### Configure solver println("Configuring Solver") - OPTIMIZER = configure_solver(mysetup["Solver"], settings_path) + OPTIMIZER = configure_solver(settings_path, optimizer) #### Running a case @@ -84,7 +84,7 @@ function run_genx_case_simple!(case::AbstractString, mysetup::Dict) end -function run_genx_case_multistage!(case::AbstractString, mysetup::Dict) +function run_genx_case_multistage!(case::AbstractString, mysetup::Dict, optimizer::Any) settings_path = get_settings_path(case) multistage_settings = get_settings_path(case, "multi_stage_settings.yml") # Multi stage settings YAML file path mysetup["MultiStageSettingsDict"] = YAML.load(open(multistage_settings)) @@ -114,7 +114,7 @@ function run_genx_case_multistage!(case::AbstractString, mysetup::Dict) ### Configure solver println("Configuring Solver") - OPTIMIZER = configure_solver(mysetup["Solver"], settings_path) + OPTIMIZER = configure_solver(settings_path, optimizer) model_dict=Dict() inputs_dict=Dict() diff --git a/src/configure_settings/configure_settings.jl b/src/configure_settings/configure_settings.jl index d95e3f390f..a7b943416e 100644 --- a/src/configure_settings/configure_settings.jl +++ b/src/configure_settings/configure_settings.jl @@ -11,7 +11,6 @@ function default_settings() "StorageLosses" => 1, "MinCapReq" => 0, "MaxCapReq" => 0, - "Solver" => "HiGHS", "ParameterScale" => 0, "WriteShadowPrices" => 0, "UCommit" => 0, diff --git a/src/configure_solver/configure_cbc.jl b/src/configure_solver/configure_cbc.jl index 1865f8d4d6..cf9de8a544 100644 --- a/src/configure_solver/configure_cbc.jl +++ b/src/configure_solver/configure_cbc.jl @@ -16,7 +16,7 @@ The Cbc optimizer instance is configured with the following default parameters i - threads = 1 """ -function configure_cbc(solver_settings_path::String) +function configure_cbc(solver_settings_path::String, optimizer::Any) solver_settings = YAML.load(open(solver_settings_path)) solver_settings = convert(Dict{String, Any}, solver_settings) @@ -38,5 +38,5 @@ function configure_cbc(solver_settings_path::String) attributes = rename_keys(attributes, key_replacement) attributes::Dict{String, Any} - return optimizer_with_attributes(Cbc.Optimizer, attributes...) + return optimizer_with_attributes(optimizer, attributes...) end diff --git a/src/configure_solver/configure_clp.jl b/src/configure_solver/configure_clp.jl index ddb0fa110d..7df7bff5bd 100644 --- a/src/configure_solver/configure_clp.jl +++ b/src/configure_solver/configure_clp.jl @@ -20,7 +20,7 @@ The Clp optimizer instance is configured with the following default parameters i - Perturbation = 100 (switch on perturbation (50), automatic (100), don't try perturbing (102)) """ -function configure_clp(solver_settings_path::String) +function configure_clp(solver_settings_path::String, optimizer::Any) solver_settings = YAML.load(open(solver_settings_path)) solver_settings = convert(Dict{String, Any}, solver_settings) @@ -53,5 +53,5 @@ function configure_clp(solver_settings_path::String) attributes["DualTolerance"] = attributes["PrimalTolerance"] attributes::Dict{String, Any} - return optimizer_with_attributes(Clp.Optimizer, attributes...) + return optimizer_with_attributes(optimizer, attributes...) end diff --git a/src/configure_solver/configure_cplex.jl b/src/configure_solver/configure_cplex.jl index 87d5e29a59..048e53bf4f 100644 --- a/src/configure_solver/configure_cplex.jl +++ b/src/configure_solver/configure_cplex.jl @@ -77,7 +77,7 @@ The optimizer instance is configured with the following default parameters if a Any other attributes in the settings file (which typically start with `CPX_PARAM_`) will also be passed to the solver. """ -function configure_cplex(solver_settings_path::String) +function configure_cplex(solver_settings_path::String, optimizer::Any) solver_settings = YAML.load(open(solver_settings_path)) solver_settings = convert(Dict{String, Any}, solver_settings) @@ -115,5 +115,5 @@ function configure_cplex(solver_settings_path::String) attributes = rename_keys(attributes, key_replacement) attributes::Dict{String, Any} - return optimizer_with_attributes(CPLEX.Optimizer, attributes...) + return optimizer_with_attributes(optimizer, attributes...) end diff --git a/src/configure_solver/configure_gurobi.jl b/src/configure_solver/configure_gurobi.jl index e0ab001341..2301306d3e 100644 --- a/src/configure_solver/configure_gurobi.jl +++ b/src/configure_solver/configure_gurobi.jl @@ -20,7 +20,7 @@ The Gurobi optimizer instance is configured with the following default parameter - NumericFocus = 0 (Numerical precision emphasis. See https://www.gurobi.com/documentation/8.1/refman/numericfocus.html) """ -function configure_gurobi(solver_settings_path::String) +function configure_gurobi(solver_settings_path::String, optimizer::Any) solver_settings = YAML.load(open(solver_settings_path)) solver_settings = convert(Dict{String, Any}, solver_settings) @@ -49,5 +49,5 @@ function configure_gurobi(solver_settings_path::String) attributes = rename_keys(attributes, key_replacement) attributes::Dict{String, Any} - return optimizer_with_attributes(Gurobi.Optimizer, attributes...) + return optimizer_with_attributes(optimizer, attributes...) end diff --git a/src/configure_solver/configure_highs.jl b/src/configure_solver/configure_highs.jl index b7ec56db5e..a8d7166bfe 100644 --- a/src/configure_solver/configure_highs.jl +++ b/src/configure_solver/configure_highs.jl @@ -331,7 +331,7 @@ The HiGHS optimizer instance is configured with the following default parameters """ -function configure_highs(solver_settings_path::String) +function configure_highs(solver_settings_path::String, optimizer::Any) solver_settings = YAML.load(open(solver_settings_path)) solver_settings = convert(Dict{String, Any}, solver_settings) @@ -434,5 +434,5 @@ function configure_highs(solver_settings_path::String) attributes = rename_keys(attributes, key_replacement) attributes::Dict{String, Any} - return optimizer_with_attributes(HiGHS.Optimizer, attributes...) + return optimizer_with_attributes(optimizer, attributes...) end diff --git a/src/configure_solver/configure_scip.jl b/src/configure_solver/configure_scip.jl index b7f709447d..da77c80293 100644 --- a/src/configure_solver/configure_scip.jl +++ b/src/configure_solver/configure_scip.jl @@ -11,7 +11,7 @@ The SCIP optimizer instance is configured with the following default parameters - limitsgap = 0.05 """ -function configure_scip(solver_settings_path::String) +function configure_scip(solver_settings_path::String, optimizer::Any) solver_settings = YAML.load(open(solver_settings_path)) solver_settings = convert(Dict{String, Any}, solver_settings) @@ -28,5 +28,5 @@ function configure_scip(solver_settings_path::String) attributes = rename_keys(attributes, key_replacement) attributes::Dict{String, Any} - return optimizer_with_attributes(SCIP.Optimizer, attributes...) + return optimizer_with_attributes(optimizer, attributes...) end diff --git a/src/configure_solver/configure_solver.jl b/src/configure_solver/configure_solver.jl index c2cafd3f13..fa832c2dd3 100644 --- a/src/configure_solver/configure_solver.jl +++ b/src/configure_solver/configure_solver.jl @@ -1,5 +1,14 @@ @doc raw""" - configure_solver(solver::String, solver_settings_path::String) + infer_solver(optimizer::Any) +Return the name (`String`) of the solver to be used in the GenX.configure\_solver method according to the solver imported by the user. +""" +function infer_solver(optimizer::Any) + return lowercase(string(parentmodule(optimizer))) +end + + +@doc raw""" + configure_solver(solver_settings_path::String, optimizer::Any) This method returns a solver-specific MathOptInterface OptimizerWithAttributes optimizer instance to be used in the GenX.generate\_model() method. @@ -9,22 +18,20 @@ Currently supported solvers include: "Gurobi", "CPLEX", "Clp", "Cbc", or "SCIP" The "solver\_settings\_path" argument is a string which specifies the path to the directory that contains the settings YAML file for the specified solver. """ -function configure_solver(solver::String, solver_settings_path::String) - - solver = lowercase(solver) - - path = joinpath(solver_settings_path, solver*"_settings.yml") +function configure_solver(solver_settings_path::String, optimizer::Any) + solver_name = infer_solver(optimizer) + path = joinpath(solver_settings_path, solver_name * "_settings.yml") configure_functions = Dict( - "highs" => configure_highs, - "gurobi" => configure_gurobi, - "cplex" => configure_cplex, - "clp" => configure_clp, - "cbc" => configure_cbc, - "scip" => configure_scip, - ) - - return configure_functions[solver](path) + "highs" => configure_highs, + "gurobi" => configure_gurobi, + "cplex" => configure_cplex, + "clp" => configure_clp, + "cbc" => configure_cbc, + "scip" => configure_scip, + ) + + return configure_functions[solver_name](path, optimizer) end @doc raw"""