This file is indexed.

/usr/include/coin/OsiCuts.hpp is in coinor-libosi-dev 0.106.4-1ubuntu5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
// Copyright (C) 2000, International Business Machines
// Corporation and others.  All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).

#ifndef OsiCuts_H
#define OsiCuts_H

#include "CoinPragma.hpp"

#include <cmath>
#include <cfloat>
#include "OsiCollections.hpp"
#include "OsiRowCut.hpp"
#include "OsiColCut.hpp"
#include "CoinFloatEqual.hpp"

/** Collections of row cuts and column cuts
*/
class OsiCuts {
   friend void OsiCutsUnitTest();

public:
  /**@name Iterator classes
   */
  //@{
    /** Iterator

      This is a class for iterating over the collection of cuts.
    */
    class iterator {
      friend class OsiCuts;
    public:
      iterator(OsiCuts& cuts); 
      iterator(const iterator & src);
      iterator & operator=( const iterator& rhs);    
      ~iterator ();
      OsiCut* operator*() const { return cutP_; }    
      iterator operator++();

      iterator operator++(int)
      {
        iterator temp = *this;
        ++*this;
        return temp;
      }
    
      bool operator==(const iterator& it) const {
        return (colCutIndex_+rowCutIndex_)==(it.colCutIndex_+it.rowCutIndex_);
      }
    
      bool operator!=(const iterator& it) const {
        return !((*this)==it);
      }
    
      bool operator<(const iterator& it) const {
        return (colCutIndex_+rowCutIndex_)<(it.colCutIndex_+it.rowCutIndex_);
      }
    
    private: 
      iterator();
      // *THINK* : how to inline these without sticking the code here (ugly...)
      iterator begin();
      iterator end();
      OsiCuts& cuts_;
      int rowCutIndex_;
      int colCutIndex_;
      OsiCut * cutP_;
    };
   
    /** Const Iterator

      This is a class for iterating over the collection of cuts.
    */ 
    class const_iterator {
      friend class OsiCuts;
	public:
	  typedef std::bidirectional_iterator_tag iterator_category;
	  typedef OsiCut* value_type;
	  typedef size_t difference_type;
	  typedef OsiCut ** pointer;
	  typedef OsiCut *& reference;

    public:
      const_iterator(const OsiCuts& cuts);
      const_iterator(const const_iterator & src);
      const_iterator & operator=( const const_iterator& rhs);     
      ~const_iterator ();
      const OsiCut* operator*() const { return cutP_; } 
       
      const_iterator operator++();
    
      const_iterator operator++(int)
      {
        const_iterator temp = *this;
        ++*this;
        return temp;
      }
    
      bool operator==(const const_iterator& it) const {
        return (colCutIndex_+rowCutIndex_)==(it.colCutIndex_+it.rowCutIndex_);
      }
    
      bool operator!=(const const_iterator& it) const {
        return !((*this)==it);
      }
    
      bool operator<(const const_iterator& it) const {
        return (colCutIndex_+rowCutIndex_)<(it.colCutIndex_+it.rowCutIndex_);
      }
    private:  
      inline const_iterator();  
      // *THINK* : how to inline these without sticking the code here (ugly...)
      const_iterator begin();
      const_iterator end();
      const OsiCuts * cutsPtr_;
      int rowCutIndex_;
      int colCutIndex_;
      const OsiCut * cutP_;
    };
  //@}

  //-------------------------------------------------------------------
  // 
  // Cuts class definition begins here:
  //
  //------------------------------------------------------------------- 
    
  /** \name Inserting a cut into collection */
  //@{
    /** \brief Insert a row cut */
    inline void insert( const OsiRowCut & rc );
    /** \brief Insert a row cut unless it is a duplicate - cut may get sorted.
       Duplicate is defined as CoinAbsFltEq says same*/
    void insertIfNotDuplicate( OsiRowCut & rc , CoinAbsFltEq treatAsSame=CoinAbsFltEq(1.0e-12) );
    /** \brief Insert a row cut unless it is a duplicate - cut may get sorted.
       Duplicate is defined as CoinRelFltEq says same*/
    void insertIfNotDuplicate( OsiRowCut & rc , CoinRelFltEq treatAsSame );
    /** \brief Insert a column cut */
    inline void insert( const OsiColCut & cc );

    /** \brief Insert a row cut.
    
      The OsiCuts object takes control of the cut object.
      On return, \c rcPtr is NULL.
    */
    inline void insert( OsiRowCut * & rcPtr );
    /** \brief Insert a column cut.
    
      The OsiCuts object takes control of the cut object.
      On return \c ccPtr is NULL.
    */
    inline void insert( OsiColCut * & ccPtr );
#if 0
    inline void insert( OsiCut    * & cPtr  );
#endif
    
   /** \brief Insert a set of cuts */
   inline void insert(const OsiCuts & cs);

  //@}

  /**@name Number of cuts in collection */
  //@{
    /// Number of row cuts in collection
    inline int sizeRowCuts() const;
    /// Number of column cuts in collection
    inline int sizeColCuts() const;
    /// Number of cuts in collection
    inline int sizeCuts() const;
  //@}
   
  /**@name Debug stuff */
  //@{
    /// Print cuts in collection
    inline void printCuts() const;
  //@}
   
  /**@name Get a cut from collection */
  //@{
    /// Get pointer to i'th row cut
    inline OsiRowCut * rowCutPtr(int i);
    /// Get const pointer to i'th row cut
    inline const OsiRowCut * rowCutPtr(int i) const;
    /// Get pointer to i'th column cut
    inline OsiColCut * colCutPtr(int i);
    /// Get const pointer to i'th column cut
    inline const OsiColCut * colCutPtr(int i) const;

    /// Get reference to i'th row cut
    inline OsiRowCut & rowCut(int i);
    /// Get const reference to i'th row cut
    inline const OsiRowCut & rowCut(int i) const;
    /// Get reference to i'th column cut
    inline OsiColCut & colCut(int i);
    /// Get const reference to i'th column cut
    inline const OsiColCut & colCut(int i) const;

    /// Get const pointer to the most effective cut
    inline const OsiCut * mostEffectiveCutPtr() const;
    /// Get pointer to the most effective cut
    inline OsiCut * mostEffectiveCutPtr();
  //@}

  /**@name Deleting cut from collection */
  //@{ 
    /// Remove i'th row cut from collection
    inline void eraseRowCut(int i);
    /// Remove i'th column cut from collection
    inline void eraseColCut(int i); 
    /// Get pointer to i'th row cut and remove ptr from collection
    inline OsiRowCut * rowCutPtrAndZap(int i);
    /*! \brief Clear all row cuts without deleting them
    
      Handy in case one wants to use CGL without managing cuts in one of
      the OSI containers. Client is ultimately responsible for deleting the
      data structures holding the row cuts.
    */
    inline void dumpCuts() ;
    /*! \brief Selective delete and clear for row cuts.

      Deletes the cuts specified in \p to_erase then clears remaining cuts
      without deleting them. A hybrid of eraseRowCut(int) and dumpCuts().
      Client is ultimately responsible for deleting the data structures
      for row cuts not specified in \p to_erase.
    */
    inline void eraseAndDumpCuts(const std::vector<int> to_erase) ;
  //@}
 
  /**@name Sorting collection */
  //@{ 
    /// Cuts with greatest effectiveness are first.
    inline void sort();
  //@}
  
   
  /**@name Iterators 
     Example of using an iterator to sum effectiveness
     of all cuts in the collection.
     <pre>
     double sumEff=0.0;
     for ( OsiCuts::iterator it=cuts.begin(); it!=cuts.end(); ++it )
           sumEff+= (*it)->effectiveness();
     </pre>
  */
  //@{ 
    /// Get iterator to beginning of collection
    inline iterator begin() { iterator it(*this); it.begin(); return it; }  
    /// Get const iterator to beginning of collection
    inline const_iterator begin() const { const_iterator it(*this); it.begin(); return it; }  
    /// Get iterator to end of collection 
    inline iterator end() { iterator it(*this); it.end(); return it; }
    /// Get const iterator to end of collection 
    inline const_iterator end() const { const_iterator it(*this); it.end(); return it; }  
  //@}
 
   
  /**@name Constructors and destructors */
  //@{
    /// Default constructor
    OsiCuts (); 

    /// Copy constructor 
    OsiCuts ( const OsiCuts &);
  
    /// Assignment operator 
    OsiCuts & operator=( const OsiCuts& rhs);
  
    /// Destructor 
    virtual ~OsiCuts ();
  //@}

private:
  //*@name Function operator for sorting cuts by efectiveness */
  //@{
    class OsiCutCompare
    { 
    public:
      /// Function for sorting cuts by effectiveness
      inline bool operator()(const OsiCut * c1P,const OsiCut * c2P) 
      { return c1P->effectiveness() > c2P->effectiveness(); }
    };
  //@}

  /**@name Private methods */
  //@{     
    /// Copy internal data
    void gutsOfCopy( const OsiCuts & source );
    /// Delete internal data
    void gutsOfDestructor();
  //@}
    
  /**@name Private member data */
  //@{   
    /// Vector of row cuts pointers
    OsiVectorRowCutPtr rowCutPtrs_;
    /// Vector of column cuts pointers
    OsiVectorColCutPtr colCutPtrs_;
  //@}

};


//-------------------------------------------------------------------
// insert cuts into collection
//-------------------------------------------------------------------
void OsiCuts::insert( const OsiRowCut & rc )
{
  OsiRowCut * newCutPtr = rc.clone();
  //assert(dynamic_cast<OsiRowCut*>(newCutPtr) != NULL );
  rowCutPtrs_.push_back(static_cast<OsiRowCut*>(newCutPtr));
}
void OsiCuts::insert( const OsiColCut & cc )
{
  OsiColCut * newCutPtr = cc.clone();
  //assert(dynamic_cast<OsiColCut*>(newCutPtr) != NULL );
  colCutPtrs_.push_back(static_cast<OsiColCut*>(newCutPtr));
}

void OsiCuts::insert( OsiRowCut* & rcPtr )
{
  rowCutPtrs_.push_back(rcPtr);
  rcPtr = NULL;
}
void OsiCuts::insert( OsiColCut* &ccPtr )
{
  colCutPtrs_.push_back(ccPtr);
  ccPtr = NULL;
}
#if 0
void OsiCuts::insert( OsiCut* & cPtr )
{
  OsiRowCut * rcPtr = dynamic_cast<OsiRowCut*>(cPtr);
  if ( rcPtr != NULL ) {
    insert( rcPtr );
    cPtr = rcPtr;
  }
  else {
    OsiColCut * ccPtr = dynamic_cast<OsiColCut*>(cPtr);
    assert( ccPtr != NULL );
    insert( ccPtr );
    cPtr = ccPtr;
  }
}
#endif
    
// LANNEZ SEBASTIEN added Thu May 25 01:22:51 EDT 2006
void OsiCuts::insert(const OsiCuts & cs)
{
  for (OsiCuts::const_iterator it = cs.begin (); it != cs.end (); it++)
  {
    const OsiRowCut * rCut = dynamic_cast <const OsiRowCut * >(*it);
    const OsiColCut * cCut = dynamic_cast <const OsiColCut * >(*it);
    assert (rCut || cCut);
    if (rCut)
      insert (*rCut);
    else
      insert (*cCut);
  }
}

//-------------------------------------------------------------------
// sort
//------------------------------------------------------------------- 
void OsiCuts::sort() 
{
  std::sort(colCutPtrs_.begin(),colCutPtrs_.end(),OsiCutCompare()); 
  std::sort(rowCutPtrs_.begin(),rowCutPtrs_.end(),OsiCutCompare()); 
}


//-------------------------------------------------------------------
// Get number of in collections
//------------------------------------------------------------------- 
int OsiCuts::sizeRowCuts() const {
  return static_cast<int>(rowCutPtrs_.size()); }
int OsiCuts::sizeColCuts() const {
  return static_cast<int>(colCutPtrs_.size()); }
int OsiCuts::sizeCuts()    const {
  return static_cast<int>(sizeRowCuts()+sizeColCuts()); }

//----------------------------------------------------------------
// Get i'th cut from the collection
//----------------------------------------------------------------
const OsiRowCut * OsiCuts::rowCutPtr(int i) const { return rowCutPtrs_[i]; }
const OsiColCut * OsiCuts::colCutPtr(int i) const { return colCutPtrs_[i]; }
OsiRowCut * OsiCuts::rowCutPtr(int i) { return rowCutPtrs_[i]; }
OsiColCut * OsiCuts::colCutPtr(int i) { return colCutPtrs_[i]; }

const OsiRowCut & OsiCuts::rowCut(int i) const { return *rowCutPtr(i); }
const OsiColCut & OsiCuts::colCut(int i) const { return *colCutPtr(i); }
OsiRowCut & OsiCuts::rowCut(int i) { return *rowCutPtr(i); }
OsiColCut & OsiCuts::colCut(int i) { return *colCutPtr(i); }

//----------------------------------------------------------------
// Get most effective cut from collection
//----------------------------------------------------------------
const OsiCut * OsiCuts::mostEffectiveCutPtr() const 
{ 
  const_iterator b=begin();
  const_iterator e=end();
  return *(std::min_element(b,e,OsiCutCompare()));
}
OsiCut * OsiCuts::mostEffectiveCutPtr()  
{ 
  iterator b=begin();
  iterator e=end();
  //return *(std::min_element(b,e,OsiCutCompare()));
  OsiCut * retVal = NULL;
  double maxEff = COIN_DBL_MIN;
  for ( OsiCuts::iterator it=b; it!=e; ++it ) {
    if (maxEff < (*it)->effectiveness() ) {
      maxEff = (*it)->effectiveness();
      retVal = *it;
    }
  }
  return retVal;
}

//----------------------------------------------------------------
// Print all cuts
//----------------------------------------------------------------
void
OsiCuts::printCuts() const  
{ 
  // do all column cuts first
  int i;
  int numberColCuts=sizeColCuts();
  for (i=0;i<numberColCuts;i++) {
    const OsiColCut * cut = colCutPtr(i);
    cut->print();
  }
  int numberRowCuts=sizeRowCuts();
  for (i=0;i<numberRowCuts;i++) {
    const OsiRowCut * cut = rowCutPtr(i);
    cut->print();
  }
}

//----------------------------------------------------------------
// Erase i'th cut from the collection
//----------------------------------------------------------------
void OsiCuts::eraseRowCut(int i) 
{
  delete rowCutPtrs_[i];
  rowCutPtrs_.erase( rowCutPtrs_.begin()+i ); 
}
void OsiCuts::eraseColCut(int i) 
{   
  delete colCutPtrs_[i];
  colCutPtrs_.erase( colCutPtrs_.begin()+i );
}
/// Get pointer to i'th row cut and remove ptr from collection
OsiRowCut * 
OsiCuts::rowCutPtrAndZap(int i)
{
  OsiRowCut * cut = rowCutPtrs_[i];
  rowCutPtrs_[i]=NULL;
  rowCutPtrs_.erase( rowCutPtrs_.begin()+i ); 
  return cut;
}
void OsiCuts::dumpCuts()
{
  rowCutPtrs_.clear() ;
}
void OsiCuts::eraseAndDumpCuts(const std::vector<int> to_erase)
{
  for (unsigned i=0; i<to_erase.size(); i++) {
    delete rowCutPtrs_[to_erase[i]];
  }
  rowCutPtrs_.clear();
}


#endif