Changeset 2418


Ignore:
Timestamp:
Mar 6, 2019 8:03:21 PM (8 months ago)
Author:
stefan
Message:

cleanup notsobasic

Location:
branches/gh-pages
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gh-pages/notsobasic.md

    r2416 r2418  
    11# Not-Quite-So-Basic Model Classes
    22
    3 # Pivot Choices
     3## Pivot Choices
    44
    55In the dual algorithm, any infeasible basic variable may be chosen to
     
    2121to ClpSimplex model as in the following code fragment:
    2222
    23 ```
    24   ClpDualRowSteepest steep(1); // 0 uninitialized, 1 compute weights
    25   model.setDualRowPivotAlgorithm(steep);
    26  
     23```
     24ClpDualRowSteepest steep(1); // 0 uninitialized, 1 compute weights
     25model.setDualRowPivotAlgorithm(steep);
    2726```
    2827
     
    3736does steepest edge create an instance and pass it to ClpSimplex model as
    3837in the following code fragment:
    39 
    40 ```
     38```
    4139  ClpPrimalColumnSteepest steep(1); // 0 devex, 1 steepest
    4240  model.setPrimalColumnPivotAlgorithm(steep);
    43  
    4441```
    4542
     
    4744exist. This could be implemented by anyone who is interested.
    4845
    49 # Matrix Classes
     46## Matrix Classes
    5047
    5148The next abstract class of interest is `ClpMatrixBase`. CLP encapsulates
     
    7774following:
    7875
    79 ```
    80   ClpPlusMinusOneMatrix plusMinus(matrix);
    81   assert (plusMinus.getIndices()); // would be zero if not +- one
    82   model.loadProblem(plusMinus,
    83     lowerColumn,upperColumn,objective,
    84     lower,upper);
    85  
     76```
     77ClpPlusMinusOneMatrix plusMinus(matrix);
     78assert (plusMinus.getIndices()); // would be zero if not +- one
     79model.loadProblem(plusMinus,
     80  lowerColumn,upperColumn,objective,
     81  lower,upper);
    8682```
    8783
     
    9086`head` and `tail`, one could do the following:
    9187
    92 ```
    93   ClpNetworkMatrix network(numberColumns,head,tail);
    94   model.loadProblem(network,
    95     lowerColumn,upperColumn,objective,
    96     lower,upper);
    97  
     88```
     89ClpNetworkMatrix network(numberColumns,head,tail);
     90model.loadProblem(network,
     91  lowerColumn,upperColumn,objective,
     92  lower,upper);
    9893```
    9994
    100 Actual code is in `COIN/Clp/Test/unitTest.cpp`. A quick glance at the
     95Actual code is in `test/unitTest.cpp`. A quick glance at the
    10196output of this program shows that use of `ClpNetworkMatrix` gives much
    10297faster run times. This is not because of storage issues, but because CLP
     
    112107would be used).
    113108
    114 # Message Handling
     109## Message Handling
    115110
    116 Strictly speaking, message handling is a general COIN topic, but it
     111Strictly speaking, message handling is a general COIN-OR topic, but it
    117112won't hurt to repeat a few important things here.
    118113
     
    120115`model.setLogLevel(int value)` where 0 gives nothing and each increase
    121116in value switches on more messages. See `ClpMessage.cpp`,
    122 `CoinMessage.cpp` and [???](#messages) to see which messages are at
     117`CoinMessage.cpp` and [Messages](./messages) to see which messages are at
    123118which level. A more sophisticated user may wish to handle messages in a
    124119different way. This is done using `passInMessageHandler` with a pointer
     
    127122would be:
    128123
    129 ```
    130   FILE * fp; // assumed open
    131   CoinMessageHandler handler(fp);
    132   model.passInMessageHandler(&handler);
    133  
     124```
     125FILE * fp; // assumed open
     126CoinMessageHandler handler(fp);
     127model.passInMessageHandler(&handler);
    134128```
    135129
    136130A still more sophisticated use would be to write a class derived from
    137131`CoinMessageHandler` and then override the `print` method. Below follows
    138 an example which would print only a message for optimality (or
    139 infeasibility):
     132an example which would print only a message for optimality (or infeasibility):
    140133
    141 ``` 
    142   class DerivedHandler :
    143    public CoinMessageHandler {
    144    public:
    145      virtual int print() ;
    146    };
     134```
     135class DerivedHandler {
     136  public CoinMessageHandler {
     137  public:
     138    virtual int print() ;
     139  };
    147140
    148 
    149    int DerivedHandler::print()
    150    {
    151      if (currentSource()=="Clp") {
    152        if (currentMessage().externalNumber()>=0
    153        && currentMessage().externalNumber()<4) {
    154          // finished
    155          return CoinMessageHandler::print(); // print
    156        }
    157      }
    158      return 0;
    159    }
    160  
     141  int DerivedHandler::print()
     142  {
     143    if (currentSource()=="Clp") {
     144      if (currentMessage().externalNumber()>=0
     145        && currentMessage().externalNumber()<4) {
     146          // finished
     147          return CoinMessageHandler::print(); // print
     148        }
     149      }
     150      return 0;
     151  }
     152}
    161153```
Note: See TracChangeset for help on using the changeset viewer.