Skip to main content

Add Linear Regression Constraint Constr with some constant features and some optimization variable features

Answered

Comments

5 comments

  • Suman Tripathy
    Gurobi-versary
    First Comment
    First Question

    Sorry - the support website isn't letting me attach the ilp, log, sol, mps files?

    0
  • Suman Tripathy
    Gurobi-versary
    First Comment
    First Question

    Darn ok, putting in the LR model directly with its coefficients gives me the same exact error, so something else must be wrong in my problem setup, but I don't know how to interpret the output of the IIS file. I have a dictionary for optimization constants with floats as the values. Note that water = gp.Var here.

    lr_yield = model.addConstr(pct_yield_ta == 1.01e-3 * optimization_constants['Torque'] + 1.54e1 * water + 1.22e-3 *optimization_constants['Days'] + 86.7) 
    model.update()
    0
  • Pierre Bonami
    Gurobi Staff Gurobi Staff

    In the ILP file you have that the variable `Torque_Mill_1_TA` should take an integer value but it is equal to 1943.07, a contradiction. That is why the model is infeasible.

    As in your initial description you say that Torque and days are fixed values they shouldn't have integer requirements when you declare them in Gurobi.

    0
  • Suman Tripathy
    Gurobi-versary
    First Comment
    First Question

    Hi, yes I realized my mistake later. Thank you so much for your help. I actually have a more challenging follow-up now.  I am now trying to compare outputs of my model when I plug in Linear Regression vs. Random Forest Regression.  My RF model has much lower error, and I was hoping to plug it into my Gurobi model. However, it seems to be giving results that we "don't expect" as opposed to LR, which gives more interpretable outputs.

    For example, in my problem, I have 2 water flows (variables Imbibition Water TA and Imbibition Water TB) and I expect my optimizer to be maximizing both because that should be maximizing the objective as well. My optimizer with LR models does indeed maximize both these variables, but my optimizer with RF models does not and is perhaps getting stuck in a local optima. I tried warm starting Imbibition Water TA and Imbibition Water TB at their max values, but that did not help me find the global optima either. I assume it has to do with the nonlinear model having nondifferentiable points that mess up the gradient search from the optimizer?  Would appreciate some advice here if possible!

    0
  • Pierre Bonami
    Gurobi Staff Gurobi Staff

    Hi,

    To be sure, when you talk about the results for your optimizer with RF model, you are talking after the RF has been computed with sciki-learn.

    Is your problem solved to an optimal solution by Gurobi? Gurobi is not a local optimizer and is not doing gradient search so there shouldn't be any local optima issue in Gurobi. It should be a property of your RF estimator that you get a better output with input that is not maximizing both variables (is the output of your RF estimator the objective value?)

    0

Please sign in to leave a comment.