source: html/userguide/ch04.html @ 2182

Last change on this file since 2182 was 966, checked in by ddelanu, 16 years ago

Temporary version, trying to fix problems in server change, real release to follow

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.5 KB
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 4. 
2More Samples
3</title><meta name="generator" content="DocBook XSL Stylesheets V1.66.1"><link rel="start" href="index.html" title="CLP User Guide"><link rel="up" href="index.html" title="CLP User Guide"><link rel="prev" href="ch03s03.html" title="Message Handling"><link rel="next" href="ch04s02.html" title="Common CLP Tasks in the Samples"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. 
4More Samples
5</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch04s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="moreexamples"></a>Chapter 4. 
6More Samples
7</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ch04.html#id4772901">CLP's Samples Directory</a></span></dt><dd><dl><dt><span class="section"><a href="ch04.html#minimumcppdesc">minimum.cpp</a></span></dt><dt><span class="section"><a href="ch04.html#defaultscppdesc">defaults.cpp</a></span></dt><dt><span class="section"><a href="ch04.html#drivercppdesc">driver.cpp</a></span></dt><dt><span class="section"><a href="ch04.html#networkcppdesc">network.cpp</a></span></dt><dt><span class="section"><a href="ch04.html#testbarriercppdesc">testBarrier.cpp</a></span></dt><dt><span class="section"><a href="ch04.html#id4774185">dualCuts.cpp</a></span></dt><dt><span class="section"><a href="ch04.html#id4774208">decompose.cpp</a></span></dt><dt><span class="section"><a href="ch04.html#id4774225">driver2.cpp</a></span></dt></dl></dd><dt><span class="section"><a href="ch04s02.html">Common CLP Tasks in the Samples</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id4772901"></a>CLP's Samples Directory</h2></div></div></div><p>
8The CLP dsitribution includes a number of <tt class="filename">.cpp</tt> sample files.
9Users are encouraged to use them as starting points for their own CLP projects.
10The files can be found in the <tt class="filename">COIN/Clp/Samples/</tt> directory.
11For the latest information on compiling and running these samples, please see
12the file <tt class="filename">COIN/Clp/Samples/INSTALL</tt>.  Below is a list of
13some of the most useful sample files with a short description for each file.
14</p><div class="table"><a name="id4772294"></a><p class="title"><b>Table 4.1. Basic Samples</b></p><table summary="Basic Samples" border="0"><colgroup><col><col></colgroup><thead><tr><th align="left" valign="bottom">
15        Source file       
16        </th><th align="left" valign="bottom">
17        Description
18        </th></tr></thead><tbody><tr><td align="left" valign="top">
19        <a href="" target="_top"><tt class="filename">minimum.cpp</tt></a>
20        </td><td align="left" valign="top">
21        This is a CLP "Hello, world" program.  It reads a problem
22        from an MPS file, and solves the problem.
23        [<a href="ch04.html#minimumcppdesc" title="minimum.cpp">More...</a>]
24        </td></tr><tr><td align="left" valign="top">
25        <a href="" target="_top"><tt class="filename">defaults.cpp</tt></a>
26        </td><td align="left" valign="top">
27        This is one of the simpler driver programs available.  It sets
28        tolerances to defaults and is a good place to find straightforward uses
29        of "set" and    "get" methods.  It also prints out full
30        MPS-like solutions.
31        [<a href="ch04.html#defaultscppdesc" title="defaults.cpp">More...</a>]
32        </td></tr><tr><td align="left" valign="top">
33        <a href="" target="_top"><tt class="filename">driver.cpp</tt></a>
34        </td><td align="left" valign="top">
35        This is designed to be a file that a user could modify to get a useful
36        driver program for his or her project.  In particular, it demonstrates
37        the use of CLP's  presolve functionality.
38        [<a href="ch04.html#drivercppdesc" title="driver.cpp">More...</a>]
39        </td></tr><tr><td align="left" valign="top">
40        <a href="" target="_top"><tt class="filename">network.cpp</tt></a>
41        </td><td align="left" valign="top">
42        This shows the use of non-standard matrices and how to load a problem
43        without the use of MPS files.
44        [<a href="ch04.html#networkcppdesc" title="network.cpp">More...</a>]
45        </td></tr><tr><td align="left" valign="top">
46        <a href="" target="_top"><tt class="filename">testBarrier.cpp</tt></a>
47        </td><td align="left" valign="top">
48        This is a basic driver file for the barrier method of CLP, similar to
49        <a href="" target="_top"><tt class="filename">minimum.cpp</tt></a>.  The barrier method is not currently addressed in this
50        guide.
51        [<a href="ch04.html#testbarriercppdesc" title="testBarrier.cpp">More...</a>]
52        </td></tr></tbody></table></div><div class="table"><a name="id4773491"></a><p class="title"><b>Table 4.2. Advanced Samples</b></p><table summary="Advanced Samples" border="0"><colgroup><col><col></colgroup><thead><tr><th align="left" valign="bottom">
53        Source file       
54        </th><th align="left" valign="bottom">
55        Description
56        </th></tr></thead><tbody><tr><td align="left" valign="top">
57        <a href="" target="_top"><tt class="filename">driver2.cpp</tt></a>
58        </td><td align="left" valign="top">
59        This sample, in addition to some tasks common to other samples, does
60        some advanced message handling and presolve.
61        </td></tr><tr><td align="left" valign="top">
62        <a href="" target="_top"><tt class="filename">dualCuts.cpp</tt></a>
63        </td><td align="left" valign="top">
64        This sample implements a method of treating a problem as a collection
65        of cuts.
66        </td></tr><tr><td align="left" valign="top">
67        <a href="" target="_top"><tt class="filename">decompose.cpp</tt></a>
68        </td><td align="left" valign="top">
69        This does full Dantzig-Wolfe decomposition.  It illustrates
70        the use of many models, adding columns, et cetera.
71        </td></tr><tr><td align="left" valign="top">
72        <a href="" target="_top"><tt class="filename">sprint.cpp</tt></a>
73        </td><td align="left" valign="top">
74        This solves a long, thin problem by solving smaller subsets.  It is a
75        simplified version of work done by one of the authors on aircrew
76        scheduling problems.  It shows the use of two models and their
77        synchronization.  A more general version can be found in
78        <tt class="filename">COIN/Clp/ClpSolve.cpp</tt>
79        </td></tr><tr><td align="left" valign="top">
80        <a href="" target="_top"><tt class="filename">sprint2.cpp</tt></a>
81        </td><td align="left" valign="top">
82        This is similar to <tt class="filename">sprint.cpp</tt> but is designed for
83        solving large problems with little choice.  The idea is that if
84        relatively few variables are fixed, presolve can greatly reduce the
85        problem size so that a series of solves can get close to the optimal
86        solution much faster than would a naïve solve of the full problem.
87        </td></tr></tbody></table></div><p>
88The remaining Samples listed here are considered unsupported in that they are of
89a more esoteric nature and are sometimes contributed as a result of an
90individual's request.  The are to be found in
91<tt class="filename">COIN/Clp/Samples/Contributed</tt>.
92</p><div class="table"><a name="id4773721"></a><p class="title"><b>Table 4.3. Unsupported Samples</b></p><table summary="Unsupported Samples" border="0"><colgroup><col><col></colgroup><thead><tr><th align="left" valign="bottom">
93        Source file       
94        </th><th align="left" valign="bottom">
95        Description
96        </th></tr></thead><tbody><tr><td align="left" valign="top">
97        <a href="" target="_top"><tt class="filename">testBasis.cpp</tt></a>
98        </td><td align="left" valign="top">
99        This sample takes a problem, changes any inequality constraints to
100        equality constraints, solves the problem, and creates the optimal basis.
101        </td></tr><tr><td align="left" valign="top">
102        <a href="" target="_top"><tt class="filename">testGub.cpp</tt></a>
103        </td><td align="left" valign="top">
104        This sample illustrates the use of the GUB ("Generalized Upper
105        Bound") technique.
106        </td></tr><tr><td align="left" valign="top">
107        <a href="" target="_top"><tt class="filename">ekk.cpp</tt></a>
108        </td><td align="left" valign="top">
109        This sample can be used to compare CLP and OSL.  It uses an additional
110        file in the Samples directory, <tt class="filename">ekk_interface.cpp</tt>.
111        These sample files are not likely to be interesting to new CLP users
112        who do not have experience with OSL.
113        </td></tr><tr><td align="left" valign="top">
114        <a href="" target="_top"><tt class="filename">hello.cpp</tt></a>
115        </td><td align="left" valign="top">
116        This sample creates a text-based picture of a matrix on screen
117        (limited to an 80x80 matrix).  It's not terribly useful but it does
118        illustrate one way to step through the elements of a matrix.
119        </td></tr><tr><td align="left" valign="top">
120        <a href="" target="_top"><tt class="filename">piece.cpp</tt></a>
121        </td><td align="left" valign="top">
122        This sample takes a matrix read in by <tt class="classname">CoinMpsIo</tt>
123        (can be used to read in MPS files without a solver), deletes every
124        second column and solves the resulting problem.
125        </td></tr><tr><td align="left" valign="top">
126        <a href="" target="_top"><tt class="filename">useVolume.cpp</tt></a>
127        </td><td align="left" valign="top">
128        The Volume Algorithm is another solver available as part of the COIN-OR
129        distribution.  This sample shows how to use the Volume Algorithm with
130        CLP.
131        </td></tr></tbody></table></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="minimumcppdesc"></a>minimum.cpp</h3></div></div></div><p>
132This sample is examined in more detail in <a href="ch02s02.html" title="
133  First Example
134  ">the section called &#8220;
135  First Example
136  &#8221;</a>.
137</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="defaultscppdesc"></a>defaults.cpp</h3></div></div></div><p>
138This sample begins by reading an MPS file.  The default MPS file is
139<tt class="filename">COIN/Mps/Sample/p0033.mps</tt>; this can be over-riden by a
140command-line specification of a (path and) file name).  The sample then sets
141the pivot algorithm to be exact devex.  It "gets" the default
142infeasibility cost and "sets" it to that value (and prints it to
143standard out).  This sort of getting and setting of various parameters
144constitutes a common theme in this sample, with the purpose of illustrating
145usage of some of the more common get and set methods available in CLP.
147At this point the model is solved by the primal method.  A sequence of sets,
148gets and prints is then followed by a number of calls to methods which give
149specific information about the status of the problem (for example, the code
150checks that the current solution has been proven to be optimal by
151<tt class="code">assert(model.isProvenOptimal())</tt>).
153Next, a copy of the original model is made.  More sets and gets are
154performed to demonstrate the use of additional options (including
155the setting of the default message handling as well as changing of the
156"log level" (amount of output)).  The model is solved again a
157number of times between changes of the optimization direction (i.e. changing
158from min to max or vice versa).  The remaining lines of this sample serve to
159display solution and problem information in much the same way as is done in
161</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="drivercppdesc"></a>driver.cpp</h3></div></div></div><p>
162This sample begins by reading an MPS file.  The default MPS file is
163<tt class="filename">COIN/Mps/Sample/p0033.mps</tt>; this can be over-riden by a
164command-line specification of a (path and) file name).  A second command-line
165argument can specify that either the "primal" or "dual"
166method (or even the "barrier", see below) should be used by CLP.
168Once the problem has been
169read, there are two options for how to solve it, one of which must be chosen at
170compile-time (<tt class="code">STYLE1</tt> being defined or not determines this
171choice).  The second manner is more flexible and involves more specific
172directions being given to CLP, including the ability to specify that the barrier
173method should be used.
175At this point in the sample, the problem is solved by CLP, and some basic ouput
176is generated.  If more output is desired, at compile-time, an
177<tt class="code">exit(0)</tt> statement must either be removed or commented.  There are
178two levels of additional output, the first of which is suppressed  by a
179<tt class="code">#if 0</tt> directive which may be modified at compile-time if desired.
180This first level of output only involves non-zero columns, whereas the second
181provides additional information.
182</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="networkcppdesc"></a>network.cpp</h3></div></div></div><p>
183This handy sample reads a network problem generated by
184<a href="" target="_top">netgen</a>, converts
185it to an LP using CLP's network matrix type, and solves.  This entirely avoids
186the use of an MPS file, as the LP is built in memory from the network data file
187created by netgen.  Also, the factorization frequency is changed, and the
188problem is solved more than once (demonstrating the change of optimization sense
189as well as switching from dual to primal methods).
190</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="testbarriercppdesc"></a>testBarrier.cpp</h3></div></div></div><p>
191This straightfoward sample begins by reading a problem from an MPS file.  It
192then chooses a Cholesky factorization and solves the problem using the
193predictor corrector barrier method.  It then copies the problem and performs a
194crossover to a simplex solution in the new copy.
195</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id4774185"></a>dualCuts.cpp</h3></div></div></div><p>
196This sample begins with only the equality constraints of a problem.  The
197inequalities are considered to be part of a pool of available cuts in much the
198same way as is done in integer programming.  However, in this case, the cuts are
199not "generated", they are simply the inequalities of the problem.
200</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id4774208"></a>decompose.cpp</h3></div></div></div><p>
201More on this sample coming soon!
202</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id4774225"></a>driver2.cpp</h3></div></div></div><p>
203More on this sample coming soon!
204</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch04s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Message Handling </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Common CLP Tasks in the Samples</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.