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
// IPBend.hpp
// Interval Assignment Data for Meshkit
//
// Data for defining an objective function that is piecewise linear and bends at integer points
//

#ifndef MESHKIT_IA_IPBEND_HP
#define MESHKIT_IA_IPBEND_HP

#include <vector>
#include <limits>

namespace MeshKit 
{

class IPBend
{
public:
  // index of delta, magnitude of tilt = weight multiplier
  // note tilt is applied to that delta and all subsequent ones
  typedef std::pair<unsigned int, double> IPTilt;
  typedef std::vector< IPTilt > TiltVec;
  
  /** constructor */
  IPBend() :<--- Member variable 'IPBend::xl' is not initialized in the constructor.
    deltaIStart(0), numDeltaPlus(1), numDeltaMinus(1), 
    plusTilts(), minusTilts()  // usually these vecs are empty
  {}
  
  /** default destructor */
  virtual ~IPBend() {}
  
  // index i of x[i] or sum-even constraint i is implicitly defined by position in IPBendVec

  int xl; // x value if all deltas are zero
  
  int deltaIStart; // index of the first delta variables in the Nlp

  // delta0 is always defined, one of them
  int numDeltaPlus; // number of plus deltas defined
  int numDeltaMinus; // number of minus deltas defined
  int num_deltas() const 
    {return numDeltaPlus + numDeltaMinus; } 
  
  // x = xl + sum ( deltas_plus ) - sum (deltas_minus );
  // delta_plus[k] for k < numDeltaPlus + 1 is in [0,1], last is [0,infinity]
  
  static int num_deltas_max() 
  { return std::numeric_limits<int>::max()/2 - 2; }
  
  // sorted tilts, for x > g and x < g
  TiltVec plusTilts, minusTilts; 
  
};

typedef std::vector< IPBend > IPBendVec;
  
class IPBendData
{
public:
  IPBendVec bendVec;
  int numSumVars;
  int sumVarStart;
  double maxActiveVarWeight;
};
  
// default constructors for object and its members OK
// inline IPData::IPData() {} 

// default destructor OK

} // namespace MeshKit 

#endif