How to set solver parameters in mindtpy?

1,142 views
Skip to first unread message

shansha...@gmail.com

unread,
Mar 4, 2021, 11:48:36 AM3/4/21
to Pyomo Forum
Hi, 

I found the mindtpy has two kinds of solver, mip solver and nlp solver. How can I set the time limit or other parameters for the mip solver inside the mindtpy? 

Sincerely,

Shanshan 

berna...@gmail.com

unread,
Mar 5, 2021, 1:12:44 AM3/5/21
to Pyomo Forum
Hi Shanshan,
thank you for being interested in MindtPy! Indeed this solver relies on subsolvers for MILP and NLP subproblems. We know that users want to pass down options to these solvers, therefore under the arguments "mip_solver_args" and "nlp_solver_args" are designed for that end, where you pass dictionaries with these options.
An example would be to do something along the lines of 
from pyomo.environ import SolverFactory
model = YOUR_MINLP_MODEL
opt = SolverFactory('mindtpy')
opt.solve(model, strategy='OA',
                      mip_solver=glpk, #or any MILP solver such as Gurobi, CPLEX, CBC, ...
                      nlp_solver=ipopt, #or other NLP solvers such as BARON
                      mip_solver_args={'timelimit': 100},  
                      nlp_solver_args={ 'nlp_scaling_method':'user-scaling'}
                      )

Cheers,
David

shansha...@gmail.com

unread,
Mar 6, 2021, 2:44:26 AM3/6/21
to Pyomo Forum
Hi David,

Thanks for your reply. I met another problem. When I was using the mindtpy to solve a minlp problem. The algorithm will end at solving the master MIP problem with similar errors as following after several iterations:

Numeric value `0.8680779209067118` (<class 'float'>) is not in domain Binary for Var Q[2396,1,1].MC_bin_y[1] 

and the value of LB is larger than the UB value. 

As I know that the master MIP problem is solving the problem with the first-order Tylor extension of the nonlinear constraint.  I am not sure why the MIP problem result will violate the variable's domain. 

Sincerely,

Shanshan

berna...@gmail.com

unread,
Mar 7, 2021, 2:28:15 AM3/7/21
to Pyomo Forum
Hi Shanshan,
it is hard to understand where the error is coming from without knowing the model and by only seeing one line of output.
It seems as if the MIP solver is unable to find a solution that satisfies the discretenes of the variable Q[2396,1,1].MC_bin_y[1]  definition (0.86 =/= 1 or 0).
You should look at the MIP solver output to see if the mistake is happening at that level.
I would recommend you to use the option "solver_tee=True" in order to see the output in the subsolvers on the screen.
Best,
David

shansha...@gmail.com

unread,
Mar 8, 2021, 2:25:35 AM3/8/21
to Pyomo Forum
Hi David,

Thanks for your short answer. I have solved this problem by revising my model. I have another question on Mindtpy. How can mindtpy guarantee optimality? For my problem, the mindtpy will stop when the LB is larger than UB. 

Sincerely,

Shanshan 

David Bernal

unread,
Mar 8, 2021, 9:41:24 AM3/8/21
to pyomo...@googlegroups.com

Hi Shanshan,

MindtPy currently implements methods for guaranteeing optimality in both convex and nonconvex MINLP problems, depending on the algorithm that you are using. We can modify the algorithm by the option “strategy” where “OA” is the default. The strategies “OA” and “ECP”, which stand for Outer approximation and extended cutting planes respectively, have convergence guarantees for convex MINLP problems. The strategy “GOA”, which stand for global outer approximation” implements methods that guarantee convergence for nonconvex MINLP problems. Be aware that GOA requires you to download and install MC++ in your system https://pyomo.readthedocs.io/en/stable/contributed_packages/mcpp.html , and that the NLP subproblems need to be solved to global optimality (using solvers such as BARON or SCIP) to actually provide you with a global optimal solution. Usually the methods for convex MINLP are used as heuristics for nonconvex MINLP, with decent performance in practice (let me shamelessly plug a link to this review paper on convex MINLP https://link.springer.com/article/10.1007/s11081-018-9411-8 )

I hope this helps!

 

Best regards,

 

David E. Bernal

--
You received this message because you are subscribed to a topic in the Google Groups "Pyomo Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyomo-forum/TPiBKltDrq4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyomo-forum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/42c7123b-cf1e-42bb-b7e6-111046e09292n%40googlegroups.com.

 

shansha...@gmail.com

unread,
Mar 8, 2021, 12:37:28 PM3/8/21
to Pyomo Forum
Hi David,

Thanks for your patient reply again. I have tried all the strategies you mentioned using gurobi as milp solver and ipopt as nlp solver. When I was using the GOA strategy, my model was easily sticking at the first iteration of the master MILP problem and hard to converge. For OA strategy, I can get solution but I don't think it is an optimal solution. Maybe there is still something wrong with my model. I will try to use Baron or SCIP as NLP solver. 

Sincerely,

Shanshan

shansha...@gmail.com

unread,
Apr 19, 2021, 2:15:38 PM4/19/21
to Pyomo Forum
Hi David,

I found one issue for Mindtpy. Once I used   mip_solver_args={'mipgap': 0.005} for setting parameter for MILP subproblem, there is always an error: 
ValueError: ProblemWriter_cpxlp passed unrecognized io_options:
add_options = ['option mipgap=0.005;']
It seems that Mindtpy cannot set parameters for sub solvers. 

Sincerely,

Shanshan

在2021年3月4日星期四 UTC-7 下午11:12:44<berna...@gmail.com> 写道:

Peng Zedong

unread,
May 4, 2022, 5:14:57 AM5/4/22
to Pyomo Forum
Hi Shanshan,

MindtPy provides you the mip_solver_mipgap configuration to set mipgap for MIP solvers.
For example:
result = SolverFactory('mindtpy').solve(model,
                                                                      mip_solver='cplex',
                                                                      mip_solver_mipgap=0.001,
                                                                      tee=True)

L T

unread,
Jan 5, 2023, 9:07:20 AM1/5/23
to Pyomo Forum
Hello,
i have a questions concerning setting subsolver options in mindty. I want to set the iteration limit of the subsolver ipopt. But it seems like this options is not possible. I tried it with this code:
result = opt.solve(model, strategy='OA', init_strategy='FP', iteration_limit=1000000, time_limit=36000,
                   mip_solver='cplex', add_no_good_cuts=True, heuristic_nonconvex=True, mip_solver_args={'timelimit': 36000, 'warmstart': True}, mip_solver_mipgap=0.001,
                   nlp_solver='ipopt', nlp_solver_args={'timelimit': 36000, 'maxiter':10000}, tee=True, mip_solver_tee=True, nlp_solver_tee=True)

Setting timelimit does work. I also tried iteration_limit instead of maxiter. I always get this error: ValueError: ProblemWriter_nl passed unrecognized io_options:
    maxiter = 10000

Thank you very much in advance

Peng Zedong

unread,
Jan 6, 2023, 8:55:28 PM1/6/23
to Pyomo Forum

Hi,

In MindtPy, nlp_solver_args are set as the following,
SolverFactory('ipopt').solve(model, **nlp_solver_args). 

Solver-specific options should be passed through solver.options.

result = opt.solve(model, strategy='OA', init_strategy='FP', iteration_limit=1000000, time_limit=36000,
mip_solver='cplex', add_no_good_cuts=True, heuristic_nonconvex=True, mip_solver_args={'timelimit': 36000, 'warmstart': True}, mip_solver_mipgap=0.001,
nlp_solver='ipopt', nlp_solver_args={'timelimit': 36000, 'options':{'max_iter':10000}}, tee=True, mip_solver_tee=True, nlp_solver_tee=True)


Hope this helps.
Reply all
Reply to author
Forward
0 new messages