BlisConstraint.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the BiCePS Linear Integer Solver (BLIS). *
3  * *
4  * BLIS is distributed under the Eclipse Public License as part of the *
5  * COIN-OR repository (http://www.coin-or.org). *
6  * *
7  * Authors: *
8  * *
9  * Yan Xu, Lehigh University *
10  * Ted Ralphs, Lehigh University *
11  * *
12  * Conceptual Design: *
13  * *
14  * Yan Xu, Lehigh University *
15  * Ted Ralphs, Lehigh University *
16  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17  * Matthew Saltzman, Clemson University *
18  * *
19  * *
20  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21  * All Rights Reserved. *
22  *===========================================================================*/
23 
24 #ifndef BlisConstraint_h_
25 #define BlisConstraint_h_
26 
27 #include "BcpsObject.h"
28 
29 class OsiRowCut;
30 
31 //#############################################################################
32 
33 class BlisConstraint : public BcpsConstraint {
34 
35  protected:
37  int size_;
39  int *indices_;
41  double *values_;
42 
43  public:
44 
47 
49  BlisConstraint(int s, const int *ind, const double *val);
50 
52  BlisConstraint(double lbh, double ubh, double lbs, double ubs);
53 
55  BlisConstraint(double lbh, double ubh, double lbs, double ubs,
56  int size, const int *ind, const double *val);
58  virtual ~BlisConstraint();
59 
61  BlisConstraint(const BlisConstraint & rhs);
62 
65  int getSize() const { return size_; }
66  int* getIndices() const { return indices_; }
67  double* getValues() const { return values_; }
72  void setData(int s, const int *ind, const double *val) {
73  if (size_ < s) {
74  delete [] indices_;
75  delete [] values_;
76  indices_ = new int [s];
77  values_ = new double [s];
78  }
79  size_ = s;
80  memcpy(indices_, ind, sizeof(int) * s);
81  memcpy(values_, val, sizeof(double) * s);
82  }
85  protected:
86 
89 
92 
93  public:
94 
97 
99  virtual void hashing(BcpsModel *model=NULL);
100 
102  double violation(const double *lpSolution);
103 
104  using AlpsKnowledge::encode ;
106  virtual AlpsReturnStatus encode(AlpsEncoded *encoded);
107 
109  virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const;
110 };
111 
112 //#############################################################################
113 
114 #endif
double * values_
Value of nonzero coefficients.
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
Decode a constraint from an encoded object.
void setData(int s, const int *ind, const double *val)
Set data.
int * getIndices() const
Return data.
Row Cut Class.
Definition: OsiRowCut.hpp:29
AlpsReturnStatus
Definition: Alps.h:118
BlisConstraint()
Default constructor.
double * getValues() const
Return data.
int * indices_
Variable indices.
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
double violation(const double *lpSolution)
Check if violates a given lp solution.
int getSize() const
Return data.
int size_
Number of nonzero coefficients.
OsiRowCut * createOsiRowCut()
Create a OsiRowCut based on this constraint.
AlpsReturnStatus decodeBlis(AlpsEncoded &encoded)
Unpack Blis part from a encode object.
virtual ~BlisConstraint()
Destructor.
AlpsReturnStatus encodeBlis(AlpsEncoded *encoded)
Pack Blis part into an encoded object.
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
virtual void hashing(BcpsModel *model=NULL)
Compute a hash key.
virtual AlpsEncoded * encode() const
This method should encode the content of the object and return a pointer to the encoded form...