I have a code "factoring" question (C++, but the language is mostly irrelevant). I have…
- User
I have a code "factoring" question (C++, but the language is mostly irrelevant). I have two models, one yearly and one monthly. The logic is not very different. Now I am implementing a "compare and possibly replace" functionality: think of the model as computing a lot of "columns" (as they would be if it were Excel), then I first compute the output with a given input/given initial conditions, then I compute the output again with a "shocked" input/modified initial conditions, then I read in the output from the first run and check whether the sum of the values of some of the columns at time 0 is bigger than the corresponding sum for the second (current run): if it is, I use the read-in first run output as the output of the second run as well and otherwise I use the actual output.
I implemented it for the yearly model by having a boolean variable use_first_scenario (simply return sum_of_some_columns_read > sum_of_some_columns(0);) and then for each of the columns, something like: if use_first_scenario { lookup_time = t; return current_column_read; } return current_column(t);
Now I want to do the same for the monthly model. Should I create use_first_scenario_monthly with the corresponding logic, or add it to my existing use_first_scenario via if (monthly_setting = "N") (then use yearly, otherwise monthly logic) and then put either boolean variable in all monthly columns?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.