I've read the entire Mindtpy manual trying to understand how to install or use it, but I couldn't manage to install or use it. I tried similar things like "pip install mindtpy" or "import mindtpy". I also attempted to install other dependencies like IPOPT and GLPK, which Mindtpy requires, but still had no success. Please, I need assistance from someone who knows how to use it!
Specifically, I need to learn how to install and use Mindtpy in Visual Studio Code.
Thank you for your attention, I appreciate it.
mintdpy
is installed as a third-party contribution package when installing pyomo
, but it needs external solver to work.
If you install a new python environment and install pyomo
in it, you can already use mindtpy
as SolverFactory
Supossing you're using any unix-like system, open a terminal and type
pyomo
in it$ python -m venv .env
$ source .env/bin/activate
(.env) $ pip install pyomo==6.7.0
mindtpy
. first ipopt and then cbc$ sudo apt-get install coinor-libipopt-dev
$ sudo apt-get install coinor-cbc
$(.env) python main.py
# This is main.py
from pyomo.environ import *
model = ConcreteModel()
model.x = Var(bounds=(1.0,10.0),initialize=5.0)
model.y = Var(within=Binary)
model.c1 = Constraint(expr=(model.x-4.0)**2 - model.x <= 50.0*(1-model.y))
model.c2 = Constraint(expr=model.x*log(model.x)+5.0 <= 50.0*(model.y))
model.objective = Objective(expr=model.x, sense=minimize)
results = SolverFactory('mindtpy').solve(model, tee=True, mip_solver='cbc', nlp_solver='ipopt')
print(results)
This should give you the following output:
Starting MindtPy version 0.1.0 using OA algorithm
iteration_limit: 50
stalling_limit: 15
time_limit: 600
strategy: OA
add_regularization: None
call_after_main_solve: <pyomo.contrib.gdpopt.util._DoNothing object at 0x7f572970bca0>
call_after_subproblem_solve: <pyomo.contrib.gdpopt.util._DoNothing object at 0x7f572970bcd0>
call_after_subproblem_feasible: <pyomo.contrib.gdpopt.util._DoNothing object at 0x7f572970bd00>
tee: true
logger: <Logger pyomo.contrib.mindtpy (INFO)>
logging_level: 20
integer_to_binary: false
add_no_good_cuts: false
use_tabu_list: false
single_tree: false
solution_pool: false
num_solution_iteration: 5
cycling_check: true
feasibility_norm: L_infinity
differentiate_mode: reverse_symbolic
use_mcpp: false
calculate_dual_at_solution: false
use_fbbt: false
use_dual_bound: true
partition_obj_nonlinear_terms: true
quadratic_strategy: 0
move_objective: false
add_cuts_at_incumbent: false
heuristic_nonconvex: false
init_strategy: rNLP
level_coef: 0.5
solution_limit: 10
sqp_lag_scaling_coef: fixed
fp_cutoffdecr: 0.1
fp_iteration_limit: 20
fp_projcuts: true
fp_transfercuts: true
fp_projzerotol: 0.0001
fp_mipgap: 0.01
fp_discrete_only: true
fp_main_norm: L1
fp_norm_constraint: true
fp_norm_constraint_coef: 1.0
add_slack: false
max_slack: 1000.0
OA_penalty_factor: 1000.0
equality_relaxation: false
linearize_inactive: false
nlp_solver: ipopt
nlp_solver_args:
mip_solver: cbc
mip_solver_args:
mip_solver_mipgap: 0.0001
threads: 0
regularization_mip_threads: 0
solver_tee: false
mip_solver_tee: false
nlp_solver_tee: false
mip_regularization_solver: None
absolute_bound_tolerance: 0.0001
relative_bound_tolerance: 0.001
small_dual_tolerance: 1e-08
integer_tolerance: 1e-05
constraint_tolerance: 1e-06
variable_tolerance: 1e-08
zero_tolerance: 1e-08
obj_bound: 1000000000000000.0
continuous_var_bound: 10000000000.0
integer_var_bound: 1000000000.0
initial_bound_coef: 0.1
-----------------------------------------------------------------------------------------------
Mixed-Integer Nonlinear Decomposition Toolbox in Pyomo (MindtPy)
-----------------------------------------------------------------------------------------------
For more information, please visit
https://pyomo.readthedocs.io/en/stable/contributed_packages/mindtpy.html
If you use this software, please cite the following:
Bernal, David E., et al. Mixed-integer nonlinear decomposition toolbox for Pyomo (MindtPy).
Computer Aided Chemical Engineering. Vol. 44. Elsevier, 2018. 895-900.
Original model has 2 constraints (2 nonlinear) and 0 disjunctions, with 2 variables, of which 1 are binary, 0 are integer, and 1 are continuous.
rNLP is the initial strategy being used.
===============================================================================================
Iteration | Subproblem Type | Objective Value | Primal Bound | Dual Bound | Gap | Time(s)
- Relaxed NLP 1 inf 1 nan% 0.04
1 MILP 1 inf 1 nan% 0.07
NLP subproblem was locally infeasible.
Solving feasibility problem
2 MILP 1 inf 1 nan% 0.14
* 2 Fixed NLP 2.43845 2.43845 1 58.99% 0.18
3 MILP 2.43845 2.43845 2.43845 -0.00% 0.20
MindtPy exiting on bound convergence. Absolute gap: -1.2729224785346105e-08 <= absolute tolerance: 0.0001
===============================================================================================
Primal integral : 0.0000
Dual integral : 0.2073
Primal-dual gap integral : 0.2073