source: branches/devel-1/include/ClpSimplexPrimal.hpp @ 15

Last change on this file since 15 was 15, checked in by forrest, 18 years ago

Hope this works from wincvs

Fix error in values pass

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4/*
5   Authors
6   
7   John Forrest
8
9 */
10#ifndef ClpSimplexPrimal_H
11#define ClpSimplexPrimal_H
12
13#include "ClpSimplex.hpp"
14
15/** This solves LPs using the primal simplex method
16
17    It inherits from ClpSimplex.  It has no data of its own and
18    is never created - only cast from a ClpSimplex object at algorithm time.
19
20*/
21
22class ClpSimplexPrimal : public ClpSimplex {
23
24public:
25
26  /**@name Description of algorithm */
27  //@{
28  /** Primal algorithm
29
30      Method
31
32     It tries to be a single phase approach with a weight of 1.0 being
33     given to getting optimal and a weight of infeasibilityCost_ being
34     given to getting primal feasible.  In this version I have tried to
35     be clever in a stupid way.  The idea of fake bounds in dual
36     seems to work so the primal analogue would be that of getting
37     bounds on reduced costs (by a presolve approach) and using
38     these for being above or below feasible region.  I decided to waste
39     memory and keep these explicitly.  This allows for non-linear
40     costs!  I have not tested non-linear costs but will be glad
41     to do something if a reasonable example is provided.
42
43     The code is designed to take advantage of sparsity so arrays are
44     seldom zeroed out from scratch or gone over in their entirety.
45     The only exception is a full scan to find incoming variable for
46     Dantzig row choice.  For steepest edge we keep an updated list
47     of dual infeasibilities (actually squares). 
48     On easy problems we don't need full scan - just
49     pick first reasonable.  This method has not been coded.
50
51     One problem is how to tackle degeneracy and accuracy.  At present
52     I am using the modification of costs which I put in OSL and which was
53     extended by Gill et al.  I am still not sure whether we will also
54     need explicit perturbation.
55
56     The flow of primal is three while loops as follows:
57
58     while (not finished) {
59
60       while (not clean solution) {
61
62          Factorize and/or clean up solution by changing bounds so
63          primal feasible.  If looks finished check fake primal bounds.
64          Repeat until status is iterating (-1) or finished (0,1,2)
65
66       }
67
68       while (status==-1) {
69
70         Iterate until no pivot in or out or time to re-factorize.
71
72         Flow is:
73
74         choose pivot column (incoming variable).  if none then
75         we are primal feasible so looks as if done but we need to
76         break and check bounds etc.
77
78         Get pivot column in tableau
79
80         Choose outgoing row.  If we don't find one then we look
81         primal unbounded so break and check bounds etc.  (Also the
82         pivot tolerance is larger after any iterations so that may be
83         reason)
84
85         If we do find outgoing row, we may have to adjust costs to
86         keep going forwards (anti-degeneracy).  Check pivot will be stable
87         and if unstable throw away iteration and break to re-factorize.
88         If minor error re-factorize after iteration.
89
90         Update everything (this may involve changing bounds on
91         variables to stay primal feasible.
92
93       }
94
95     }
96
97     TODO's (or maybe not)
98
99     At present we never check we are going forwards.  I overdid that in
100     OSL so will try and make a last resort.
101
102     Needs partial scan pivot in option.
103
104     May need other anti-degeneracy measures, especially if we try and use
105     loose tolerances as a way to solve in fewer iterations.
106
107     I like idea of dynamic scaling.  This gives opportunity to decouple
108     different implications of scaling for accuracy, iteration count and
109     feasibility tolerance.
110
111  */
112
113  int primal(int ifValuesPass=0);
114  //@}
115
116  /**@name For advanced users */
117  //@{
118  /// Do not change infeasibility cost and always say optimal
119  void alwaysOptimal(bool onOff);
120  //@}
121
122  /**@name Functions used in primal */
123  //@{
124  /** This has the flow between re-factorizations
125      firstSuperBasic == number rows + columns normally,
126      otherwise first super basic variable
127   */
128  void whileIterating(int & firstSuperBasic); 
129  /** The primals are updated by the given array.
130      Returns number of infeasibilities.
131      After rowArray will have cost changes for use next iteration
132  */
133  int updatePrimalsInPrimal(OsiIndexedVector * rowArray,
134                  double theta,
135                  double & objectiveChange);
136  /**
137      Row array has pivot column
138      This chooses pivot row.
139      Rhs array is used for distance to next bound (for speed)
140      For speed, we may need to go to a bucket approach when many
141      variables go through bounds
142      On exit rhsArray will have changes in costs of basic variables
143      If valuesPass non-zero then compute dj for direction
144  */
145  void primalRow(OsiIndexedVector * rowArray,
146                 OsiIndexedVector * rhsArray,
147                 OsiIndexedVector * spareArray,
148                 OsiIndexedVector * spareArray2,
149                 int valuesPass);
150  /**
151      Chooses primal pivot column
152      updateArray has cost updates (also use pivotRow_ from last iteration)
153      Would be faster with separate region to scan
154      and will have this (with square of infeasibility) when steepest
155      For easy problems we can just choose one of the first columns we look at
156  */
157  void primalColumn(OsiIndexedVector * updateArray,
158                    OsiIndexedVector * spareRow1,
159                    OsiIndexedVector * spareRow2,
160                    OsiIndexedVector * spareColumn1,
161                    OsiIndexedVector * spareColumn2);
162
163  /** Checks if tentative optimal actually means unbounded in primal
164      Returns -3 if not, 2 if is unbounded */
165  int checkUnbounded(OsiIndexedVector * ray,OsiIndexedVector * spare,
166                     double changeCost);
167  /**  Refactorizes if necessary
168       Checks if finished.  Updates status.
169       lastCleaned refers to iteration at which some objective/feasibility
170       cleaning too place.
171
172       type - 0 initial so set up save arrays etc
173            - 1 normal -if good update save
174            - 2 restoring from saved
175  */
176  void statusOfProblemInPrimal(int & lastCleaned, int type);
177  /// Perturbs problem (method depends on perturbation())
178  void perturb();
179  /// Sets sequenceIn_ to next superBasic (input by first..) and updates
180  void nextSuperBasic(int & firstSuperBasic);
181  //@}
182};
183#endif
184
Note: See TracBrowser for help on using the repository browser.