conroylau / lpinfer

lpinfer: An R Package for Inference in Linear Programs
GNU General Public License v3.0
3 stars 5 forks source link

The first step of `estbounds` should be callable by itself #19

Closed a-torgovitsky closed 4 years ago

a-torgovitsky commented 4 years ago

Call it mincriterion Remember not to duplicate code when breaking this out Edit: now --> not

conroylau commented 4 years ago

The first step of estbounds is callable, but I have written them separately for 1-norm (the function estbounds1_L1) and 2-norm (the function estbounds1_L2).

I will use a function mincriterion to cover both cases and break them out of the estbounds function.

I am thinking of using S3 style on mincriterion so that it can present the results in a nice way via print or summary, just like the dkqs or estbounds functions etc.

May I check with you would it be enough to print the following information from the mincriterion function?

Thank you!

a-torgovitsky commented 4 years ago

The first step of estbounds is callable, but I have written them separately for 1-norm (the function estbounds1_L1) and 2-norm (the function estbounds1_L2).

I will use a function mincriterion to cover both cases and break them out of the estbounds function.

Ok, just make sure not to duplicate code for the constraints, which are going to be the same for parts of the two problems.

Having the print function is helpful, but don't include this:

  • If the minimum value of the objective function is 0, print an additional information indicating that the actual linear or quadratic program that finds the bounds is feasible and the bounds produced in the second stage of the estimation procedure will be the same as the bounds from the actual problem.
conroylau commented 4 years ago

Done! I have added the function mincriterion for the first stage estimation procedure. The constraints are not duplicated for the 1-norm and the 2-norm problem.

The following is a sample output using the print function:

Call:
mincriterion(data = data, func_obs = func_two_moment, A_obs = A_obs_twom, 
    A_tgt = A_tgt, A_shp_eq = A_shp_eq_dkqs, A_shp_ineq = A_shp_ineq_dkqs, 
    beta_shp_eq = beta_shp_eq_dkqs, beta_shp_ineq = beta_shp_ineq_dkqs, 
    norm = 2, solver = "gurobi")

< Results from the first stage estimation procedure >
Minimum value: 0 
Norm used: L2-norm 
Solver used: gurobi 

May I know would this be okay? In addition, should I make the summary function as a wrapper for the print function as before too?

Thank you!

a-torgovitsky commented 4 years ago

For now it's fine if they are the same. Later we may want to add information. print should look like this:

Minimum value: 0 
Norm: 2
Solver: gurobi 
conroylau commented 4 years ago

Done! I have revised the print message in the above format and made summary to be the wrapper of print for now. Thanks!