Closed artgoldberg closed 3 years ago
Not a problem.
From my email to Yin Hoon:
I believe that the method unscale_conv_opt_solution() is correct as it stands. My analysis differs from your example below because the terms in the dfba_obj_expr (to use the WC Sim terminology) are reactions (wc_lang.Reaction and wc_lang.DfbaObjReaction instances) not species.
Take the example from tests/submodels/test_dfba.py, the model in tests/submodels/fixtures/dfba_test_model.xlsx. Its objective is
dfba_obj_expr = 1 * biomass_reaction
where biomass_reaction is 'm3[c] ==> '. The dFBA problem is solved in "tests/submodels/fixtures/Solutions to test dFBA models, by hand.txt”. In lines 31 - 50 I obtain the reaction fluxes.
If the problem is changed by scaling the dFBA objective coefficients by s, then the entire solution remains the same, except that the objective functions given to the solver — let’s call it objective_scaled — is
s * biomass_reaction.
Since the solution to the remainder of the FBA conv. opt. model remains unchanged, the solver reports that
objective_scaled = s * biomass_reaction = s * dfba_obj_expr
Therefore, the unscaled dfba_obj_expr is given by
dfba_obj_expr = objective_scaled / s
My unit tests confirm this in test "V: Modify II by scaling the coefficients of objective function's terms by 10”, following line 709, which uses the same inputs as test II, but scales the coefficients in dFBA objectives by 10. The test confirms that the same value for the objective is obtained as in test II.
Yin Hoon writes:
It was really nice to see the things we discussed implemented in neat code. Below are my comments:
There is a bug in line 641 under the method unscale_conv_opt_solution. Specifically, in contrast to bound scaling where we do the opposite (division vs multiplication) to un-scale, for coefficient scaling we do the same operation. This may seem unintuitive so I’ll use a simple example to illustrate that: