<jupyter_start><jupyter_text>**1: Final goods sector** This runs the final goods sector alone, to provide some understanding of relevant classes in the abatement model.  **1.1: Define nesting structure and read in data via nesting_trees** Define nesting structure of inputs by mapping: Keys are aggregates, values are inputs in that aggregate.<jupyter_code>FG_tree = af.nesting_tree(
    name='FG',
    tree = {
        'KE': ['K','E'],
        'E' : ['E1','E2']},
    **{'setname': 'n',
       'alias': 'nn',
       'alias2' : 'nnn',
       'inpname': 'in_FG',
       'aggname': 'agg_FG',
       'mapname': 'in_FG2agg_FG',
       'outname': 'out_FG',
       'sector':  'sec_FG'}
)<jupyter_output><empty_output><jupyter_text>Create sets, subsets, and mappings from tree:<jupyter_code>FG_tree.run_all()<jupyter_output><empty_output><jupyter_text>Read in data from excel:<jupyter_code>read_type = {'1dvars': ['sigma'], # list sheets with with data of variables defined over 1 set
             'vars_panel': {'mu': 2}} # dictionary with variables defined over n sets written in panel-data form. Key refers to sheet name, value refers to number of sets.
FG_tree.database.read_from_excel('Make_data//FinalGoods.xlsx',read_type)<jupyter_output><empty_output><jupyter_text>**1.2: Initialize abatement_model with nesting_tree**<jupyter_code>FG = af.abatement_model(FG_tree)
FG.run_abatement_model(repo=os.getcwd()+'\\gms\\FG',type_='CES',export_settings=True)<jupyter_output><empty_output><jupyter_text>**1.3: Finally, use the model to initialize gams model** Initialize model with database, and workfolder:<jupyter_code>FG_model = DB2Gams.gams_model(os.getcwd()+'\\workfolder')<jupyter_output><empty_output><jupyter_text>*NB: We can pass options to the solver using dict inputs*<jupyter_code># FG_model.run(FG.model,options_run={'output': sys.stdout}) # Run with gams output in cell
FG_model.run(FG.model) # run without<jupyter_output>WARNING: \%FG\% is not defined and was not replaced
WARNING: \%FG\% is not defined and was not replaced
WARNING: \%FG\% is not defined and was not replaced
WARNING: \%FG\% is not defined and was not replaced
WARNING: \%FG\% is not defined and was not replaced
WARNING: \%FG\% is not defined and was not replaced
WARNING: \%FG\% is not defined and was not replaced
WARNING: \%FG\% is not defined and was not replaced<jupyter_text>The database:  **2: Energy-Service producing firms**<jupyter_code>ES_tree = af.nesting_tree(
    name='ES',
    tree= {
        'E1': ['E10','E11'],
        'E2': ['E20','E21','E22']},
    **{'setname': 'n',
       'alias'  : 'nn',
       'alias2' : 'nnn',
       'inpname': 'in_ES',
       'aggname': 'agg_ES',
       'mapname': 'in_ES2agg_ES',
       'outname': 'out_ES',
       'sector': 'sec_ES'}
)<jupyter_output><empty_output><jupyter_text>Create sets, read in data from excel:<jupyter_code>ES_tree.run_all()
read_type = {'1dvars': ['sigma'], 'vars_panel': {'mu': 2}}
ES_tree.database.read_from_excel('Make_data//ES.xlsx',read_type)<jupyter_output><empty_output><jupyter_text>Initialize as model:<jupyter_code>ES = af.abatement_model(ES_tree)
ES.run_abatement_model(repo=os.getcwd()+'\\gms\\ES',type_='normalized_CES',export_settings=True)<jupyter_output><empty_output><jupyter_text>Run model:<jupyter_code>gams_ES = DB2Gams.gams_model(work_folder = os.getcwd()+'\\workfolder')
gams_ES.run(ES.model)<jupyter_output>WARNING: \%ES\% is not defined and was not replaced
WARNING: \%ES\% is not defined and was not replaced
WARNING: \%ES\% is not defined and was not replaced
WARNING: \%ES\% is not defined and was not replaced
WARNING: \%ES\% is not defined and was not replaced
WARNING: \%ES\% is not defined and was not replaced
WARNING: \%ES\% is not defined and was not replaced
WARNING: \%ES\% is not defined and was not replaced<jupyter_text>**3: Energy-Service-component producing firms**<jupyter_code>ESC_tree = af.nesting_tree(
    name='ESC',
    tree= {
        'E10': ['E100'],
        'E11': ['E110','E111'],
        'E20': ['E200'],
        'E21': ['E210','E211'],
        'E22': ['E220','E221','E222']},
    **{'setname': 'n',
       'alias'  : 'nn',
       'alias2' : 'nnn',
       'inpname': 'in_ESC',
       'aggname': 'agg_ESC',
       'mapname': 'in_ESC2agg_ESC',
       'outname': 'out_ESC',
       'sector': 'sec_ESC'}
)
ESC_tree.run_all()
read_type = {'1dvars': ['sigma']}
ESC_tree.database.read_from_excel('Make_data//ESC.xlsx',read_type)
ESC = af.abatement_model(ESC_tree)
ESC.run_abatement_model(repo=os.getcwd()+'\\gms\\ES',type_='MNL',export_settings=True)<jupyter_output><empty_output><jupyter_text>Run model:<jupyter_code>gams_ESC = DB2Gams.gams_model(work_folder = os.getcwd()+'\\workfolder')
gams_ESC.run(ESC.model)<jupyter_output>WARNING: \%ESC\% is not defined and was not replaced
WARNING: \%ESC\% is not defined and was not replaced
WARNING: \%ESC\% is not defined and was not replaced
WARNING: \%ESC\% is not defined and was not replaced
WARNING: \%ESC\% is not defined and was not replaced
WARNING: \%ESC\% is not defined and was not replaced
WARNING: \%ESC\% is not defined and was not replaced
WARNING: \%ESC\% is not defined and was not replaced<jupyter_text>**4: Energy-service technologies** A nesting tree with input-split, and output-split models: **Baseline component-technologies** *Tree:*<jupyter_code>Tech_tree_base = af.nesting_tree(
    name='Tbase',
    tree={'E100': ['B1_E100','B2_E100','K_E100'],
          'E200': ['B2_E200','B2_E200','K_E200']},
    **{'setname': 'n',
       'alias'  : 'nn',
       'alias2' : 'nnn',
       'inpname': 'in_Tbase',
       'aggname': 'agg_Tbase',
       'mapname': 'in_Tbase2agg_Tbase',
       'outname': 'out_Tbase',
       'sector' : 'sec_Tbase'}
)
Tech_tree_base.run_all()<jupyter_output><empty_output><jupyter_text>*Write model:*<jupyter_code>Tbase = af.abatement_model(Tech_tree_base)
Tbase.run_abatement_model(repo=os.getcwd()+'\\gms\\Tbase',type_='CES',export_settings=True)<jupyter_output><empty_output><jupyter_text>*Run model:*<jupyter_code>gams_Tbase = DB2Gams.gams_model(os.getcwd()+'\\workfolder')
gams_Tbase.run(Tbase.model)<jupyter_output>WARNING: \%Tbase\% is not defined and was not replaced
WARNING: \%Tbase\% is not defined and was not replaced
WARNING: \%Tbase\% is not defined and was not replaced
WARNING: \%Tbase\% is not defined and was not replaced
WARNING: \%Tbase\% is not defined and was not replaced
WARNING: \%Tbase\% is not defined and was not replaced
WARNING: \%Tbase\% is not defined and was not replaced
WARNING: \%Tbase\% is not defined and was not replaced<jupyter_text>**None baseline component-technologies**<jupyter_code>Tech_tree = af.nesting_tree_with_CET(
    name='T', 
    tree={'in': {'E110': ['B1_E110','B2_E110'],
                 'E210': ['B1_E210','B2_E210'],
                 'E220': ['B1_E220','B2_E220'],
                 'T1'  : ['B1_T1','B2_T1','K_T1'],
                 'T2'  : ['B1_T2','B2_T2','K_T2'],
                 'T3'  : ['B1_T3','B2_T3','K_T3']},
         'out': {'T1'  : ['E111'],
                 'T2'  : ['E211', 'E221'],
                 'T3'  : ['E222']}},
    **{'setname': 'n',
       'alias'  : 'nn',
       'alias2' : 'nnn',
       'in_map' : 'in_map_T',
       'out_map': 'out_map_T',
       'all_map': 'all_map_T',
       'in_endo': 'in_endo_T',
       'out_endo': 'out_endo_T',
       'in_agg' : 'in_agg_T',
       'out_agg': 'out_agg_T',
       'all_agg': 'all_agg_T',
       'inpname': 'input_T',
       'outname': 'output_T'
       })
Tech_tree.run_all()
Tech = af.abatement_model_with_CET(Tech_tree)
Tech.run_abatement_model(repo=os.getcwd()+'\\gms\\Tech',type_in='CES',type_out='CES',export_settings=True)
gams_Tech = DB2Gams.gams_model(work_folder = os.getcwd()+'\\workfolder')
gams_Tech.run(Tech.model)<jupyter_output>WARNING: \%T\% is not defined and was not replaced
WARNING: \%T\% is not defined and was not replaced
WARNING: \%T\% is not defined and was not replaced
WARNING: \%T\% is not defined and was not replaced
WARNING: \%T\% is not defined and was not replaced
WARNING: \%T\% is not defined and was not replaced
WARNING: \%T\% is not defined and was not replaced
WARNING: \%T\% is not defined and was not replaced
{'fraction_non_alphanumeric': 0.16010788280004903, 'fraction_numerical': 0.021453965918842712, 'mean_word_length': 4.307742355237475, 'pattern_counts': {'":': 0, '<': 60, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '458646', 'license': 'MIT', 'n_tokens_mistral': 3132, 'n_tokens_neox': 2940, 'n_words': 713, 'path': 'InputDisplacingAbatement/Building_models_w_nesting_trees.ipynb', 'repo_name': 'ChampionApe/Abatement_project', 'size': '8157'}