Refactor solve_lp_for_year.py
Not ready to merge
In filing #323 I looked through this file, and took a stab at streamlining the code. Changes include:
- Using a
wage_binfunction to create wage bins. - Using a loop to assign
lhs_varsdictionary elements.* - Using a loop to assign factor variables.
- Using an
add_targetfunction to assignrhs_varsdictionary elements.* - More explicitly adjust
model_varsfor year 2014. - Rename
LPtolpsince it's not a constant. - Other minor changes like comments.
* These pieces won't currently work since they attempt to access globals() from within a function (locals() also won't work). Per https://stackoverflow.com/q/56983782/1840471, there's no good way to access these in-between-scoped variables, and this is really a sign that something could be done better. It seems to me that sticking with the dictionary elements rather than creating new variables would be a clean alternative.
I haven't tested this code yet. Would the right way be to run make cps-files?
Thanks for working on this, @MaxGhenis! These changes look good so far.
I haven't tested this code yet. Would the right way be to run make cps-files?
Yes. Once you run this it'll create a new weights file and you can see if the results have changed at all. Fair warning, this will take a few hours to run.
Sorry I've left this open so long. I'll resolve conflicts, boil it down to the basics, and test it, once #343 is merged.