-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.html
304 lines (280 loc) · 12.5 KB
/
doc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minotaur Documentation</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="style2.css">
<link rel="stylesheet" href="doc.css">
<style>
.highlight {
color: blue;
text-decoration: underline;
}
.clickable-link {
color: inherit;
text-decoration: none;
}
</style>
</head>
<body>
<header>
<div class="navbar">
<div class="logo"></div>
<div class="nav-buttons">
<div class="hamburger" onclick="toggleMenu()">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
<a href="index.html">
<button class="documentation-button">Home</button>
</a>
<a href="downloads.html">
<button class="documentation-button">Installation</button>
</a>
<a href="doc.html">
<button style="color: rgb(0, 0, 0);" class="documentation-button">User Guide</button>
</a>
<a href="https://www.ieor.iitb.ac.in/files/faculty/amahajan/minotaur/nightly/origin/html/index.html">
<button class="documentation-button">Developers Docs</button>
</a>
<!-- <a href="doc.html">
<button class="documentation-button" style="color: rgb(0, 0, 0);">Documentation</button>
</a> -->
<a href="https://www.github.com/coin-or/minotaur">
<button class="documentation-button">Source Code</button>
</a>
</div>
</div>
</header>
<section class="links" id="extra">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="downloads.html">Installation</a></li>
<li>
<a href="doc.html">User Guide</a>
</li>
<li>
<a href="https://www.ieor.iitb.ac.in/files/faculty/amahajan/minotaur/nightly/origin/html/index.html">Developers Docs</a>
</li>
<!-- <li><a href="doc.html">Documentation</a></li> -->
<li><a href="https://www.github.com/minotaur-solver/minotaur">Source Code</a></li>
<li onclick="toggleMenu()"><a href="#">Close</a></li>
</ul>
</section>
<div class="container">
<section id="user-documentation">
<h2>User Documentation</h2>
<p>
Example usage in <a href="#setup"><span class="highlight">Google Colab</span></a> with Pyomo<br>
Example usage in <a href="#minotaur-jupyter"><span class="highlight">Jupyter Notebook</span></a> with Pyomo<br>
Example usage in <a href="#minotaur-ampl"><span class="highlight">AMPL</span></a> with local installation
</p>
</section>
<p>Let's take an example of an optimization problem:</p>
<div class="code-block">
<code>
Maximize 5.5x<sub>1</sub> + 2.1x<sub>2</sub><br>
Subject to:<br>
-x<sub>1</sub> + x<sub>2</sub> <= 2<br>
8x<sub>1</sub> + 2x<sub>2</sub> <= 17<br>
x<sub>1</sub>, x<sub>2</sub> are integers
</code>
</div>
<section id="setup">
<h3>1 Set up for Google Colab environment</h3>
<h4> 1.1 Download and set up Minotaur in your Google Colab environment:</h4>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('setup-code')">Copy</button>
<code id="setup-code">
!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
</code>
</div>
<p>If you prefer to use the latest nightly (unstable) version of Minotaur, use the following commands instead:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('nightly-code')">Copy</button>
<code id="nightly-code">
!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
</code>
</div>
</section>
<section id="installing-pyomo">
<h4>1.2 Installing Pyomo</h4>
<p>Install the Pyomo package using pip:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('install-pyomo')">Copy</button>
<code id="install-pyomo">
!pip install -q pyomo
</code>
</div>
</section>
<section id="creating-model">
<h4>1.3 Creating a Model</h4>
<p>Here's how you can create this model in Pyomo:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('create-model')">Copy</button>
<code id="create-model">
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)
</code>
</div>
</section>
<section id="solving-model">
<h4>1.4 Solving the Model</h4>
<p>Use one of Minotaur's solvers (mbnb, mqg, mglob, mmultistart) to solve the model. Here, we use the 'mglob' solver:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('solve-model')">Copy</button>
<code id="solve-model">
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)
</code>
</div>
</section>
<section id="viewing-results">
<p>After solving the model, you can view the results with the following commands:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('view-results')">Copy</button>
<code id="view-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)
</code>
</div>
</section>
<section id="minotaur-jupyter">
<h3>2 Set up for Jupyter Notebook</h3>
<h4>2.1 Download, extract Minotaur binaries and install Pyomo:</h4>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('jupyter-setup')">Copy</button>
<code id="jupyter-setup">
# 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
</code>
</div>
<h4>2.2 Create the optimization model in Pyomo:</h4>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('jupyter-model')">Copy</button>
<code id="jupyter-model">
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)
</code>
</div>
<h4>2.3 Solve the model using Minotaur:</h4>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('jupyter-solve')">Copy</button>
<code id="jupyter-solve">
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)
</code>
</div>
<p>View the results:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('jupyter-results')">Copy</button>
<code id="jupyter-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)
</code>
</div>
</section>
<section id="minotaur-ampl">
<h3>3 Set up for AMPL</h3>
<p>To use Minotaur with AMPL, follow the steps below:</p>
<p> 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. </p>
<p>Extract the download tar/zip, Open the extracted folder and navigate to bin folder.</p>
<p>Copy the four binaries/executables from bin folder to main Ampl folder that conatins other executables.</p>
<p>Create an optimization model in AMPL:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('ampl-model')">Copy</button>
<code id="ampl-model">
# 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;
</code>
</div>
<p>Then, use the following AMPL commands to set up and solve the model with Minotaur:</p>
<div class="code-block">
<button class="copy-button" onclick="copyToClipboard('ampl-setup')">Copy</button>
<code id="ampl-setup">
# 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;
</code>
</div>
<p>Replace <code>/path/to/minotaur/build/bin/mglob</code> with the actual path to your Minotaur executable.</p>
</section>
</section>
</div>
</section>
<footer class="footer">
<a name="license"></a>
<div class="license" >
<h2>License</h2>
<p>Minotaur is free to use, modify, and redistribute without any restrictions.<br> <a href='https://minotaur-solver.github.io/LICENSE.txt'>see the license for details </a></p>
</div>
<div class="contact" style="margin-left: 4%;">
<h2>Contact</h2>
<p>Queries about using the software may be addressed to the <a href="https://lists.mcs.anl.gov/mailman/listinfo/minotaur" >Minotaur mailing list</a>. <br>Other queries can be made to Ashutosh Mahajan, amahajan [at] iitb.ac.in</p>
</div>
</footer>
<script>
const toggleMenu = () => {
const extra = document.getElementById('extra');
if (extra.style.display === "block") {
extra.style.display = "none";
} else {
extra.style.display = "block";
}
}
</script>
</body>
</html>