How can I get the properties of a Gurobi's Presolve model? - gurobi

I have an integer programming problem with linear objective function and some quadratic constraints. When I use Gurobi to solve this problem, Gurobi uses Presolve to create a Quadratically Constrained Integer Programming model. Now, I would like to know if the objective function of the Presolve model is quadratic too.
Thanks in advance.

Gurobi will give you the presolved model with the method presolve on the model object. That object is a regular model object and you can query its attributes. The attribute isQCP is true if there are any quadratic constraints. The attribute isQP indicates that the model has a quadratic objective, but no quadratic constraints. The attribute NumQConstrs is a count of the number of quadratic constraints.
You can also use the printStats method to print the numbers or you could use the write method to write the presolved model to a file.
presolved_model = model.presolve()
print(presolved_model.IsQCP)
print(presolved_model.IsQP)
presolved_model.printStats()
presolved_model.write("presolved.lp")

Related

How to solve this quadratic optimization problem

My problem is described in this picture(It's like a Pyramid structure):
The objective function is below:
In this problem, D is known, A is the object that I want to get. It is a layered structure, each block in the upper layer is divided into four sub-blocks in the layer below. And the value of the upper layer node is equal to the sum of the four child nodes of the lower layer. In above example, I used only 2 layers.
What I want to do is simulate the distribution of D with A, so in the objective function is the ratio of two adjacent squares in each row in A compared to the value in D. I do this comparison on each layer and sum them. Then it is all of my objective function. But in the finest layer, the value in A has a constrain A<=1, the value in A can be a number between 0 and 1. I have tried to solve it using Quadratic programming in python library CVXPY. However, it seems the speed is slow.
So I want to solve it in another way, because this is a convex optimization problem, which can guarantee the global optimal solution. What I think is whether it is possible to use the method of derivation. There are two unknown variables in each item, that is, the two items with A in the formula. Partial derivatives are obtained for them, and the restriction of A<=1 is added, then solve using gradient descent method. Is this mathematically feasible, because I don't know much about optimization, and if it is possible, how should I do it? If not possible, what other methods can I use?

What is the most reliable method to optimize linear objective function with nonlinear constraints and Why?

I currently solve the following problem:
Basically, this problem is equivalent to find the confidence interval for logistic regression. The objective function is linear (no second derivative), meanwhile, the constraint is non-linear. Specifically, I used n = 1, alpha = 0.05, theta = logit of p where p = [0,1] (for detail, please see binomial distribution). Thus, I have a closed-form solution for the gradient and jacobian for objective and constraints respectively.
In R, I first tried the alabama::auglag function which used augmented Lagrangian method with BFGS (as a default) and nloptr::auglag function which used augmented Lagrangian method with SLSQP (i.e. SLSQP as a local minimizer). Although they were able to find the (global) minimizer most time, sometimes they failed and produced a far-off solution.
After all, I could obtain the best (most stable) result using SLSQP method (nloptr::nloptr with algorithm=NLOPT_LD_SLSQP).
Now, I have a question of why SLSQP produced better result in this setting than the first two methods and why the first two methods (augmented Lagrangian with BFGS and SLSQP as a local optimizer) did not perform well.
Another question is, considering my problem setting, what would be the best method to find the optimizer?
Any comments and suggestions would be much appreciated.
Thanks.

Can I use a lookup table instead of a 5 degree polynomial equation between three variables in a non-linear optimization model?

I am having a non-linear optimization model with several variables and a certain function between three of them should be defined as a constraint. (Let us say, that the efficiency of a machine is dependent on the inlet and outlet temperatures). I have calculated some values in a table to visualize the dependency for T_inlets and T_outlets. It gives back a pretty ugly surface. A good fit would be something like a 5 degree polynomial equation if I wanted to define a function directly, but I do not think that would boost my computation speed... So instead I am considering simply having the created table and use it as a lookup table. Is a non-linear solver able to interpret this? I am using ipopt in Pyomo environment.
Another idea would be to limit my feasible temperature range and simplify the connection...maybe with using peace-wise linearization. Is it doable with 3d surfaces?
Thanks in advance!

what is the exact meaning of "First LP value" in SCIP solver, for a nonlinear convex model

I have solved using SCIP a convex mathematical model with binary variables, linear Objective function and a set of linear constraints amended with a single non-linear constraint making the model as a non-linear binary problem.
In the output file provided by SCIP, there is a term named as: First LP value and a value has been assigned to. I cannot figure out what is exactly the meaning of First LP value for my specific nonlinear problem ?? I appreciate any explanation in detail.
For solving nonlinear problems, SCIP solves linear programming relaxations (LPs) that describe an outer approximation of the feasible region. The first LP value is the value of the optimal solution to the initial LP that was solved at the root node, after presolving, but before any separation.

Solving one-zero linear programming

I have a model about one-zero linear programming, when I use AMPL, I declare variables as binary type, but when I solved it, my results have many numbers not is 0,1.
var X{1..7,1..21,1..4} binary;
I think the type of variable: integer, binary not doing in AMPL
When I solved it, my results such as: X[1,5,6]=0.55555.
You should use a mixed-integer programming solver such as CPLEX or Gurobi to get an integer solution. The default AMPL solver is MINOS which relaxes integrality and issues a warning such as:
MINOS 5.51: ignoring integrality of 10 variables