source: html/use.html @ 1586

Last change on this file since 1586 was 1586, checked in by pbonami, 10 years ago

Two typos in links

File size: 15.1 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
2  "http://www.w3.org/TR/html4/loose.dtd"> 
3<html > 
4<head><title></title> 
5<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
6<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> 
7<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> 
8<!-- html --> 
9<meta name="src" content="tmp.tex"> 
10<meta name="date" content="2010-01-23 16:47:00"> 
11<link rel="stylesheet" type="text/css" href="bonmin.css"> 
12</head><body 
13>
14<!--l. 2--><p class="noindent" ><div id="header">   <h1 id="siteName"><TT> <big> BONMIN </big> </tt> Users' Manual</h1>   <div id="globalNav">   <a href="Intro.html">Introduction</a> |   <a href="Obtain.html">Download</a> |  <a href="Install.html">Install</a> |   <a href="use.html">Use</a> |   <a href="options_set.html">Setting Options</a> |   <a href="options_list.html">Options List</a> |   <a href="bib.html">Bibliography</a> |  </div>   </div>  <div id="leftPanel"> <div id="side-bar">  <ul> <li class="main"><a href="/Bonmin/index.html">Bonmin</a></li>  <li><a href="https://projects.coin-or.org/Bonmin">Wiki</a></li>   <li><a href="http://neos.mcs.anl.gov/neos/solvers/minco:Bonmin/AMPL.html"> NEOS </a> </li>  <li><a href="http://egon.cheme.cmu.edu/ibm/page.htm">IBM-CMU OCR </a></li>  <li><a href="http://domino.research.ibm.com/comm/research_projects.nsf/pages/minlp.index.html">  IBM MINLP </a></li>  <br>  <br>  <li class="main"><a href="/index.html">COIN-OR Home</a></li>  <li><a href="/projects.html">Projects</a></li>  <li><a href="/faqs.html">FAQs</a></li>   <li><a href="/download.html">Download</a></li>  <li><a href="/mail.html">Mailing Lists</a></li>  <li><a href="/how-to-help.html">Get Involved</a></li>  <li><a href="/resources.html">Related Resources</a></li>  <li class="main"><a href="/foundation.html">  <br>  <br>  COIN-OR Foundation  </a></li>   <li><a href="/events.html">Events</a></li>  <li><a href="/members.html">Members</a></li>  </ul>  </div> </div> <!--end navBar div -->  <br>   <h2 id="pageName"> Running <span 
15class="cmtt-10">BONMIN </span> </h2> <a href="#sec:run&#x02D9;nl " > On an .nl file  </a> /
16<a href="#sec:run&#x02D9;ampl " > From Ampl  </a> / <a href="#sub&#x02D9;sec:prio " > priorities and SOS in Ampl  </a> /
17<a href="#sec:run&#x02D9;gams " > From GAMS  </a> / <a href="#sec:run&#x02D9;cpp " > From a C++ Programm  </a> /   </div> 
18<!--l. 11--><p class="noindent" > <div id="rightPanel"> <div id="headlines"> <h4>References </h4>     <div id="refer"> <p>  1 <a 
19href="../bib/index.html#Gay" >Writing <span 
20class="cmbx-10">.nl </span>files. D.M.&#x00A0;Gay.</a>  </p> </div>       <div id="refer"> <p>  2 <a 
21href="../bib/index.html#AMPL" >AMPL: A Modeling Language for
22Mathematical Programming, Second Edition, Duxbury Press Brooks Cole
23Publishing Co., 2003. R.&#x00A0;Fourer and D.M.&#x00A0;Gay and B.W.&#x00A0;Kernighan.</a>  </p> </div>     </div> </div> 
24<!--l. 18--><p class="noindent" > </div> <div id="content"> <div class="feature"> <h3> Running <span 
25class="cmtt-10">BONMIN </span></h3> <span 
26class="cmtt-10">BONMIN</span>&#x00A0;can be run
27     <ul class="itemize1">
28     <li class="itemize">from a command line on a <span 
29class="cmtt-10">.nl </span>file (see  <a href=&#8221;bib.html#Gay&#8221; > [Gay2005]</a> ),
30     </li>
31     <li class="itemize">from the modeling language <a 
32href="http://www.ampl.com" ><span 
33class="cmtt-10">Ampl</span></a> (see  <a href=&#8221;bib.html#AMPL&#8221; > [Fourrer2003]</a>
34     ),
35     </li>
36     <li class="itemize">from the <a 
37href="http://www.gams.com/" >Gams</a> modeling language,
38     </li>
39     <li class="itemize">by invoking it from a C/C++ program.
40     </li>
41     <li class="itemize">remotely through the <a 
42href="http://neos.mcs.anl.gov/neos" >NEOS</a> web interface.</li></ul>
43<!--l. 30--><p class="indent" >   In this page, we give some details about the various ways to run <span 
44class="cmtt-10">BONMIN</span>.
45<!--l. 33--><p class="indent" >    </div> <div class="story"> <h3><a name=  &#8221;sec:run&#x02D9;nl&#8221; ></a> On a <span 
46class="cmtt-10">.nl </span>file  </h3>   <span 
47class="cmtt-10">BONMIN</span>&#x00A0;can read a <span 
48class="cmtt-10">.nl </span>file which could be
49generated by <span 
50class="cmtt-10">Ampl </span>(for example <span 
51class="cmtt-10">mytoy.nl </span>in the <span 
52class="cmtt-10">Bonmin-dist/Bonmin/test</span>
53subdirectory). The command line takes just one argument which is the name of the
54<span 
55class="cmtt-10">.nl </span>file to be processed.
56<!--l. 40--><p class="indent" >   For example, if you want to solve <span 
57class="cmtt-10">mytoy.nl</span>, from the <span 
58class="cmtt-10">Bonmin-dist </span>directory,
59issue the command:
60<!--l. 43--><p class="indent" >   <div id="verbatim">
61
62   <table 
63class="verbatim"><tr class="verbatim"><td 
64class="verbatim"><div class="verbatim">
65&#x00A0;<br />bonmin&#x00A0;test/mytoy.nl
66&#x00A0;<br />
67</div>
68</td></tr></table>
69<!--l. 48--><p class="nopar" > </div> 
70<!--l. 51--><p class="indent" >    </div> <div class="story"> <h3><a name=  &#8221;sec:run&#x02D9;ampl&#8221; ></a> From <span 
71class="cmtt-10">Ampl </span> </h3>  To use <span 
72class="cmtt-10">BONMIN</span>&#x00A0;from <span 
73class="cmtt-10">Ampl </span>you just need to have
74the directory where the <span 
75class="cmtt-10">bonmin </span>executable is in your <span 
76class="cmtt-10">$PATH </span>and to issue the
77command
78<!--l. 56--><p class="indent" >   <div id="verbatim">
79
80   <table 
81class="verbatim"><tr class="verbatim"><td 
82class="verbatim"><div class="verbatim">
83&#x00A0;<br />option&#x00A0;solver&#x00A0;bonmin;
84&#x00A0;<br />
85</div>
86</td></tr></table>
87<!--l. 61--><p class="nopar" > </div> 
88<!--l. 64--><p class="indent" >   in the <span 
89class="cmtt-10">Ampl </span>environment. Then the next <span 
90class="cmtt-10">solve </span>will use <span 
91class="cmtt-10">BONMIN</span>&#x00A0;to solve the
92model loaded in <span 
93class="cmtt-10">Ampl</span>. After the optimization is finished, the values of the variables in
94the best-known or optimal solution can be accessed in <span 
95class="cmtt-10">Ampl</span>. If the optimization is
96interrupted with <span 
97class="cmtt-10">&#x003C;CTRL-C&#x003E; </span>the best known solution is accessible (this feature is not
98available in Cygwin).
99<br class="newline" />
100<!--l. 71--><p class="indent" >    </div> <div class="story"> <h3><a name=  &#8221;A&#8221; ></a> Example <span 
101class="cmtt-10">Ampl </span>model  </h3>   simple <span 
102class="cmtt-10">Ampl </span>example model follows:
103<!--l. 73--><p class="indent" >   <div id="verbatim">
104
105   <table 
106class="verbatim"><tr class="verbatim"><td 
107class="verbatim"><div class="verbatim">
108&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;#&#x00A0;An&#x00A0;Ampl&#x00A0;version&#x00A0;of&#x00A0;toy
109&#x00A0;<br />
110&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;reset;
111&#x00A0;<br />
112&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;var&#x00A0;x&#x00A0;binary;
113&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;var&#x00A0;z&#x00A0;integer&#x00A0;&#x003E;=&#x00A0;0&#x00A0;&#x003C;=&#x00A0;5;
114&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;var&#x00A0;y{1..2}&#x00A0;&#x003E;=0;
115&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;minimize&#x00A0;cost:
116&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;-&#x00A0;x&#x00A0;-&#x00A0;y[1]&#x00A0;-&#x00A0;y[2]&#x00A0;;
117&#x00A0;<br />
118&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;subject&#x00A0;to
119&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;c1:&#x00A0;(&#x00A0;y[1]&#x00A0;-&#x00A0;1/2&#x00A0;)^2&#x00A0;+&#x00A0;(y[2]&#x00A0;-&#x00A0;1/2)^2&#x00A0;&#x003C;=&#x00A0;1/4&#x00A0;;
120&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;c2:&#x00A0;x&#x00A0;-&#x00A0;y[1]&#x00A0;&#x003C;=&#x00A0;0&#x00A0;;
121&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;c3:&#x00A0;x&#x00A0;+&#x00A0;y[2]&#x00A0;+&#x00A0;z&#x00A0;&#x003C;=&#x00A0;2;
122&#x00A0;<br />
123&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;option&#x00A0;solver&#x00A0;bonmin;&#x00A0;#&#x00A0;Choose&#x00A0;BONMIN&#x00A0;as&#x00A0;the&#x00A0;solver&#x00A0;(assuming&#x00A0;that
124&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;#&#x00A0;bonmin&#x00A0;is&#x00A0;in&#x00A0;your&#x00A0;PATH
125&#x00A0;<br />
126&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;solve;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;#&#x00A0;Solve&#x00A0;the&#x00A0;model
127&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;display&#x00A0;x;
128&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;display&#x00A0;y;
129&#x00A0;<br />
130</div>
131</td></tr></table>
132<!--l. 98--><p class="nopar" > </div> 
133<!--l. 101--><p class="indent" >   (This example can be found in the subdirectory <span 
134class="cmtt-10">Bonmin/examples/amplExamples/</span>
135of the <span 
136class="cmtt-10">BONMIN</span>&#x00A0;package.)
137<!--l. 104--><p class="indent" >    </div> <div class="story"> <h3><a name=  &#8221;sub&#x02D9;sec:prio&#8221; ></a> Setting up branching priorities, directions and declaring SOS1
138constraints in ampl  </h3>   Branching priorities, branching directions and pseudo-costs can
139be passed using <span 
140class="cmtt-10">Ampl </span>suffixes. The suffix for branching priorities is <span 
141class="cmtt-10">"priority"</span>
142(variables with a higher priority will be chosen first for branching), for branching
143direction is <span 
144class="cmtt-10">"direction" </span>(if direction is 1 the <span 
145class="cmsy-10">&#x2265; </span>branch is explored first, if direction
146is <span 
147class="cmsy-10">-</span>1 the <span 
148class="cmsy-10">&#x2264; </span>branch is explored first), for up and down pseudo costs <span 
149class="cmtt-10">"upPseudoCost"</span>
150and <span 
151class="cmtt-10">"downPseudoCost" </span>respectively (note that if only one of the up and
152down pseudo-costs is set in the <span 
153class="cmtt-10">Ampl </span>model it will be used for both up and
154down).
155<br class="newline" />
156<!--l. 114--><p class="indent" >   For example, to give branching priorities of 10 to variables <span 
157class="cmtt-10">y </span>and 1 to variable <span 
158class="cmtt-10">x</span>
159and to set the branching directions to explore the upper branch first for
160all variables in the simple example given, we add before the call to solve:
161<div id="verbatim">
162
163   <table 
164class="verbatim"><tr class="verbatim"><td 
165class="verbatim"><div class="verbatim">
166&#x00A0;<br />suffix&#x00A0;priority&#x00A0;IN,&#x00A0;integer,&#x00A0;&#x003E;=0,&#x00A0;&#x003C;=&#x00A0;9999;
167&#x00A0;<br />y[1].priority&#x00A0;:=&#x00A0;10;
168&#x00A0;<br />y[2].priority&#x00A0;:=&#x00A0;10;
169&#x00A0;<br />x.priority&#x00A0;:=&#x00A0;1;
170&#x00A0;<br />
171&#x00A0;<br />suffix&#x00A0;direction&#x00A0;IN,&#x00A0;integer,&#x00A0;&#x003E;=-1,&#x00A0;&#x003C;=1;
172&#x00A0;<br />y[1].direction&#x00A0;:=&#x00A0;1;
173&#x00A0;<br />y[2].direction&#x00A0;:=&#x00A0;1;
174&#x00A0;<br />x.direction&#x00A0;:=&#x00A0;1;
175&#x00A0;<br />
176</div>
177</td></tr></table>
178<!--l. 130--><p class="nopar" > </div> 
179<!--l. 133--><p class="indent" >   SOS Type-1 branching is also available in <span 
180class="cmtt-10">BONMIN</span>&#x00A0;from <span 
181class="cmtt-10">Ampl</span>. We follow the
182conventional way of doing this with suffixes. Two type of suffixes should be
183declared:
184<!--l. 137--><p class="indent" >   <div id="verbatim">
185
186   <table 
187class="verbatim"><tr class="verbatim"><td 
188class="verbatim"><div class="verbatim">
189suffix&#x00A0;sosno&#x00A0;IN,&#x00A0;integer,&#x00A0;&#x003E;=1;&#x00A0;&#x00A0;#&#x00A0;Note&#x00A0;that&#x00A0;the&#x00A0;solver&#x00A0;assumes&#x00A0;that&#x00A0;these
190&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;#&#x00A0;&#x00A0;&#x00A0;values&#x00A0;are&#x00A0;positive&#x00A0;for&#x00A0;SOS&#x00A0;Type&#x00A0;1
191&#x00A0;<br />suffix&#x00A0;ref&#x00A0;IN;
192</div>
193</td></tr></table>
194<!--l. 142--><p class="nopar" > </div> 
195<!--l. 145--><p class="indent" >   Next, suppose that we wish to have variables
196<!--l. 147--><p class="indent" >   <div id="verbatim">
197
198   <table 
199class="verbatim"><tr class="verbatim"><td 
200class="verbatim"><div class="verbatim">
201var&#x00A0;X&#x00A0;{i&#x00A0;in&#x00A0;1..M,&#x00A0;j&#x00A0;in&#x00A0;1..N}&#x00A0;binary;
202</div>
203</td></tr></table>
204<!--l. 150--><p class="nopar" > </div> 
205and the &#8220;convexity&#8221; constraints:
206<!--l. 154--><p class="indent" >   <div id="verbatim">
207
208   <table 
209class="verbatim"><tr class="verbatim"><td 
210class="verbatim"><div class="verbatim">
211subject&#x00A0;to&#x00A0;Convexity&#x00A0;{i&#x00A0;in&#x00A0;1..M}:
212&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;sum&#x00A0;{j&#x00A0;in&#x00A0;1..N}&#x00A0;X[i,j]&#x00A0;=&#x00A0;1;
213</div>
214</td></tr></table>
215<!--l. 158--><p class="nopar" > </div> 
216<!--l. 161--><p class="indent" >   (note that we must explicitly include the convexity constraints in the <span 
217class="cmtt-10">Ampl</span>
218model).
219<!--l. 163--><p class="indent" >   Then after reading in the data, we set the suffix values: <div id="verbatim">
220
221   <table 
222class="verbatim"><tr class="verbatim"><td 
223class="verbatim"><div class="verbatim">
224&#x00A0;<br />#&#x00A0;The&#x00A0;numbers&#x00A0;&#8216;val[i,j]&#8217;&#x00A0;are&#x00A0;chosen&#x00A0;typically&#x00A0;as
225&#x00A0;<br />#&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;the&#x00A0;values&#x00A0;&#8216;represented&#8217;&#x00A0;by&#x00A0;the&#x00A0;discrete&#x00A0;choices.
226&#x00A0;<br />let&#x00A0;{i&#x00A0;in&#x00A0;1..M,&#x00A0;j&#x00A0;in&#x00A0;1..N}&#x00A0;X[i,j].ref&#x00A0;:=&#x00A0;val[i,j];
227&#x00A0;<br />
228&#x00A0;<br />#&#x00A0;These&#x00A0;identify&#x00A0;which&#x00A0;SOS&#x00A0;constraint&#x00A0;each&#x00A0;variable&#x00A0;belongs&#x00A0;to.
229&#x00A0;<br />let&#x00A0;{i&#x00A0;in&#x00A0;1..M,&#x00A0;j&#x00A0;in&#x00A0;1..N}&#x00A0;X[i,j].sosno&#x00A0;:=&#x00A0;i;
230</div>
231</td></tr></table>
232<!--l. 173--><p class="nopar" > </div> 
233<!--l. 176--><p class="indent" >    </div> <div class="story"> <h3><a name=  &#8221;sec:run&#x02D9;gams&#8221; ></a> From <span 
234class="cmtt-10">Gams </span> </h3>  Thanks to the <a 
235href="http://projects.coin-or.org/GAMSlinks" >GAMSlinks</a> project, Bonmin is
236available in <span 
237class="cmtt-10">Gams </span>since release 22.5 of the <a 
238href="http://www.gams.com/" ><span 
239class="cmtt-10">GAMS</span></a> modeling system. The system is
240available for <a 
241href="http://download.gams-software.com/" >download from GAMS</a>. Without buying a license it works as a demo
242with limited capabilities. Documentation for using <span 
243class="cmtt-10">BONMIN</span>&#x00A0;in <span 
244class="cmtt-10">GAMS </span>is available
245<a 
246href="http://www.gams.com/solvers/coin.pdf" >here</a>.
247<!--l. 187--><p class="indent" >    </div> <div class="story"> <h3><a name=  &#8221;sec:run&#x02D9;cpp&#8221; ></a> From a C/C++ program  </h3>   <span 
248class="cmtt-10">BONMIN</span>&#x00A0;can also be run from within a
249C/C++ program if the user codes the functions to compute first- and second-order
250derivatives. An example of such a program is available in the subdirectory
251<span 
252class="cmtt-10">CppExample </span>of the <span 
253class="cmtt-10">examples </span>directory. For further explanations, please refer to this
254example and to the reference manual.
255   
256</body></html> 
257
258
259
Note: See TracBrowser for help on using the repository browser.