pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

Solve square problem to initialize regression problem using parmest using `objective_at_theta()`

Open kanishka-ghosh opened this issue 2 years ago • 3 comments

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:

  1. Update objective_at_theta() to handle theta_values = None: Parameters are fixed at initialized values and model is solved as a square problem
  2. Unfix parameters before theta_est() is called for parameter estimation
  3. 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) Specify IPOPT solver options to initialize parameter estimation from the square problem solution (bound_push) d. Call theta_est()

kanishka-ghosh avatar May 03 '22 15:05 kanishka-ghosh

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 if theta_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 using theta_est()
  • Add flag argument initialize_parmest_model to objective_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 from objective_at_theta() to build extended form of the model for parameter estimation and set flag model_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.

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 from objective_at_theta() to build the extended form of the model instead of creating it through theta_est()?
  • Any possible compatibility issues or redundancies to think about?

@adowling2, @kaklise, @blnicho thoughts on this approach?

kanishka-ghosh avatar May 12 '22 14:05 kanishka-ghosh

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).

adowling2 avatar May 12 '22 14:05 adowling2

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): image

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.

kanishka-ghosh avatar Jun 21 '22 18:06 kanishka-ghosh

Can this be closed now that the PR was merged? @kanishka-ghosh

adowling2 avatar Sep 27 '22 10:09 adowling2

Yes

kanishka-ghosh avatar Sep 27 '22 11:09 kanishka-ghosh