User Documentation

Example usage in Google Colab with Pyomo
Example usage in Jupyter Notebook with Pyomo
Example usage in AMPL with local installation

Let's take an example of an optimization problem:

Maximize 5.5x1 + 2.1x2
Subject to:
-x1 + x2 <= 2
8x1 + 2x2 <= 17
x1, x2 are integers

1 Set up for Google Colab environment

1.1 Download and set up Minotaur in your Google Colab environment:

!rm -f minotaur-0.4.1-linux-x86_64.tar.gz !wget -nc https://www.ieor.iitb.ac.in/files/faculty/amahajan/minotaur/bin/minotaur-0.4.1-linux-x86_64.tar.gz !tar -zxf minotaur-0.4.1-linux-x86_64.tar.gz !rm -f mbin !ln -s minotaur-0.4.1-linux-x86_64/bin mbin

If you prefer to use the latest nightly (unstable) version of Minotaur, use the following commands instead:

!rm -f minotaur-nightly.tar.gz !wget -nc https://www.ieor.iitb.ac.in/files/faculty/amahajan/minotaur/bin/minotaur-nightly.tar.gz !tar -zxf minotaur-nightly.tar.gz !rm -f mbin !ln -s minotaur-nightly mbin

1.2 Installing Pyomo

Install the Pyomo package using pip:

!pip install -q pyomo

1.3 Creating a Model

Here's how you can create this model in Pyomo:

from pyomo.environ import * model = ConcreteModel() model.x1 = Var(within=Integers) model.x2 = Var(within=Integers) model.obj = Objective(expr=5.5*model.x1 + 2.1*model.x2, sense=maximize) model.con1 = Constraint(expr=-model.x1 + model.x2 <= 2) model.con2 = Constraint(expr=8*model.x1 + 2*model.x2 <= 17)

1.4 Solving the Model

Use one of Minotaur's solvers (mbnb, mqg, mglob, mmultistart) to solve the model. Here, we use the 'mglob' solver:

mntr = SolverFactory("mglob", executable='/content/mbin/mglob') mntr.options['--log_level'] = 2 mntr.options['--time_limit'] = 60 mntr.options['--qp_engine'] = 'None' mntr.options['--nlp_engine'] = 'IPOPT' # Set tee to True if you want to see solver output result = mntr.solve(model, tee=False)

After solving the model, you can view the results with the following commands:

print("Solver termination status:", result.solver.status) print("Solver termination condition:", result.solver.termination_condition) print("Best solution value:", model.obj()) print("Best bound: ", result.problem.lower_bound) print("Solver time:", result.solver.time)

2 Set up for Jupyter Notebook

2.1 Download, extract Minotaur binaries and install Pyomo:

# First, download and extract Minotaur binaries !wget -nc https://www.ieor.iitb.ac.in/files/faculty/amahajan/minotaur/bin/minotaur-0.4.1-linux-x86_64.tar.gz !tar -zxf minotaur-0.4.1-linux-x86_64.tar.gz !ln -s minotaur-0.4.1-linux-x86_64/bin mbin # Install Pyomo !pip install -q pyomo

2.2 Create the optimization model in Pyomo:

from pyomo.environ import * model = ConcreteModel() model.x1 = Var(within=Integers) model.x2 = Var(within=Integers) model.obj = Objective(expr=5.5*model.x1 + 2.1*model.x2, sense=maximize) model.con1 = Constraint(expr=-model.x1 + model.x2 <= 2) model.con2 = Constraint(expr=8*model.x1 + 2*model.x2 <= 17)

2.3 Solve the model using Minotaur:

mntr = SolverFactory("mglob", executable='./mbin/mglob') mntr.options['--log_level'] = 2 mntr.options['--time_limit'] = 60 #mntr.options['--qp_engine'] = 'None' #mntr.options['--nlp_engine'] = 'IPOPT' result = mntr.solve(model, tee=True)

View the results:

print("Solver termination status:", result.solver.status) print("Solver termination condition:", result.solver.termination_condition) print("Best solution value:", model.obj()) print("Best bound: ", result.problem.lower_bound) print("Solver time:", result.solver.time)

3 Set up for AMPL

To use Minotaur with AMPL, follow the steps below:

First, ensure you have Minotaur and AMPL installed on your system. If minotaur not installed then download precompiled binaries from download section according to your machine.

Extract the download tar/zip, Open the extracted folder and navigate to bin folder.

Copy the four binaries/executables from bin folder to main Ampl folder that conatins other executables.

Create an optimization model in AMPL:

# AMPL Model (example.mod) var x1 integer; var x2 integer; maximize obj: 5.5*x1 + 2.1*x2; subject to con1: -x1 + x2 <= 2; subject to con2: 8*x1 + 2*x2 <= 17; display x1, x2, obj;

Then, use the following AMPL commands to set up and solve the model with Minotaur:

# AMPL Commands here we are using mglob solver model example.mod; #If minotaur already downloaded in your system then use following command option solver "/path/to/minotaur/build/bin/mglob"; #If binaries/executables are in Ampl main folder option solver mglob #To solve the problem solve; #To see output display x1, x2, obj;

Replace /path/to/minotaur/build/bin/mglob with the actual path to your Minotaur executable.