pyomo
pyomo copied to clipboard
Solve square problem to initialize regression problem using parmest using `objective_at_theta()`
Summary
Updating the function objective_at_theta()
to support the option theta_values=None
instead of making changes to theta_est()
to solve a square instance of the parameter estimation problem in parmest
for complex Pyomo models before solving the actual regression problem. @adowling2 @blnicho @jsiirola this issue supercedes PR #2322. I will close PR #2322 and open a new PR once this is implemented.
Rationale
Instead of modifying theta_est()
, use existing functionality from objective_at_theta()
to solve initial square problem.
Description
Following are the steps for the proposed functionality:
- Update
objective_at_theta()
to handletheta_values = None
: Parameters are fixed at initialized values and model is solved as a square problem - Unfix parameters before
theta_est()
is called for parameter estimation - Add documentation explaining the sequence of solving a parameter estimation problem with an initial square solve on this page.
a. Create Estimator objects
b. Call
objective_at_theta(theta_values=None)
c. (Optional) SpecifyIPOPT
solver options to initialize parameter estimation from the square problem solution (bound_push
) d. Calltheta_est()
Challenge using workflow described in this issue:
Function objective_at_theta()
calls internal method _Q_at_theta()
which creates a local Pyomo model instance for each scenario, solves the model, and returns the objective function values and theta values.
If objective_at_theta()
is used to solve a square problem to initialize the parameter estimation problem (using theta_est()
), the solved instance of the square problem is over-written by methods in theta_est()
which create the extended form of the model and the square-solve is not utilized.
Proposed changes:
-
Add a member flag
model_initialized
for Estimator object to indicate iftheta_est()
needs to create the extended form of the model- Default:
False
,theta_est()
creates the extended model form with all scenarios (current behavior) - If
True
, skip building the extended model form usingtheta_est()
- Default:
-
Add flag argument
initialize_parmest_model
toobjective_at_theta()
- Default=
False
,objective_at_theta()
works as it currently does - If
True
, use Pyomo model components from instances created by_Q_at_theta()
called fromobjective_at_theta()
to build extended form of the model for parameter estimation and set flagmodel_initialized = True
- Additional feature: If there are exceptions for any particular scenario (solver termination condition not optimal), provide a warning message to user with scenario number.
- Default=
Updated workflow:
1. Create Estimator object
2. Call objective_at_theta(theta_values=None, initialize_parmest_model=True)
a. objective_at_theta()
solves the single-scenario, square-instance of the model for each scenario with theta
fixed at values used to initialize the model. These models are then used to build the extended form for parameter estimation
3. Call theta_est()
4. (Optional) Specify IPOPT solver options to initialize parameter estimation from the square problem solution (bound_push
)
Questions
- How should we approach copying and collecting variables from the model instances in
_Q_at_theta()
called fromobjective_at_theta()
to build the extended form of the model instead of creating it throughtheta_est()
? - Any possible compatibility issues or redundancies to think about?
@adowling2, @kaklise, @blnicho thoughts on this approach?
And to remind everyone, our overarching goal is for ParmEst to model systematically initialize the model using a provided value of theta.
The proposal here is to use objective_at_theta()
to solve the square problem for each scenario (data set) independently, then copy the initialized values into the "full" (2-stage stochastic program) instance of the parameter estimation model (which is created and solved by theta_est()
currently).
Created a PR (#2438 ) to merge the changes suggested in this issue into main. However, the codecov tests through GitHub actions are failing repeatedly with the following error for all 3 platforms (linux, win, osx):
While searching for solutions to fix this, I found the following GitHub issue: https://github.com/codecov/codecov-action/issues/598 which was closed using the PR: https://github.com/CCExtractor/sample-platform/pull/667
The solution seems to be to downgrade codecov github action to use v0.1.15.
@blnicho It would be great if we could discuss this during today's (06/21/2022) dev call.
Can this be closed now that the PR was merged? @kanishka-ghosh
Yes