From a0d9443af147e949c1e6a01ac24749d12593ec5b Mon Sep 17 00:00:00 2001 From: Harpreet Date: Sat, 3 Sep 2016 00:36:51 +0530 Subject: cbcintlinprog added --- thirdparty/linux/include/coin/OsiRowCut.hpp | 331 ++++++++++++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 thirdparty/linux/include/coin/OsiRowCut.hpp (limited to 'thirdparty/linux/include/coin/OsiRowCut.hpp') diff --git a/thirdparty/linux/include/coin/OsiRowCut.hpp b/thirdparty/linux/include/coin/OsiRowCut.hpp new file mode 100644 index 0000000..1332802 --- /dev/null +++ b/thirdparty/linux/include/coin/OsiRowCut.hpp @@ -0,0 +1,331 @@ +// 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 OsiRowCut_H +#define OsiRowCut_H + +#include "CoinPackedVector.hpp" + +#include "OsiCollections.hpp" +#include "OsiCut.hpp" + +//#define OSI_INLINE_ROWCUT_METHODS +#ifdef OSI_INLINE_ROWCUT_METHODS +#define OsiRowCut_inline inline +#else +#define OsiRowCut_inline +#endif + +/** Row Cut Class + +A row cut has: +
value
to every vector entry
+ void operator+=(double value)
+ { row_ += value; }
+
+ /// subtract value
from every vector entry
+ void operator-=(double value)
+ { row_ -= value; }
+
+ /// multiply every vector entry by value
+ void operator*=(double value)
+ { row_ *= value; }
+
+ /// divide every vector entry by value
+ void operator/=(double value)
+ { row_ /= value; }
+ //@}
+
+ /// Allow access row sorting function
+ void sortIncrIndex()
+ {row_.sortIncrIndex();}
+
+ /**@name Constructors and destructors */
+ //@{
+ /// Assignment operator
+ OsiRowCut & operator=( const OsiRowCut& rhs);
+
+ /// Copy constructor
+ OsiRowCut ( const OsiRowCut &);
+
+ /// Clone
+ virtual OsiRowCut * clone() const;
+
+ /// Default Constructor
+ OsiRowCut ();
+
+ /** \brief Ownership Constructor
+
+ This constructor assumes ownership of the vectors passed as parameters
+ for indices and elements. \p colIndices and \p elements will be NULL
+ on return.
+ */
+ OsiRowCut(double cutlb, double cutub,
+ int capacity, int size,
+ int *&colIndices, double *&elements);
+
+ /// Destructor
+ virtual ~OsiRowCut ();
+ //@}
+
+ /**@name Debug stuff */
+ //@{
+ /// Print cuts in collection
+ virtual void print() const ;
+ //@}
+
+private:
+
+
+ /**@name Private member data */
+ //@{
+ /// Row elements
+ CoinPackedVector row_;
+ /// Row lower bound
+ double lb_;
+ /// Row upper bound
+ double ub_;
+ //@}
+};
+
+#ifdef OSI_INLINE_ROWCUT_METHODS
+
+//-------------------------------------------------------------------
+// Set/Get lower & upper bounds
+//-------------------------------------------------------------------
+double OsiRowCut::lb() const { return lb_; }
+void OsiRowCut::setLb(double lb) { lb_ = lb; }
+double OsiRowCut::ub() const { return ub_; }
+void OsiRowCut::setUb(double ub) { ub_ = ub; }
+
+//-------------------------------------------------------------------
+// Set row elements
+//-------------------------------------------------------------------
+void OsiRowCut::setRow(int size,
+ const int * colIndices, const double * elements)
+{
+ row_.setVector(size,colIndices,elements);
+}
+void OsiRowCut::setRow( const CoinPackedVector & v )
+{
+ row_ = v;
+}
+
+//-------------------------------------------------------------------
+// Get the row
+//-------------------------------------------------------------------
+const CoinPackedVector & OsiRowCut::row() const
+{
+ return row_;
+}
+
+//-------------------------------------------------------------------
+// Get the row so we can change
+//-------------------------------------------------------------------
+CoinPackedVector & OsiRowCut::mutableRow()
+{
+ return row_;
+}
+
+//----------------------------------------------------------------
+// == operator
+//-------------------------------------------------------------------
+bool
+OsiRowCut::operator==(const OsiRowCut& rhs) const
+{
+ if ( this->OsiCut::operator!=(rhs) ) return false;
+ if ( row() != rhs.row() ) return false;
+ if ( lb() != rhs.lb() ) return false;
+ if ( ub() != rhs.ub() ) return false;
+ return true;
+}
+bool
+OsiRowCut::operator!=(const OsiRowCut& rhs) const
+{
+ return !( (*this)==rhs );
+}
+
+
+//----------------------------------------------------------------
+// consistent & infeasible
+//-------------------------------------------------------------------
+bool OsiRowCut::consistent() const
+{
+ const CoinPackedVector & r=row();
+ r.duplicateIndex("consistent", "OsiRowCut");
+ if ( r.getMinIndex() < 0 ) return false;
+ return true;
+}
+bool OsiRowCut::consistent(const OsiSolverInterface& im) const
+{
+ const CoinPackedVector & r=row();
+ if ( r.getMaxIndex() >= im.getNumCols() ) return false;
+
+ return true;
+}
+bool OsiRowCut::infeasible(const OsiSolverInterface &im) const
+{
+ if ( lb() > ub() ) return true;
+
+ return false;
+}
+
+#endif
+
+/** Row Cut Class which refers back to row which created it.
+ It may be useful to strengthen a row rather than add a cut. To do this
+ we need to know which row is strengthened. This trivial extension
+ to OsiRowCut does that.
+
+*/
+class OsiRowCut2 : public OsiRowCut {
+
+public:
+
+ /**@name Which row */
+ //@{
+ /// Get row
+ inline int whichRow() const
+ { return whichRow_;}
+ /// Set row
+ inline void setWhichRow(int row)
+ { whichRow_=row;}
+ //@}
+
+ /**@name Constructors and destructors */
+ //@{
+ /// Assignment operator
+ OsiRowCut2 & operator=( const OsiRowCut2& rhs);
+
+ /// Copy constructor
+ OsiRowCut2 ( const OsiRowCut2 &);
+
+ /// Clone
+ virtual OsiRowCut * clone() const;
+
+ /// Default Constructor
+ OsiRowCut2 (int row=-1);
+
+ /// Destructor
+ virtual ~OsiRowCut2 ();
+ //@}
+
+private:
+
+
+ /**@name Private member data */
+ //@{
+ /// Which row
+ int whichRow_;
+ //@}
+};
+#endif
--
cgit