From fc26b4dcfc288f0b5c5ed6bbe9c0b9f42f392824 Mon Sep 17 00:00:00 2001 From: benherry Date: Tue, 11 Jun 2024 17:12:56 +0200 Subject: [PATCH 01/10] [feat]: exporting invest profiles either in invest_mix for all years (to be used by investDistrib discipline) or as var_array_mix at the poles (to be used by the design variables disc) --- .../investments/convex_combination_model.py | 2 +- .../investments_profile_builder_disc.py | 143 +++++++++++---- ...obian_investments_profile_builder_disc.pkl | Bin 521 -> 561 bytes ...stments_profile_builder_disc_all_years.pkl | Bin 0 -> 517 bytes ...n_investments_profile_builder_disc_mix.pkl | Bin 0 -> 595 bytes ...investments_profile_builder_disc_poles.pkl | Bin 0 -> 554 bytes .../l0_test_investments_profile_builder.py | 152 +++++++++++++--- ...st_gradient_investments_profile_builder.py | 168 +++++++++++++++--- 8 files changed, 374 insertions(+), 91 deletions(-) create mode 100644 energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl create mode 100644 energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_mix.pkl create mode 100644 energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl diff --git a/energy_models/core/investments/convex_combination_model.py b/energy_models/core/investments/convex_combination_model.py index cdebd740..d6071419 100644 --- a/energy_models/core/investments/convex_combination_model.py +++ b/energy_models/core/investments/convex_combination_model.py @@ -50,7 +50,7 @@ def compute_convex_combination(self): self.convex_combination_df = pd.DataFrame({ 'years': self.dataframes[0]['years'], - **dict(zip(self.dataframes[0].columns, convex_combination.T)) # demander à Antoine + **dict(zip(self.dataframes[0].columns, convex_combination.T)) }) def compute(self): diff --git a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py index 66a6ebe6..5781fe55 100644 --- a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py +++ b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py @@ -21,11 +21,13 @@ InstanciatedSeries, TwoAxesInstanciatedChart, ) +from sostrades_core.execution_engine.design_var.design_var import DesignVar from energy_models.core.investments.convex_combination_model import ( ConvexCombinationModel, ) from energy_models.glossaryenergy import GlossaryEnergy +import numpy as np class InvestmentsProfileBuilderDisc(SoSWrapp): @@ -42,10 +44,18 @@ class InvestmentsProfileBuilderDisc(SoSWrapp): 'icon': 'fas fa-coins fa-fw', 'version': '', } + DESIGN_VAR_DESCRIPTOR = DesignVar.DESIGN_VAR_DESCRIPTOR + ''' + The DESIGN_VAR_DESCRIPTOR is used by the design variables discipline. + If it is not an empty dictionnary and if it contains columns that are already in column_names, then + the corresponding invest profile for this column_name is exported at the years of the poles only. + The exported data is then to be used by the design variables discipline instead of the investment Distribution discipline + ''' DESC_IN = { 'n_profiles': {'type': 'int', 'unit': '-', 'user_level': 3}, - 'column_names': {'type': 'list', 'subtype_descriptor': {'list': 'string'}} + 'column_names': {'type': 'list', 'subtype_descriptor': {'list': 'string'}}, + DESIGN_VAR_DESCRIPTOR: {'type': 'dict', 'editable': True, 'structuring': True, 'user_level': 3}, } DESC_OUT = {} @@ -57,6 +67,11 @@ def setup_sos_disciplines(self): dynamic_inputs = {} dynamic_outputs = {} df_descriptor = None + column_names = None + n_profiles = None + self.columns_to_export_at_poles = None + self.columns_to_export_at_years = None + self.years_poles = None # list of years at the poles if 'n_profiles' in self.get_data_in(): n_profiles = self.get_sosdisc_inputs('n_profiles') @@ -64,6 +79,7 @@ def setup_sos_disciplines(self): for i in range(n_profiles): dynamic_inputs[f'coeff_{i}'] = {'type': 'float', 'unit': '-'} + if 'column_names' in self.get_data_in(): column_names = self.get_sosdisc_inputs('column_names') if column_names is not None and n_profiles is not None: @@ -75,13 +91,41 @@ def setup_sos_disciplines(self): "dataframe_descriptor": df_descriptor, } - if df_descriptor is not None: - dynamic_outputs[GlossaryEnergy.invest_mix] = { - "type": "dataframe", "unit": "G$", - "dataframe_descriptor": df_descriptor, - "namespace": "ns_invest", #same namespace as for invest_mix in discipline InvestmentDistribution - "visibility": "Shared", - } + if self.DESIGN_VAR_DESCRIPTOR in self.get_data_in(): + design_var_descriptor = self.get_sosdisc_inputs(self.DESIGN_VAR_DESCRIPTOR) + if column_names is not None: + self.columns_to_export_at_poles = [col for col in column_names if + col + '_array_mix' in design_var_descriptor.keys()] + self.columns_to_export_at_years = [col for col in column_names if col not in self.columns_to_export_at_poles] + if design_var_descriptor is not None and len(self.columns_to_export_at_poles) > 0: + dynamic_inputs['nb_poles'] = {'type': 'int', 'unit': '-', 'user_level': 3} + + + if df_descriptor is not None and self.columns_to_export_at_poles is not None: + # the output invest profile can be provided either for all the years or for some limited number of poles. + # In the second case, the profiles to consider are defined in DESIGN_VAR_DESCRIPTOR as they are provided + # to the design variables discipline + df_descriptor_years = df_descriptor.copy() + list(map(df_descriptor_years.pop, self.columns_to_export_at_poles)) + # should not add the invest mix if all the outputs are given at the poles + if len(df_descriptor_years.keys()) > 0: + dynamic_outputs[GlossaryEnergy.invest_mix] = { + "type": "dataframe", "unit": "G$", + "dataframe_descriptor": df_descriptor_years, + "namespace": "ns_invest", # same namespace as for invest_mix in discipline InvestmentDistribution + "visibility": "Shared", + } + for var in self.columns_to_export_at_poles: + df_descriptor_poles = {GlossaryEnergy.Years: ("int", [1900, GlossaryCore.YearEndDefault], False), + var: ("float", [0.0, 1e30], False) + } + dynamic_outputs[f'{var}_array_mix'] = { + "type": "dataframe", "unit": "G$", + "dataframe_descriptor": df_descriptor_poles, + "namespace": "ns_invest", + # same namespace as for invest_mix in discipline InvestmentDistribution + "visibility": "Shared", + } self.add_inputs(dynamic_inputs) self.add_outputs(dynamic_outputs) @@ -91,29 +135,50 @@ def run(self): # type: (...) -> None inputs = self.get_sosdisc_inputs() n_profiles = inputs['n_profiles'] + self.model.store_inputs( positive_coefficients={f'coeff_{i}': inputs[f'coeff_{i}'] for i in range(n_profiles)}, - dataframes=[inputs[f'df_{i}'] for i in range(n_profiles)] + dataframes=[inputs[f'df_{i}'] for i in range(n_profiles)], ) self.model.compute() - - outputs = { - GlossaryEnergy.invest_mix: self.model.convex_combination_df - } - - self.store_sos_outputs_values(outputs) + convex_combination_df = self.model.convex_combination_df + # some data are stored in invest_mix, others in _array_mix + if len(self.columns_to_export_at_years) > 0: + outputs = { + GlossaryEnergy.invest_mix: self.model.convex_combination_df[[GlossaryEnergy.Years] + self.columns_to_export_at_years] + } + self.store_sos_outputs_values(outputs) + + if len(self.columns_to_export_at_poles) > 0: + df = inputs['df_0'] + years = df[GlossaryEnergy.Years] # all profiles should have the same years + nb_poles = inputs['nb_poles'] + self.years_poles = np.linspace(years.values.min(), years.values.max(), nb_poles, dtype='int') # to avoid interpolation, accept non-even step size between the poles + self.poles_index = list(df[df[GlossaryEnergy.Years].isin(self.years_poles)].index) + for col in self.columns_to_export_at_poles: # extract data at the poles + df = self.model.convex_combination_df[[GlossaryEnergy.Years] + [col]] + outputs = {col + '_array_mix' : df[df.index.isin(self.poles_index)]} + self.store_sos_outputs_values(outputs) def compute_sos_jacobian(self): dict_in = self.get_sosdisc_inputs() column_names_list = dict_in['column_names'] n_profiles = dict_in['n_profiles'] - for col_name in column_names_list: - for i in range(n_profiles): + for i in range(n_profiles): + for col_name in column_names_list: derivative = self.model.d_convex_combination_d_coeff_in(col_name, f'coeff_{i}') - self.set_partial_derivative_for_other_types( - (GlossaryEnergy.invest_mix, col_name), - (f'coeff_{i}',), derivative.reshape((len(derivative), 1)) + # some data are stored in invest_mix, others in _array_mix + if col_name in self.columns_to_export_at_years: + self.set_partial_derivative_for_other_types( + (GlossaryEnergy.invest_mix, col_name), + (f'coeff_{i}',), derivative.reshape((len(derivative), 1)) + ) + else: #col_name in self.columns_to_export_at_poles: + derivative_at_poles = derivative[self.poles_index].reshape((len(self.poles_index), 1)) #extract gradient at the poles only + self.set_partial_derivative_for_other_types( + (col_name + '_array_mix', col_name), + (f'coeff_{i}',), derivative_at_poles ) def get_chart_filter_list(self): @@ -133,25 +198,23 @@ def get_post_processing_list(self, filters=None): if chart_filter.filter_key == 'charts_invest': charts = chart_filter.selected_values - invest_profile = self.get_sosdisc_outputs(GlossaryEnergy.invest_mix) - years = list(invest_profile['years'].values) + n_profiles = self.get_sosdisc_inputs('n_profiles') + years = list(self.get_sosdisc_inputs('df_0')[GlossaryEnergy.Years].values) column_names = self.get_sosdisc_inputs('column_names') - graph_name = "Output profile invest" - graph = TwoAxesInstanciatedChart(GlossaryEnergy.Years, 'Invest [G$]', - chart_name=graph_name) + graph_years = TwoAxesInstanciatedChart(GlossaryEnergy.Years, f'Invest {GlossaryEnergy.invest_mix} [G$]', + chart_name="Output profile invest") + graph_poles = TwoAxesInstanciatedChart(GlossaryEnergy.Years, f'Invest array_mix [G$]', + chart_name="Output profile invest at the poles") - columns_to_include_in_output_graph = [column for column in column_names if column != GlossaryEnergy.Years] for idx, column in enumerate(column_names): chart_name = f"Investments in {column}" # we want to plot the generic invest profiles of each column on 1 graph, not 1 graph for each of the n_profile - if idx < len(columns_to_include_in_output_graph): + if idx < len(column_names): chart = TwoAxesInstanciatedChart(GlossaryEnergy.Years, 'Invest [G$]', chart_name=chart_name) - - n_profiles = self.get_sosdisc_inputs('n_profiles') for i in range(n_profiles): input_series_values = list(self.get_sosdisc_inputs(f'df_{i}')[column].values) input_serie_obj = InstanciatedSeries(years, input_series_values, f'df_{i}', "lines") @@ -159,11 +222,23 @@ def get_post_processing_list(self, filters=None): instanciated_charts.append(chart) - if column in columns_to_include_in_output_graph: - series_values = list(invest_profile[column].values) + if column in self.columns_to_export_at_years: + invest_profile_years = self.get_sosdisc_outputs(GlossaryEnergy.invest_mix) + series_values = list(invest_profile_years[column].values) serie_obj = InstanciatedSeries(years, series_values, column, "lines") - graph.add_series(serie_obj) - - instanciated_charts.append(graph) + graph_years.add_series(serie_obj) + elif column in self.columns_to_export_at_poles: + invest_profile_poles = self.get_sosdisc_outputs(column + '_array_mix') + series_values = list(invest_profile_poles[column].values) + serie_obj = InstanciatedSeries(list(self.years_poles), series_values, column + '_array_mix', display_type="scatter", + marker_symbol='circle', + #marker=dict(color='LightSkyBlue', size=20, line=dict(color='MediumPurple', width=2)) + ) + graph_poles.add_series(serie_obj) + + if len(self.columns_to_export_at_years) > 0: + instanciated_charts.append(graph_years) + if len(self.columns_to_export_at_poles) > 0: + instanciated_charts.append(graph_poles) return instanciated_charts \ No newline at end of file diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc.pkl index 92c8b1fd148b05f3f1d93ffba645403c6e15a67a..28fcb121223ee8b091dd756acdcb6a579a7025ad 100644 GIT binary patch literal 561 zcmZ>Y%CIzaj8qGb-0x?9k%6)6|NsAMtUOPaRz7|8cZ$>g{QJKSf4P4sp&@{Co)`5TWeseWV9!&$a~XEkA|X%pcr%48|gt+PA-gVUTqd`FHBD} z2~dB%n`iUolX9%hhp(;WyWP4jyn1q^VMSl&Z4>XC-ka^_l^p3_l$`s+Y|FuKul7!R zeD|q%WmbvfGv)-zs4W4pZ#VRP{{5wS`IReG{C_?=J^u4}mZV*B+F<(b22WtNKlE(Z!YL4|6|QxBbR3^PY`Qj8uhByj#gMt9ka- zrTO8kU$@#l?_#a7K6)f2{NRThchV;P+%bLiah}j+t`T>(KE7eg%V}z(wd%Lnro;?` z{h<<0e~tB}7$#lp?`TUg)Bm8gVA*NaWtYDc%wCboro88=`FUmAtpSz_*FLY@e0lYc zpsm}d>iMvRUjBN@;+z}f+q~Nu{}--*w|z^WmetK$w?j0!g0DAmD450Qf11ql@3GYH z+U*rlo1X1oz2o=Y@0mBsqFJ8^7QT`0OZ;|r=lOY@C%d{7`h^>w*-w679{cR}fpY%CIzaj8qGbv}6AGi-FPT|NsAgs@NiufB5YAJBQ(a{{5olH+hlV6E1LcIq@vw zkYG_bz_?vhi;scXfx(D@f#F2P1t19ojH+5yj>~!%dzf6fa6w86Bzb{xvD-{3wpk3k zSd@#poLtHuIB~1AX9LG&wHa;~E+r_lWEd{FaLX;zk$p+Pl(y|wB@g#qfXpS{vlS)2gay&rOal-_kOS0;>460Z0 z9=q#!*MHB&PE{|TiwET`ZqzZ=-U^ahtWo;D(@;JlfJ2ArMR8lA(nSejlVn~FM>h8p zOTAv&x_sn)-TK&SLo2uaLeZ21GdeS7Y3`C!c+b-5Q2p>tg5;;m2aNOcg{mr2d^9{w zj!!9zuIV(0<0^1;=J>8rP-30OrPjxJe5KeXfd?~rn=%Cz-I5BoUuAhw){zl(G@0?3 zgC^IuM=}rXc?w&vJi!J_5C3{-v7sh^N{tH>X3R@)RPbv&pYiMatKhEBIHXPQHIR#oQx=)&4=;p$~F~&!s=UmNPsickr2%vaQDRzKRQSg3rB6 zrvH6$!EefR9zzw+DpU70RqYztmvUDenDC7^as9jA#5I=ASA0A#v?l-4d(u^~P@#tX G@fQGJdefr- diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl new file mode 100644 index 0000000000000000000000000000000000000000..453452878a88b90b6ed625c628292d697c230d35 GIT binary patch literal 517 zcmV+g0{ZGw!F8~2M|NsBI+K*^mepJaF6ac?x-)4L6UO-GZI6#OK zQX)=75CXsfyrBprq@kgs2mmx>Xfyx=Km$Rb25Mv)25A5^$Q%F$fB<9w00EHEpa1{> z0000700E!?82|tPWHe|100000004@niIpBi^*>Y_)Qth?fCh$|G&Z1VpvjN}O&*?< z4Lu>~nm50KalPw*OQ5tB*l-)~nO)6GN6179X z#tkv_WRi9q@U{_79U+*MbAvvB;@jCBO;3?{Yo;EMaAMZEosOHG0gBLEO;pDnZx$eK zf@IMd!^*@svZnBGuMG*ll{zpb>fvFgo+ZJqJ>jG%NRGXvoRG0*gsx6A*;3~`P#7kW z2G%1LbJxy}_5zG6C-0d2!4z>;!GW!fX007Vc z&<2124H$p{pa1{>0iXnGq-mN0Vi-&a!8Fm4gun@eX@HC)01y}^ntq^)iKr>*s6SNp zrlFwpjExzj2AG2o83sTeNHjF`fN7?iM4;}SByPYPa0W7n8RRv-L+Pe>+CfcA<0ymm zV5D!mEXqw@Bo^x-+8u_G{BoM1>R3p;fh42N8*Z9yL1klOm!l2bhDgT)<{FjFNt{0G zxNe*Ha!YloX4M3OLV8M1I#fa7be?$CA0wVNJH_5go#1kS%L^b)0H{;AJ8nxdKljPt z4J{rpQSjEs$BOqIvl#3A?FNw286kQUJ?VWFud}qr0dFi^Nee-)zeT(S?=|t{1mRU@ z=NBy8f!fHL5}H{GKvNujjxLV@Yk@vuo%H{U1XMj&xq3JOt)S;qOcuMU&Z z^`B;tH9@@FQfn=LJGi{)32n7x#(=FsrzCZTqdoj1Y&0}C=0^z|8`;xQQWU0DA|Qxn zX@0p!gw2eL-LK>QY%CIzaj8qGb6ux^YiGi`a{{R1VUJi#-f8=z^l^e1^PW=Szz;FXkHxIn6k zgTbKfQs%PRK^6HkHC`OB6yRAt!M4e$T;5iwX(HFecjb~(X3x1Yqg7#sp5AIhPo`o+ zn~RSljK9r)eRnB;v*YE$>SGhjR6l+@XsL95hx~kdlN))_n#CcnnNPDFFj{d*<9?#d zxeaC2G3l0;A2a&5`xf35*|7Pom-zW3EA})T zkC7Dpf6g!HN#c}Cp*fM8k3?~{vHhDSu_toc9Y)oqr;a%<=UsL6O|aJcFEcE1UdQ)O zOSa;jzxzNz+Qisf1^TjVm(M(m$+lZAB7Zt);br#H`?101uIDZlKHxHwo3cwlHcFo@ zaMRzr*V8_;9%uY#emA9FakF>SCrgd5vhily<}poJ?y_CL#ZX#L?`ZO#9Jkn-^|!a( z%QnAt+ Date: Wed, 12 Jun 2024 17:14:55 +0200 Subject: [PATCH 02/10] [fix] techno_array_mix converted to array instead of dataframe --- .../investments_profile_builder_disc.py | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py index a71f2eb1..f684ec7f 100644 --- a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py +++ b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py @@ -57,7 +57,7 @@ class InvestmentsProfileBuilderDisc(SoSWrapp): DESC_IN = { 'n_profiles': {'type': 'int', 'unit': '-', 'user_level': 3}, 'column_names': {'type': 'list', 'subtype_descriptor': {'list': 'string'}}, - DESIGN_VAR_DESCRIPTOR: {'type': 'dict', 'editable': True, 'structuring': True, 'user_level': 3}, + DESIGN_VAR_DESCRIPTOR: {'type': 'dict', 'editable': True, 'structuring': True, 'user_level': 3, 'namespace': 'ns_invest'}, } DESC_OUT = {} @@ -110,7 +110,7 @@ def setup_sos_disciplines(self): df_descriptor_years = df_descriptor.copy() list(map(df_descriptor_years.pop, self.columns_to_export_at_poles)) # should not add the invest mix if all the outputs are given at the poles - if len(df_descriptor_years.keys()) > 0: + if len(self.columns_to_export_at_years) > 0: dynamic_outputs[GlossaryEnergy.invest_mix] = { "type": "dataframe", "unit": "G$", "dataframe_descriptor": df_descriptor_years, @@ -122,10 +122,11 @@ def setup_sos_disciplines(self): var: ("float", [0.0, 1e30], False) } dynamic_outputs[f'{var}_array_mix'] = { - "type": "dataframe", "unit": "G$", - "dataframe_descriptor": df_descriptor_poles, + "type": "array", + "unit": "G$", + #"dataframe_descriptor": df_descriptor_poles, "namespace": "ns_invest", - # same namespace as for invest_mix in discipline InvestmentDistribution + # same namespace as for design_var discipline inputs "visibility": "Shared", } @@ -160,7 +161,7 @@ def run(self): # type: (...) -> None self.poles_index = list(df[df[GlossaryEnergy.Years].isin(self.years_poles)].index) for col in self.columns_to_export_at_poles: # extract data at the poles df = self.model.convex_combination_df[[GlossaryEnergy.Years] + [col]] - outputs = {col + '_array_mix' : df[df.index.isin(self.poles_index)]} + outputs = {col + '_array_mix' : df[df.index.isin(self.poles_index)][col].values} self.store_sos_outputs_values(outputs) def compute_sos_jacobian(self): @@ -178,10 +179,7 @@ def compute_sos_jacobian(self): ) else: #col_name in self.columns_to_export_at_poles: derivative_at_poles = derivative[self.poles_index].reshape((len(self.poles_index), 1)) #extract gradient at the poles only - self.set_partial_derivative_for_other_types( - (col_name + '_array_mix', col_name), - (f'coeff_{i}',), derivative_at_poles - ) + self.set_partial_derivative(col_name + '_array_mix', f'coeff_{i}', derivative_at_poles) def get_chart_filter_list(self): chart_filters = [] @@ -231,7 +229,7 @@ def get_post_processing_list(self, filters=None): graph_years.add_series(serie_obj) elif column in self.columns_to_export_at_poles: invest_profile_poles = self.get_sosdisc_outputs(column + '_array_mix') - series_values = list(invest_profile_poles[column].values) + series_values = list(invest_profile_poles) serie_obj = InstanciatedSeries(list(self.years_poles), series_values, column + '_array_mix', display_type="scatter", marker_symbol='circle', #marker=dict(color='LightSkyBlue', size=20, line=dict(color='MediumPurple', width=2)) From cb20bc4cd3a6219aa37b847b4b7f11fbbbfdeaa9 Mon Sep 17 00:00:00 2001 From: b4pm-devops Date: Sun, 16 Jun 2024 05:07:08 +0000 Subject: [PATCH 03/10] Pickle recalculated --- ..._FossilSimpleTechno_FossilSimpleTechno.pkl | Bin 868 -> 861 bytes ...ossilSimpleTechno_construction_delay_0.pkl | Bin 858 -> 878 bytes .../jacobian_flue_gas_CalciumLooping.pkl | Bin 1486 -> 1389 bytes ...obian_investments_profile_builder_disc.pkl | Bin 516 -> 519 bytes ...quid_fuel_Transesterification_negative.pkl | Bin 1854 -> 1975 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/energy_models/tests/jacobian_pkls/jacobian_FossilSimpleTechno_FossilSimpleTechno.pkl b/energy_models/tests/jacobian_pkls/jacobian_FossilSimpleTechno_FossilSimpleTechno.pkl index 3447681db6fe9eeb8f565217b0d22587f9e9bfb5..a83f2e59fc617c5267e67673681df431d2ada329 100644 GIT binary patch delta 837 zcmaFDc9)IMDJsL#&@oaiIP&k3Am)jD>h)eFTnrBwPyn05#gL23dQHAuGD$gdae~Q- zl#B#MlN1vPpDYs|H#KDzhRj!?W(yY}G%*6%>)lS%2gipmPzW7j+yRl`I#Hac=W5S4lmlCw*TfjdTngQ0NN0?&q)#4!0R zMiJ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EPpU8DjN%C znrY)%AEg7jqfIo)!YkB*k}2NED1fFsss=G$wZvFJgaQN*zA3@a>aL^|vkdWLTOsV< zJjbLKXAqy-u3_+S`5Y>|wO>3u?i)~)Ae#nv5MZJ-wGGF3WhE_-kz~;x{k98?)OPVz zpt~>rEa$0OtEg!x6re=ui7mx?_8=KDYUIhSfEnL9DhK?aa?}nbG(9B)5r`C2Khfep O@pmLsg$WM`L@SU(QdKel diff --git a/energy_models/tests/jacobian_pkls/jacobian_flue_gas_CalciumLooping.pkl b/energy_models/tests/jacobian_pkls/jacobian_flue_gas_CalciumLooping.pkl index 6ac63463935f5ce896b893fe053b8d90e4ee53d8..ab096940732c0b4462fd1497db0dae7f65eda152 100644 GIT binary patch literal 1389 zcmV-z1(NzgT4*^jL0KkKS@R6nJ^%;HfB*lz+w}iu-TlAaw_pGF|N8&#@7Go4-@g6p z%fEJeKfllfyTBp<0)P-?(CMKEy(V?IQgA+{+0B8UJ01OjA zXwcBfkU^77nhZgp4FCb5pfVVSng9%#nrH(?hJYFjO*AwCpa1{>FiioYLqjG&VvSV* zWO|w!28|6EK+|ey8UO=B0RR9E0MIl502&$^WHdA}7)F7h(?*R0X#^QG$)Lm<0MGy$ z8UrDSX`lefiKc)wXlMbT#M47S8UO$Q0|d|-G&C|~1X7bk#AQ#?dT4@rnlnvIY6q#B zgBnH?6DETo27!}64KY1UqHRFaK-xg{G-;sGlP92_pfuAang^kjq=N+jPzZvN2@sT$ z5Kwx0d)$&i1QG%WAo+nH3J)+zKuAGk0t5V@Sb>O0fQSzLMDi#q{+0-By}S9@ z8~Jbbe%U}kt{Sa8q%+(2;IwcZ`JxOl!Wj`O?ExUR&R=&X6XG3xw z(eiHsNg@ucH-V8GR9F#uP)pjujpi8ogjy|>jkyjxpC~P42ZXknERUJpTTEH95(O-o zfhj$7K`K|<%V8<08K1tzM79e_Ok)ASS?hHyz9$g@%}!d*G%hbCup(_^plX)9T|CZv zp&+gX$$|*l$_*P(=)KwnBF;+e-c<)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}}y!b~zmgEQ>G8F4)Kml42gbAU;3>(3PMzBq3-5(5(W|YnKE* z6_d4ZsR7 zOu8w5LHt`pNF^4uZBa`rjj(r|$Og?(==abz8-xO^XE3PX_MQ@>d4q%S_dTwQ=hBJ( z=JsE>rSP4noAsa@4*?Xn^|k*6)}%|qelS@aFYJ;Hs$>bVE-sJR58uUw1~V;g5=4Ns z06RipATmfq1OZ4?fk>rFR)REOjvZ{zk+_%LJ8ek^Zq)IIH8GshDmmMoZN+ZaL8jc% oOmZoM!d%|nWKjn-abH|^dR|82?Eu^kT>r(~kxmpO4H4>@fR?v{7ytkO diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc.pkl index 6e946bc68993c4a2e64dbce4eaf54a6adc2f512a..06f34ceab8d2ba94a893082f79a84da15509244a 100644 GIT binary patch literal 519 zcmV+i0{HzxT4*^jL0KkKS%#Zo4FCZw|NsBJUct*jctp&ZR208&-($<~?}0`D0K$?$ zkdFu?2tmLBw^AY;XlMgK13&-(0iXZ?02u%P3_uY|rXf8OW|YrTWHAhyWXKsb3<$^v zricRs0g359RP=g>8X5r50MGyc0B8UJ00uw+0}uq1l+6=IsgTK_XaE3YXlNP$0imXb zni^zeX`lrNXEGCJ10Dj%(4{pU!LLZqVmF2#D8oXy+83bdKouc3I+&v)6k39I97t!t zn-`d<3v?y3nIh*`jAC(v*VFtb=wt4iNfGYD7)fg+pJ1>!4w1uxHgZ5})jKYRI0f3$gl+=wPH7*y(&xDb&GD(y-R3rXPH9AZ?QurP+o{%9iJA zAZ-l+mP)Z9tT%YR5&jIriM%q8#BYNrA4*=5CBtCuEvh9}VlX5;OdGyuPM-||cJZVeCx1b~Q? zAdx6R*r>n(ya7Q9nkS%40%BlBm5+jCQnmLnqVVM27#m0 zz{*Dk>Dx`12227g%X}kwhC0%o5zbckgM_`8xR!i0oL GOo9*<8r|Oj diff --git a/energy_models/tests/jacobian_pkls/jacobian_liquid_fuel_Transesterification_negative.pkl b/energy_models/tests/jacobian_pkls/jacobian_liquid_fuel_Transesterification_negative.pkl index 1a86c3c09f7de896bf971a7f6ad0ee7ce278d616..1dac05d4f4d41d28e796cfb0c9e494b66a3dc644 100644 GIT binary patch literal 1975 zcmaiudpy$%AIE>&ep|DIU97CkZ^I%ZYNa&UW@(tY*NLK1%u>0PtS6V5a(Ns>E<;#k z=yKvD9o^Y8P1y*}U9=kwS1&G8X#w_@+3dG0$?gS7!t z^VG{cT+Y(Z@{{jsbi)5=~3F65y0zWr86=+E^Rwxj^QIs8`9;cd&n{FNgFyn0EdOP|l5E-KX%!3-1JMnj z;t<^(+MevmBbsr*JY!h^S~g<+&xW+Tj&$e&0IX!W{R4s)zufeHx^Uwo1;zc|mBH>jKxXU+3JC)bjWqoeKTHPgV^0taQq>?Z8wVR4cB zgg7Ien=gC?c8Dq8cmX0|Ff)r()B|lL7iU!Mf+64WkT?o~7w=BhZ)rdTS73zF)B&`!?wwQdK|z~!l7&#TH;BM_lDul zxZ4{5TW*%5nIKs}cy$Wv@|t;wSc7(hSit^MJ!aPg<82dBJtCAOr^sBIu!&@|RC^RB zoGUzkq2N24>&<0dPq=q?roK?=n!0UEv#aGm<;`;F&db7ZXF{?cHTjLhlqz4(&r*D4dNzKHQh?ltRSXY z=TKnGQDr7RwP7g(Id^*R$45zrDz%Qsn!Ut?m*lmPyFCW1KTq@@p4!aG_d%BIJ+nIT ze9oe~1TBK7tJYfvy3%g9PQG+*t8=UvCbGBYss3|3D6ya+uOP_EGH?r^yeIsFG}lqB zBB+V=GcS7gUFh;quFV{8pAIpPq95|BRE%^nXX3a9ERYj#BBS}cdyKh1l~8JfLrOCS zcpvZhp}!WBMGCUi!oV=S%iEcIxjt<0SYh}T|8^UtS?AcRVi&UbMfiP(sg1gt9;M}8 z1$*Z5P)jSWCeBRT8uZsc!t+dvJ$nebCX2b9dIj@l$4hvVNC>~{Cd30@Ys{PqdPl## zH)Vx>F#nU5Y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-d;)_Fz{07gcjK!huZfKVVDJ_j-}Bxb6(Ld#todsI&L-@iL|HW*jD%Rt2kD|0tKRhMN-(FI86r*;DuG7upu}klH-ZEXOLGJR81$r zC_y+B*_^t7wZma3ELZ}T17cN#ExK~SYU*liHGC4ukVQdNbo93I0Ui!U!+Ln|VPG0e zBlM&oS%F>;5S?LlwfG1H_ z2TkTOPdU_DCHbaH!;)i(ZaWpFf$cYb)wsyc>jxT6((j2rbmua@mQb$49j5>yq>NxBxRQ zv}Xl$56!$XKAP7uaUd{hS_frQnOYpmqZ~b+a%cwczLuXbnG_Eod-s$EN~Pq&bcJUl&uH_VK_sK)(fH!WerV_zR2#-h~n!AZ){Cp&#uj|z}TH>hFM&P>nShXCFd1Mre&RjP4dW0{L4=xY5;>?aSeg!H%0FWBw! zVjKz*y7J(y``>qmg;>&S{S@2(_dt-vF?CWFBb>}^Np(TvgqOE%!!PB7tNpc79ojle zxqttLbZ)G<+3PAb{L|MNlO}PZ=p(dzY>#&?hL@%^b3J=!JHp$L_ZR*B`~0+xNS}!p z&0PX&s7k(LKY~_i`i=fHOOxB*ObokbG)k*#cE-Q`3G9f2u@o+|0DT=?OcLx!kI|R* zl4Nf)4B+mk2JR%YM6Gyu9n026$3bHi0+!pABow(eD>(;{OpPxp?_ckSWy;QoT{+g~)Z1Cj8840L3X?HU9 zZTtI#t@g7jJ_es`?v5sePALU_Fla$j#QixF`*+UIIbO!Fq61SGj?qlNT?6S#?ZX7O zH=4y5GJ8H%_H6m>xl2FMzp{K4Y`tSWGu{&wmz35y(yznr_x^d8i&4T{7E zF2ZTn!$+%&YNlTADti?VEtkC5vObw@#c|NLI{75647K6%o=a!!?bki%-gw+^FIoTR z=7Zm(3Sc!wx#f`BbE#=>aee{0rvtGvWXM From f356ec06fbf6e96867458c676a3a6308b35e0b6b Mon Sep 17 00:00:00 2001 From: benherry Date: Mon, 17 Jun 2024 12:32:56 +0200 Subject: [PATCH 04/10] [feat] simplify model and remove hybrid mode, ie either export all columns in the invest_mix dataframe or export all columns in array at the pole --- .../investments_profile_builder_disc.py | 112 ++++++++++-------- ...stments_profile_builder_disc_all_years.pkl | Bin 507 -> 524 bytes ...investments_profile_builder_disc_poles.pkl | Bin 556 -> 565 bytes .../l0_test_investments_profile_builder.py | 62 +--------- ...st_gradient_investments_profile_builder.py | 72 +---------- 5 files changed, 66 insertions(+), 180 deletions(-) diff --git a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py index f684ec7f..4dbe06bc 100644 --- a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py +++ b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py @@ -25,7 +25,6 @@ InstanciatedSeries, TwoAxesInstanciatedChart, ) -from sostrades_core.execution_engine.design_var.design_var import DesignVar from energy_models.core.investments.convex_combination_model import ( ConvexCombinationModel, ) @@ -46,7 +45,7 @@ class InvestmentsProfileBuilderDisc(SoSWrapp): 'icon': 'fas fa-coins fa-fw', 'version': '', } - DESIGN_VAR_DESCRIPTOR = DesignVar.DESIGN_VAR_DESCRIPTOR + EXPORT_PROFILES_AT_POLES = 'export_invest_profiles_at_poles' ''' The DESIGN_VAR_DESCRIPTOR is used by the design variables discipline. If it is not an empty dictionnary and if it contains columns that are already in column_names, then @@ -57,7 +56,7 @@ class InvestmentsProfileBuilderDisc(SoSWrapp): DESC_IN = { 'n_profiles': {'type': 'int', 'unit': '-', 'user_level': 3}, 'column_names': {'type': 'list', 'subtype_descriptor': {'list': 'string'}}, - DESIGN_VAR_DESCRIPTOR: {'type': 'dict', 'editable': True, 'structuring': True, 'user_level': 3, 'namespace': 'ns_invest'}, + EXPORT_PROFILES_AT_POLES: {'type': 'bool', 'editable': True, 'structuring': True, 'user_level': 3, 'namespace': 'ns_invest'}, } DESC_OUT = {} @@ -71,9 +70,7 @@ def setup_sos_disciplines(self): df_descriptor = None column_names = None n_profiles = None - self.columns_to_export_at_poles = None - self.columns_to_export_at_years = None - self.years_poles = None # list of years at the poles + export_profiles_at_poles = None if 'n_profiles' in self.get_data_in(): n_profiles = self.get_sosdisc_inputs('n_profiles') @@ -85,7 +82,7 @@ def setup_sos_disciplines(self): if 'column_names' in self.get_data_in(): column_names = self.get_sosdisc_inputs('column_names') if column_names is not None and n_profiles is not None: - df_descriptor = {GlossaryEnergy.Years: ("int", [1900, GlossaryCore.YearEndDefault],False)} + df_descriptor = {GlossaryEnergy.Years: ("int", [1900, GlossaryCore.YearEndDefault], False)} df_descriptor.update({col: ("float", [0.0, 1e30], False) for col in column_names}) for i in range(n_profiles): dynamic_inputs[f'df_{i}'] = { @@ -93,51 +90,56 @@ def setup_sos_disciplines(self): "dataframe_descriptor": df_descriptor, } - if self.DESIGN_VAR_DESCRIPTOR in self.get_data_in(): - design_var_descriptor = self.get_sosdisc_inputs(self.DESIGN_VAR_DESCRIPTOR) + if self.EXPORT_PROFILES_AT_POLES in self.get_data_in(): + export_profiles_at_poles = self.get_sosdisc_inputs(self.EXPORT_PROFILES_AT_POLES) if column_names is not None: - self.columns_to_export_at_poles = [col for col in column_names if - col + '_array_mix' in design_var_descriptor.keys()] - self.columns_to_export_at_years = [col for col in column_names if col not in self.columns_to_export_at_poles] - if design_var_descriptor is not None and len(self.columns_to_export_at_poles) > 0: + if export_profiles_at_poles is not None and export_profiles_at_poles: dynamic_inputs['nb_poles'] = {'type': 'int', 'unit': '-', 'user_level': 3} - if df_descriptor is not None and self.columns_to_export_at_poles is not None: + if df_descriptor is not None and export_profiles_at_poles is not None: # the output invest profile can be provided either for all the years or for some limited number of poles. - # In the second case, the profiles to consider are defined in DESIGN_VAR_DESCRIPTOR as they are provided - # to the design variables discipline - df_descriptor_years = df_descriptor.copy() - list(map(df_descriptor_years.pop, self.columns_to_export_at_poles)) - # should not add the invest mix if all the outputs are given at the poles - if len(self.columns_to_export_at_years) > 0: + if not export_profiles_at_poles: dynamic_outputs[GlossaryEnergy.invest_mix] = { "type": "dataframe", "unit": "G$", - "dataframe_descriptor": df_descriptor_years, + "dataframe_descriptor": df_descriptor, "namespace": "ns_invest", # same namespace as for invest_mix in discipline InvestmentDistribution "visibility": "Shared", } - for var in self.columns_to_export_at_poles: - df_descriptor_poles = {GlossaryEnergy.Years: ("int", [1900, GlossaryCore.YearEndDefault], False), - var: ("float", [0.0, 1e30], False) - } - dynamic_outputs[f'{var}_array_mix'] = { - "type": "array", - "unit": "G$", - #"dataframe_descriptor": df_descriptor_poles, - "namespace": "ns_invest", - # same namespace as for design_var discipline inputs - "visibility": "Shared", - } + else: + for var in column_names: + dynamic_outputs[f'{var}_array_mix'] = { + "type": "array", + "unit": "G$", + "namespace": "ns_invest", # same namespace as for design_var discipline inputs as described in design_var_descriptor + "visibility": "Shared", + } self.add_inputs(dynamic_inputs) self.add_outputs(dynamic_outputs) + def compute_poles(self, df, nb_poles): + ''' + extract the years of the nb_poles and their corresponding index in a given dataframe + to avoid interpolation, accept non-even step size between the poles + args + df [dataframe]: dataframe that contains a column 'Years' (typically, an invest profile) + nb_poles [int]: number of poles to extract among the list of years + ''' + years = df[GlossaryEnergy.Years] + years_poles = np.linspace(years.values.min(), years.values.max(), nb_poles, + dtype='int') # to avoid interpolation, accept non-even step size between the poles + poles_index = list(df[df[GlossaryEnergy.Years].isin(years_poles)].index) + + return years_poles, poles_index + def run(self): # type: (...) -> None self.model = ConvexCombinationModel() inputs = self.get_sosdisc_inputs() n_profiles = inputs['n_profiles'] + column_names = inputs['column_names'] + export_profiles_at_poles = inputs[self.EXPORT_PROFILES_AT_POLES] self.model.store_inputs( positive_coefficients={f'coeff_{i}': inputs[f'coeff_{i}'] for i in range(n_profiles)}, @@ -147,38 +149,41 @@ def run(self): # type: (...) -> None self.model.compute() convex_combination_df = self.model.convex_combination_df # some data are stored in invest_mix, others in _array_mix - if len(self.columns_to_export_at_years) > 0: + if not export_profiles_at_poles: outputs = { - GlossaryEnergy.invest_mix: self.model.convex_combination_df[[GlossaryEnergy.Years] + self.columns_to_export_at_years] + GlossaryEnergy.invest_mix: self.model.convex_combination_df[[GlossaryEnergy.Years] + column_names] } self.store_sos_outputs_values(outputs) - if len(self.columns_to_export_at_poles) > 0: + else: df = inputs['df_0'] - years = df[GlossaryEnergy.Years] # all profiles should have the same years nb_poles = inputs['nb_poles'] - self.years_poles = np.linspace(years.values.min(), years.values.max(), nb_poles, dtype='int') # to avoid interpolation, accept non-even step size between the poles - self.poles_index = list(df[df[GlossaryEnergy.Years].isin(self.years_poles)].index) - for col in self.columns_to_export_at_poles: # extract data at the poles + years_poles, poles_index = self.compute_poles(df, nb_poles) + for col in column_names: # extract data at the poles df = self.model.convex_combination_df[[GlossaryEnergy.Years] + [col]] - outputs = {col + '_array_mix' : df[df.index.isin(self.poles_index)][col].values} + outputs = {col + '_array_mix': df[df.index.isin(poles_index)][col].values} self.store_sos_outputs_values(outputs) def compute_sos_jacobian(self): dict_in = self.get_sosdisc_inputs() column_names_list = dict_in['column_names'] n_profiles = dict_in['n_profiles'] + df = dict_in['df_0'] + export_profiles_at_poles = dict_in[self.EXPORT_PROFILES_AT_POLES] + if export_profiles_at_poles: + nb_poles = dict_in['nb_poles'] + years_poles, poles_index = self.compute_poles(df, nb_poles) for i in range(n_profiles): for col_name in column_names_list: derivative = self.model.d_convex_combination_d_coeff_in(col_name, f'coeff_{i}') - # some data are stored in invest_mix, others in _array_mix - if col_name in self.columns_to_export_at_years: + # data can be either stored in invest_mix or in _array_mix + if not export_profiles_at_poles: self.set_partial_derivative_for_other_types( (GlossaryEnergy.invest_mix, col_name), (f'coeff_{i}',), derivative.reshape((len(derivative), 1)) ) - else: #col_name in self.columns_to_export_at_poles: - derivative_at_poles = derivative[self.poles_index].reshape((len(self.poles_index), 1)) #extract gradient at the poles only + else: + derivative_at_poles = derivative[poles_index].reshape((len(poles_index), 1)) #extract gradient at the poles only self.set_partial_derivative(col_name + '_array_mix', f'coeff_{i}', derivative_at_poles) def get_chart_filter_list(self): @@ -199,8 +204,13 @@ def get_post_processing_list(self, filters=None): charts = chart_filter.selected_values n_profiles = self.get_sosdisc_inputs('n_profiles') - years = list(self.get_sosdisc_inputs('df_0')[GlossaryEnergy.Years].values) column_names = self.get_sosdisc_inputs('column_names') + df = self.get_sosdisc_inputs('df_0') + years = list(df[GlossaryEnergy.Years].values) # all profiles should have the same years + export_profiles_at_poles = self.get_sosdisc_inputs(self.EXPORT_PROFILES_AT_POLES) + if export_profiles_at_poles: + nb_poles = self.get_sosdisc_inputs('nb_poles') + years_poles, poles_index = self.compute_poles(df, nb_poles) graph_years = TwoAxesInstanciatedChart(GlossaryEnergy.Years, f'Invest {GlossaryEnergy.invest_mix} [G$]', chart_name="Output profile invest") @@ -222,23 +232,23 @@ def get_post_processing_list(self, filters=None): instanciated_charts.append(chart) - if column in self.columns_to_export_at_years: + if not export_profiles_at_poles: invest_profile_years = self.get_sosdisc_outputs(GlossaryEnergy.invest_mix) series_values = list(invest_profile_years[column].values) serie_obj = InstanciatedSeries(years, series_values, column, "lines") graph_years.add_series(serie_obj) - elif column in self.columns_to_export_at_poles: + else: invest_profile_poles = self.get_sosdisc_outputs(column + '_array_mix') series_values = list(invest_profile_poles) - serie_obj = InstanciatedSeries(list(self.years_poles), series_values, column + '_array_mix', display_type="scatter", + serie_obj = InstanciatedSeries(list(years_poles), series_values, column + '_array_mix', display_type="scatter", marker_symbol='circle', #marker=dict(color='LightSkyBlue', size=20, line=dict(color='MediumPurple', width=2)) ) graph_poles.add_series(serie_obj) - if len(self.columns_to_export_at_years) > 0: + if not export_profiles_at_poles: instanciated_charts.append(graph_years) - if len(self.columns_to_export_at_poles) > 0: + else: instanciated_charts.append(graph_poles) return instanciated_charts \ No newline at end of file diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl index 45ab23ef1a40770c6a3c9ea6a46d75fbf851c7ac..087ae3cacb425949f9930b5b54331932fb7c25dc 100644 GIT binary patch literal 524 zcmV+n0`vVsT4*^jL0KkKS<`^kW&i;}|NsBK9s*cdc}IyI6%qgU-}}SlPND!55HNue zasbO<3}V0mywWKSG&BLA0iXZ?0MGyc01SWt1|SHjDUv-C)6-KXo}@I>(ii~%ZA}1V zXvu&C#*-(c)6~Ss^f=Ja27m^D0009(0000o000<(BBe5!CJiQx+K3giS$@lwcbPzCY25 znEb|g`~rkG5*`kL)N@7=j&*Uqrj@V9Q8YgD(m9*MF(#zhsY>`dM-X#;g=Pbo7{Lo5 znllM|0|d+r*v6pF8-S2(vbM)KcekjX6!K~X7<`87YiZjZv~UgB}9sdeekwQyHQ783zn2x8KcC(y5GF<9 zN-`2GDs1!14`Y z|BaE}9(21%b5-4fOo<{)LE{>u$~}YHH)H8YgC{ literal 507 zcmVoA0000000^ldnrdm_NvEL-5r&$cp@h>l4K`5Po}_3u zN@=eE=#4mo1Y^m!A5J+{gccEkCN4qL9zl#AbcR6g4xrf^1E3!0X{0ZF5Ab2-<{e?_ zWDcTVocDh#yW#&Z$|_=m1+!~U9$Nl zXazV{+Tk4iq`fNzWY$XKUVZpX3&flrMgyog5>kNQY!49fjU>R7l_DioA57WFrAk=W z3P}T|In>gLAeT1 zY4RF96b19W@CEN%_UgLHqx0g#n0j1r!3-5bOHF64@Ep&_^OI&6Fk%{Tx6 diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl index ec5c87ed56ee3693838de1c770ce3d38ad8f79f2..b0e84239b96e9c67f0ea7dfdb5ef715590dde813 100644 GIT binary patch literal 565 zcmV-50?PeDT4*^jL0KkKS%myJk^ljTfB*li4nVQ%d3aHC<8NW2kw zXfC4B_wPLmK~ON(rB^`Y9*<3#Ah|3_s-y~ahf?iDrnVfQC*uE_OKFs&`)h01k{8#N zO?2GQ%UoFuZ2pScu5UDwT9s>7%UP1Z81!q4nJV(22^NjMG8!<~+HrVwaEg{)*W}!0 zTx{N<$7 zetF3W&okO^I2&*E&~i%rCw;*2-z$(${&_D0hEVRb+z!KhoSs0yf5qI9P81{|KMo{- D;voKW literal 556 zcmZ>Y%CIzaj8qGbe36sL$H3V2|Ns9rQjZU(R;G8|EIGD6{r>0tw|x^B3|yHu;(=*;0 z7j5fVu%#`CJ#@>PEg6%~I9!Mg3l7}1ZZYe(#z+1+nL2Xod0rSx9JsnF<6+Ux{)hMH zF`vwftP2(v601A#_nmFHeuw{4O&^&LSJ~$HJSOKW>RWY5kmUcKUS9yMUCnmRvh$o<6WH zz*F;a*xE^(Cmj&Wh!C&Vdg>sg%d^{~SaH4I(io?yZLT{?XRORz9(iPv)8QADZ^MmK z?^exkZatg7t?}p12N%Ds{PX5&Oab9Ca8C)f@e Date: Wed, 19 Jun 2024 08:37:18 +0200 Subject: [PATCH 05/10] [fix] updating doc with new output method --- .../documentation/investments_profile_builder_disc.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/energy_models/core/investments/disciplines/documentation/investments_profile_builder_disc.md b/energy_models/core/investments/disciplines/documentation/investments_profile_builder_disc.md index 4c798617..34f20ae3 100644 --- a/energy_models/core/investments/disciplines/documentation/investments_profile_builder_disc.md +++ b/energy_models/core/investments/disciplines/documentation/investments_profile_builder_disc.md @@ -18,5 +18,10 @@ The Investments Profile Builder uses the following formulas : $$ These calculations ensure that the investments are proportionally distributed based on the given coefficients. +The output investment profile can be exported either as a dataframe 'invest_mix' where the values of the variables +are provided for each year or as a 1D array per variable (named 'variable_array_mix') where the values are provided +only for a selected number of years referred to as the poles. +Therefore, the number of poles have to be provided by the user in the second case. To activate the second case, +the user must set to True the input variable 'export_invest_profiles_at_poles' From 5bcc35a5a12fa76ce02033c23d979cc42b14163f Mon Sep 17 00:00:00 2001 From: benherry Date: Wed, 19 Jun 2024 08:38:26 +0200 Subject: [PATCH 06/10] [feat] putting output variable in glossary export_at_poles, update tests --- .../investments_profile_builder_disc.py | 22 +++++++++--------- energy_models/glossaryenergy.py | 1 + ...stments_profile_builder_disc_all_years.pkl | Bin 524 -> 523 bytes ...investments_profile_builder_disc_poles.pkl | Bin 565 -> 556 bytes ...quid_fuel_Transesterification_negative.pkl | Bin 1975 -> 1854 bytes .../l0_test_investments_profile_builder.py | 5 ++-- ...st_gradient_investments_profile_builder.py | 7 ++---- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py index 4dbe06bc..7a073ed2 100644 --- a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py +++ b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py @@ -45,18 +45,18 @@ class InvestmentsProfileBuilderDisc(SoSWrapp): 'icon': 'fas fa-coins fa-fw', 'version': '', } - EXPORT_PROFILES_AT_POLES = 'export_invest_profiles_at_poles' ''' - The DESIGN_VAR_DESCRIPTOR is used by the design variables discipline. - If it is not an empty dictionnary and if it contains columns that are already in column_names, then - the corresponding invest profile for this column_name is exported at the years of the poles only. - The exported data is then to be used by the design variables discipline instead of the investment Distribution discipline + Discipline that generates an output invest profile based on generic input invest profiles and input weights for + each of those profiles. + Based on the input boolean EXPORT_PROFILES_AT_POLES, it can either export the output profile at the poles or for all years + then, the output variable is not named the same, as in the first case it becomes an input of the design_var discipline and + in the second case it is an input of the investment distribution ''' DESC_IN = { 'n_profiles': {'type': 'int', 'unit': '-', 'user_level': 3}, 'column_names': {'type': 'list', 'subtype_descriptor': {'list': 'string'}}, - EXPORT_PROFILES_AT_POLES: {'type': 'bool', 'editable': True, 'structuring': True, 'user_level': 3, 'namespace': 'ns_invest'}, + GlossaryEnergy.EXPORT_PROFILES_AT_POLES: {'type': 'bool', 'editable': True, 'structuring': True, 'user_level': 3, 'namespace': 'ns_invest'}, } DESC_OUT = {} @@ -90,8 +90,8 @@ def setup_sos_disciplines(self): "dataframe_descriptor": df_descriptor, } - if self.EXPORT_PROFILES_AT_POLES in self.get_data_in(): - export_profiles_at_poles = self.get_sosdisc_inputs(self.EXPORT_PROFILES_AT_POLES) + if GlossaryEnergy.EXPORT_PROFILES_AT_POLES in self.get_data_in(): + export_profiles_at_poles = self.get_sosdisc_inputs(GlossaryEnergy.EXPORT_PROFILES_AT_POLES) if column_names is not None: if export_profiles_at_poles is not None and export_profiles_at_poles: dynamic_inputs['nb_poles'] = {'type': 'int', 'unit': '-', 'user_level': 3} @@ -139,7 +139,7 @@ def run(self): # type: (...) -> None inputs = self.get_sosdisc_inputs() n_profiles = inputs['n_profiles'] column_names = inputs['column_names'] - export_profiles_at_poles = inputs[self.EXPORT_PROFILES_AT_POLES] + export_profiles_at_poles = inputs[GlossaryEnergy.EXPORT_PROFILES_AT_POLES] self.model.store_inputs( positive_coefficients={f'coeff_{i}': inputs[f'coeff_{i}'] for i in range(n_profiles)}, @@ -169,7 +169,7 @@ def compute_sos_jacobian(self): column_names_list = dict_in['column_names'] n_profiles = dict_in['n_profiles'] df = dict_in['df_0'] - export_profiles_at_poles = dict_in[self.EXPORT_PROFILES_AT_POLES] + export_profiles_at_poles = dict_in[GlossaryEnergy.EXPORT_PROFILES_AT_POLES] if export_profiles_at_poles: nb_poles = dict_in['nb_poles'] years_poles, poles_index = self.compute_poles(df, nb_poles) @@ -207,7 +207,7 @@ def get_post_processing_list(self, filters=None): column_names = self.get_sosdisc_inputs('column_names') df = self.get_sosdisc_inputs('df_0') years = list(df[GlossaryEnergy.Years].values) # all profiles should have the same years - export_profiles_at_poles = self.get_sosdisc_inputs(self.EXPORT_PROFILES_AT_POLES) + export_profiles_at_poles = self.get_sosdisc_inputs(GlossaryEnergy.EXPORT_PROFILES_AT_POLES) if export_profiles_at_poles: nb_poles = self.get_sosdisc_inputs('nb_poles') years_poles, poles_index = self.compute_poles(df, nb_poles) diff --git a/energy_models/glossaryenergy.py b/energy_models/glossaryenergy.py index 7426749e..58189440 100644 --- a/energy_models/glossaryenergy.py +++ b/energy_models/glossaryenergy.py @@ -27,6 +27,7 @@ class GlossaryEnergy(GlossaryWitnessCore): NB_POLES_FULL: int = 8 # number of poles in witness full NB_POLE_ENERGY_MIX_PROCESS = 12 + EXPORT_PROFILES_AT_POLES = 'export_invest_profiles_at_poles' YearEndDefaultValueGradientTest = 2030 LifetimeDefaultValueGradientTest = 7 YearEndDefault = 2050 diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl index 087ae3cacb425949f9930b5b54331932fb7c25dc..7946a7e98fbbe0a247c67d3ff06c4e06322584b1 100644 GIT binary patch literal 523 zcmV+m0`&btT4*^jL0KkKStY$2!vFz3|NsB2Is|V)ct*IL98Ldk-+S}sPn1MaP#ur} z0SZY05Q4w~w`q*9Nl6IPAR1`M0ie(tX`nO!(8vQvs2XSwQJ~Y*07*!uX$Pe8jWPfM zplA$$XaE2J13&=KVGaNRpaGx_000^>00Te(0009(1eBvF03M@8gFt8ofB@Qop`bJa zAoPF%p{AQrwkjm?M@K!vIhzRb1kg7L(PE4G2L=oea=pf$%C) zkW>Yx4!$Qv`X|M5EV!uk70_Qh3{b@`Tf>NjBrutK*`d~oVc>Za5j0VxSp%TrDnnH; zU!si#4~w8q&J)N?V$zCWMMDbVWnLlT0Zk4vB#(*wF+7oFbSpLqq*_=( zVycoTf_eBv%+WL`54^|8qTds?^hGpYVzu=XqJ|%$y9ok<+L;X*GC7E>-xK!Ph``gR zO?``%QWGc%>S$g_^``5S(SDBy9Ci9)iEOFD*sLXTr>bKF(ii~%ZA}1V zXvu&C#*-(c)6~Ss^f=Ja27m^D0009(0000o000<(BBe5!CJiQx+K3giS$@lwcbPzCY25 znEb|g`~rkG5*`kL)N@7=j&*Uqrj@V9Q8YgD(m9*MF(#zhsY>`dM-X#;g=Pbo7{Lo5 znllM|0|d+r*v6pF8-S2(vbM)KcekjX6!K~X7<`87YiZjZv~UgB}9sdeekwQyHQ783zn2x8KcC(y5GF<9 zN-`2GDs1!14`Y z|BaE}9(21%b5-4fOo<{)LE{>u$~}YHH)H8YgC{ diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_poles.pkl index b0e84239b96e9c67f0ea7dfdb5ef715590dde813..7c814f408f4b48bff112694c575347dff9022ff9 100644 GIT binary patch literal 556 zcmV+{0@M9MT4*^jL0KkKSvhpeF#rLQfB*ljn?S*B`Q?h4R*?T^-{)KQKM74D0D-E& zgn%FjNeI9J+yDcB0MGyofB*n88Z-a^000000N?;L00STZ01SqW000000000u01W^D z$N&HXA)`P50000000dM-Wi>SQJS1q@AjrtgKx6|T^#P_3XwYe(4H{{aH8lNFSTq?Z z>OdZ30gSN+FosT-O{Qox)ZS#?WK@n@ZP{f~Ta8eVfDj}M<%yc*KLiS0wii>)4F!Rt zaBl25IfeAEb)D8|bH1-9ajOGGas$=MJ$D}VJ3aC5)Gj=~UaE535zCS*#+%BO;gw^- zfH%E#S*?Q9+GLQt*KzoKGSv*767%wKf#-u$+NRHYUEO{z8~~etSm())0O?HP z#uPtCn(MPLM_?(sTc4e@aZ&v2c(&(K3Sb;^3?Ljw0`B~Q%d3aHC<8NW2kw zXfC4B_wPLmK~ON(rB^`Y9*<3#Ah|3_s-y~ahf?iDrnVfQC*uE_OKFs&`)h01k{8#N zO?2GQ%UoFuZ2pScu5UDwT9s>7%UP1Z81!q4nJV(22^NjMG8!<~+HrVwaEg{)*W}!0 zTx{N<$7 zetF3W&okO^I2&*E&~i%rCw;*2-z$(${&_D0hEVRb+z!KhoSs0yf5qI9P81{|KMo{- D;voKW diff --git a/energy_models/tests/jacobian_pkls/jacobian_liquid_fuel_Transesterification_negative.pkl b/energy_models/tests/jacobian_pkls/jacobian_liquid_fuel_Transesterification_negative.pkl index 1dac05d4f4d41d28e796cfb0c9e494b66a3dc644..1a86c3c09f7de896bf971a7f6ad0ee7ce278d616 100644 GIT binary patch literal 1854 zcmb`Bi#OYc8^*sPNfXMDxW%MNC{Z@iB~+_z+}gOsC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^UTAi~FoHi==IUYxR zRfd$gVT|{AcO}kVQdQrhKSF#-iR%CHQASapOr*R0&{>ZIRIlGg#onFjn5~T=Pq&mM z`ZTQ670+)Oacdg#6)kw3xV~^EqFA8pud6~O=l-Zs7jHPoXLGI3HQHMvt@OX{;f)@P zEN9D6BB z?`hcm>_AIHt?Ejt1msJoCh*G5R2SIJpl8O9eO%)b2wK6@1r1D&ymD+v83=2xkFxMQmegH3?_8D#cWkjH;$NV*lb zf1sISW`xF#>Y(e#mk`^btlb+PL3!1(0I^W2tIe*X*_E_Oa&qqCM)R@}3GweSeko!1 zm=f>kKz}*XoPNUvpqlD%0ZbDB48x84;INTQZ~GZe)w+KH8m~D(t|de>GSR4tV{aVR z5u8SX3&Usv%s$J|F)>l$$hZ!Ydgi;fy8&%q%KO@c8fN3$5-XrsZ<}h zIsW^%PS@u}wJk%#F;_jB^{v2lwvmk@wzkQMx|d%`u{U)(C1h>JU^AwS6^{rf?;Hy2 zJN>u)!@0WwlY*$aU2+Qil#@NE!Vs~Vfz?lJ8sCOq!UrB(b6Nb0KC6srh}My=jvm_E zCb<~h%Vd;t4Hb)Felu&$J8u=G-N+U=f?zjGmU&dxc+@*&i6~ra5sJ1uz#SR0s33^2 zfxU`nQiZSAn~bo7q)g80YYrOtNV}HZhJ3PywM}Cw%k;{0_xBCH`6qHu7A}5vP(Ev@ z87uX`h^g|a%<(_M>eQTqz7dY7s4E@0Be4Ug$5tKQyZ9hZ)`TP4yI;c|TJrxQ>-O~z z&mp8cg}dkm?BJyU9Y+e^`vAgess Date: Wed, 19 Jun 2024 10:36:26 +0200 Subject: [PATCH 07/10] add some variable to glossary energy --- energy_models/glossaryenergy.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/energy_models/glossaryenergy.py b/energy_models/glossaryenergy.py index 58189440..37016ffb 100644 --- a/energy_models/glossaryenergy.py +++ b/energy_models/glossaryenergy.py @@ -452,6 +452,12 @@ class GlossaryEnergy(GlossaryWitnessCore): "dataframe_edition_locked": False, } + TechnoProductionDf = { + "var_name": TechnoProductionValue, + 'type': 'dataframe', 'unit': 'TWh or Mt', + "dynamic_dataframe_columns": True + } + # techno names CropEnergy = "CropEnergy" ManagedWood = "ManagedWood" @@ -478,8 +484,10 @@ class GlossaryEnergy(GlossaryWitnessCore): RenewableElectricitySimpleTechno = "RenewableElectricitySimpleTechno" SolarPv = "SolarPv" SolarThermal = "SolarThermal" + Solar = "Solar" WindOffshore = "WindOffshore" WindOnshore = "WindOnshore" + WindOnshoreAndOffshore = 'WindOnShoreandOffShore' BiomassFermentation = "BiomassFermentation" FossilSimpleTechno = "FossilSimpleTechno" ElectrolysisAWE = "Electrolysis.AWE" @@ -523,6 +531,7 @@ class GlossaryEnergy(GlossaryWitnessCore): SMR = "SMR" AnimalManure = "AnimalManure" WetCropResidues = "WetCropResidues" + ForestProduction = "ForestProduction" AmineScrubbing = "AmineScrubbing" CalciumPotassiumScrubbing = "CalciumPotassiumScrubbing" From f76d1362ccecbbd1a7e9253c72865086561d7ac0 Mon Sep 17 00:00:00 2001 From: Yasser BEKKALI Date: Wed, 19 Jun 2024 17:22:45 +0200 Subject: [PATCH 08/10] Update glossaryenergy.py --- energy_models/glossaryenergy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/energy_models/glossaryenergy.py b/energy_models/glossaryenergy.py index 37016ffb..754aa452 100644 --- a/energy_models/glossaryenergy.py +++ b/energy_models/glossaryenergy.py @@ -454,10 +454,15 @@ class GlossaryEnergy(GlossaryWitnessCore): TechnoProductionDf = { "var_name": TechnoProductionValue, - 'type': 'dataframe', 'unit': 'TWh or Mt', + "type": "dataframe", "unit": "TWh or Mt", "dynamic_dataframe_columns": True } + EnergyPricesDf = { + "var_name": GlossaryWitnessCore.EnergyPricesValue, + "type": "dataframe", "unit": "$/MWh", + "dynamic_dataframe_columns": True} + # techno names CropEnergy = "CropEnergy" ManagedWood = "ManagedWood" From 0bfdfb78ab9faa9f34027a1ede11b25bca9ff7f7 Mon Sep 17 00:00:00 2001 From: benherry Date: Thu, 20 Jun 2024 08:52:36 +0200 Subject: [PATCH 09/10] [fix] correction pylint error --- .../investments_profile_builder_disc.py | 2 ++ ...vestments_profile_builder_disc_all_years.pkl | Bin 523 -> 522 bytes ...n_investments_profile_builder_disc_poles.pkl | Bin 556 -> 564 bytes 3 files changed, 2 insertions(+) diff --git a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py index 7a073ed2..3267c17d 100644 --- a/energy_models/core/investments/disciplines/investments_profile_builder_disc.py +++ b/energy_models/core/investments/disciplines/investments_profile_builder_disc.py @@ -170,6 +170,7 @@ def compute_sos_jacobian(self): n_profiles = dict_in['n_profiles'] df = dict_in['df_0'] export_profiles_at_poles = dict_in[GlossaryEnergy.EXPORT_PROFILES_AT_POLES] + poles_index = None # initialize to avoid pylint error if export_profiles_at_poles: nb_poles = dict_in['nb_poles'] years_poles, poles_index = self.compute_poles(df, nb_poles) @@ -208,6 +209,7 @@ def get_post_processing_list(self, filters=None): df = self.get_sosdisc_inputs('df_0') years = list(df[GlossaryEnergy.Years].values) # all profiles should have the same years export_profiles_at_poles = self.get_sosdisc_inputs(GlossaryEnergy.EXPORT_PROFILES_AT_POLES) + years_poles = None # initialize to avoid pylint error if export_profiles_at_poles: nb_poles = self.get_sosdisc_inputs('nb_poles') years_poles, poles_index = self.compute_poles(df, nb_poles) diff --git a/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl b/energy_models/tests/jacobian_pkls/jacobian_investments_profile_builder_disc_all_years.pkl index 7946a7e98fbbe0a247c67d3ff06c4e06322584b1..a350cc1b38b6300b2118469af968cf213f6e240f 100644 GIT binary patch literal 522 zcmV+l0`>huT4*^jL0KkKS+?y!`v3t!|NsB2+JQ;Kcy!2lHn6{E|8CFsPniJ)0KnXU z2$d)VhylO>w^A{oB_$72)CPf|0B8e10B8Vc4FCb7O&L8PJxx5Il95kD(9yJ>p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*#;6PpsEB{FBEoZNA8 z_Q&hBky%0ZmZ`>bc6eEGyMNgduVvERy69HdrqHeH=00g=pZop63htCkb}Fq(4^PF& i$?MHIda0>%S&W{<(Mt<2bg%xW_oS;}p#pQ%2`vDdpy*%# literal 556 zcmV+{0@M9MT4*^jL0KkKSvhpeF#rLQfB*ljn?S*B`Q?h4R*?T^-{)KQKM74D0D-E& zgn%FjNeI9J+yDcB0MGyofB*n88Z-a^000000N?;L00STZ01SqW000000000u01W^D z$N&HXA)`P50000000dM-Wi>SQJS1q@AjrtgKx6|T^#P_3XwYe(4H{{aH8lNFSTq?Z z>OdZ30gSN+FosT-O{Qox)ZS#?WK@n@ZP{f~Ta8eVfDj}M<%yc*KLiS0wii>)4F!Rt zaBl25IfeAEb)D8|bH1-9ajOGGas$=MJ$D}VJ3aC5)Gj=~UaE535zCS*#+%BO;gw^- zfH%E#S*?Q9+GLQt*KzoKGSv*767%wKf#-u$+NRHYUEO{z8~~etSm())0O?HP z#uPtCn(MPLM_?(sTc4e@aZ&v2c(&(K3Sb;^3?Ljw0`B~ Date: Thu, 20 Jun 2024 10:47:22 +0200 Subject: [PATCH 10/10] platform requirement v4.0.2 --- platform_version_required.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform_version_required.txt b/platform_version_required.txt index 85937e4d..752d86b6 100644 --- a/platform_version_required.txt +++ b/platform_version_required.txt @@ -1 +1 @@ -v4.0.1 \ No newline at end of file +v4.0.2 \ No newline at end of file