Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinBuild.hpp
Go to the documentation of this file.
1 /* $Id: CoinBuild.hpp 1416 2011-04-17 09:57:29Z stefan $ */
2 // Copyright (C) 2005, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CoinBuild_H
7 #define CoinBuild_H
8 
9 
10 #include "CoinPragma.hpp"
11 #include "CoinTypes.hpp"
12 #include "CoinFinite.hpp"
13 
14 
27 class CoinBuild {
28 
29 public:
32  void addRow(int numberInRow, const int * columns,
34  const double * elements, double rowLower=-COIN_DBL_MAX,
35  double rowUpper=COIN_DBL_MAX);
37  void addColumn(int numberInColumn, const int * rows,
38  const double * elements,
39  double columnLower=0.0,
40  double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0);
42  inline void addCol(int numberInColumn, const int * rows,
43  const double * elements,
44  double columnLower=0.0,
45  double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0)
46  { addColumn(numberInColumn, rows, elements, columnLower, columnUpper, objectiveValue);}
48  inline int numberRows() const
49  { return (type_==0) ? numberItems_ : numberOther_;}
51  inline int numberColumns() const
52  { return (type_==1) ? numberItems_ : numberOther_;}
55  { return numberElements_;}
58  int row(int whichRow, double & rowLower, double & rowUpper,
59  const int * & indices, const double * & elements) const;
63  int currentRow(double & rowLower, double & rowUpper,
64  const int * & indices, const double * & elements) const;
66  void setCurrentRow(int whichRow);
68  int currentRow() const;
71  int column(int whichColumn,
72  double & columnLower, double & columnUpper,double & objectiveValue,
73  const int * & indices, const double * & elements) const;
77  int currentColumn( double & columnLower, double & columnUpper,double & objectiveValue,
78  const int * & indices, const double * & elements) const;
80  void setCurrentColumn(int whichColumn);
82  int currentColumn() const;
84  inline int type() const
85  { return type_;}
87 
88 
92  CoinBuild();
94  CoinBuild(int type);
96  ~CoinBuild();
98 
102  CoinBuild(const CoinBuild&);
104  CoinBuild& operator=(const CoinBuild&);
106 private:
108  void setMutableCurrent(int which) const;
110  void addItem(int numberInItem, const int * indices,
111  const double * elements,
112  double itemLower,
113  double itemUpper, double objectiveValue);
116  int item(int whichItem,
117  double & itemLower, double & itemUpper,double & objectiveValue,
118  const int * & indices, const double * & elements) const;
122  int currentItem( double & itemLower, double & itemUpper,double & objectiveValue,
123  const int * & indices, const double * & elements) const;
125  void setCurrentItem(int whichItem);
127  int currentItem() const;
128 
129 private:
132  int numberItems_;
139  mutable double * currentItem_;
141  double * firstItem_;
143  double * lastItem_;
145  int type_;
147 };
148 
149 #endif
void setCurrentColumn(int whichColumn)
Set current column.
void addRow(int numberInRow, const int *columns, const double *elements, double rowLower=-COIN_DBL_MAX, double rowUpper=COIN_DBL_MAX)
add a row
void addCol(int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0)
add a column
Definition: CoinBuild.hpp:42
CoinBuild & operator=(const CoinBuild &)
=
void setCurrentRow(int whichRow)
Set current row.
void addItem(int numberInItem, const int *indices, const double *elements, double itemLower, double itemUpper, double objectiveValue)
add a item
int column(int whichColumn, double &columnLower, double &columnUpper, double &objectiveValue, const int *&indices, const double *&elements) const
Returns number of elements in a column and information in column.
int currentRow() const
Returns current row number.
int currentColumn() const
Returns current column number.
void setMutableCurrent(int which) const
Set current.
void addColumn(int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0)
add a column
int numberItems_
Current number of items.
Definition: CoinBuild.hpp:133
CoinBigIndex numberElements() const
Return number of elements.
Definition: CoinBuild.hpp:54
int numberOther_
Current number of other dimension i.e. Columns if addRow (i.e. max)
Definition: CoinBuild.hpp:135
int numberRows() const
Return number of rows or maximum found so far.
Definition: CoinBuild.hpp:48
CoinBigIndex numberElements_
Current number of elements.
Definition: CoinBuild.hpp:137
int numberColumns() const
Return number of columns or maximum found so far.
Definition: CoinBuild.hpp:51
int row(int whichRow, double &rowLower, double &rowUpper, const int *&indices, const double *&elements) const
Returns number of elements in a row and information in row.
void setCurrentItem(int whichItem)
Set current item.
int type_
Type of build - 0 for row, 1 for column, -1 unset.
Definition: CoinBuild.hpp:145
int currentItem() const
Returns current item number.
int CoinBigIndex
double * lastItem_
Last item pointer.
Definition: CoinBuild.hpp:143
int item(int whichItem, double &itemLower, double &itemUpper, double &objectiveValue, const int *&indices, const double *&elements) const
Returns number of elements in a item and information in item.
int type() const
Returns type.
Definition: CoinBuild.hpp:84
~CoinBuild()
Destructor.
double * firstItem_
First item pointer.
Definition: CoinBuild.hpp:141
const double COIN_DBL_MAX
Definition: CoinFinite.hpp:18
double * currentItem_
Current item pointer.
Definition: CoinBuild.hpp:139
CoinBuild()
Default constructor.
In many cases it is natural to build a model by adding one row at a time.
Definition: CoinBuild.hpp:27