- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

BcpsModel.h
Go to the documentation of this file.
1 /*===========================================================================*
2 * This file is part of the Branch, Constrain and Price Software (BiCePS) *
3 * *
4 * BiCePS 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 * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
20 * All Rights Reserved. *
21 *===========================================================================*/
22
23 #ifndef BcpsModel_h_
24 #define BcpsModel_h_
25
26 //#############################################################################
27
28 #include <vector>
29
30 #include "CoinMessageHandler.hpp"
31
32 #include "AlpsModel.h"
33 #include "AlpsKnowledgeBroker.h"
34
35 #include "BcpsMessage.h"
36 #include "BcpsObject.h"
37
38 //#############################################################################
39
40 class BcpsModel : public AlpsModel {
41
42 protected:
43
45 std::vector<BcpsConstraint *> constraints_;
46
48 std::vector<BcpsVariable *> variables_;
49
50
54 int numCoreConstraints_;
55
57 int numCoreVariables_;
58
60 CoinMessageHandler * bcpsMessageHandler_;
61
63 CoinMessages bcpsMessages_;
64
65 public:
66
67 BcpsModel()
68 :
69 numCoreConstraints_(0),
70 numCoreVariables_(0)
71 {
72 bcpsMessageHandler_ = new CoinMessageHandler();
73 bcpsMessageHandler_->setLogLevel(2);
74 bcpsMessages_ = BcpsMessage();
75 }
76
77 virtual ~BcpsModel() {
78 int i = 0;
79 int size = static_cast<int> (constraints_.size());
80 for (i = 0; i < size; ++i) {
81 delete constraints_[i];
82 }
83 size = static_cast<int> (variables_.size());
84 for (i = 0; i < size; ++i) {
85 delete variables_[i];
86 }
87 delete bcpsMessageHandler_;
88 }
89
92 std::vector<BcpsConstraint *> & getConstraints() { return constraints_; }
93 std::vector<BcpsVariable *> & getVariables() { return variables_; }
94
95 int getNumCoreConstraints() const { return numCoreConstraints_; }
96 int getNumCoreVariables() const { return numCoreVariables_; }
101 void setConstraints(BcpsConstraint **con, int size) {
102 for (int j = 0; j < size; ++j) {
103 constraints_.push_back(con[j]);
104 }
105 }
106 void setNumCoreConstraints(int num) { numCoreConstraints_ = num; }
107
108 void setVariables(BcpsVariable **var, int size) {
109 for (int j = 0; j < size; ++j) {
110 variables_.push_back(var[j]);
111 }
112 }
113 void setNumCoreVariables(int num) { numCoreVariables_ = num; }
117 std::vector<BcpsVariable *> getVariables() const { return variables_; }
118
120 std::vector<BcpsConstraint *> getConstrints() const { return constraints_; }
121
123 CoinMessageHandler * bcpsMessageHandler() const
124 { return bcpsMessageHandler_; }
125
127 CoinMessages bcpsMessages() { return bcpsMessages_; }
128
129
131 AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const;
132
134 AlpsReturnStatus decodeBcps(AlpsEncoded &encoded);
135
136 };
137
138
139 #endif
BcpsModel::variables_
std::vector< BcpsVariable * > variables_
Variables input by users (before preprocessing).
Definition: BcpsModel.h:48
BcpsModel::getConstraints
std::vector< BcpsConstraint * > & getConstraints()
Get variables and constraints.
Definition: BcpsModel.h:92
BcpsModel::~BcpsModel
virtual ~BcpsModel()
Definition: BcpsModel.h:77
CoinMessageHandler
Base class for message handling.
Definition: CoinMessageHandler.hpp:327
BcpsModel::numCoreVariables_
int numCoreVariables_
Number of core variables.
Definition: BcpsModel.h:57
BcpsModel::setNumCoreConstraints
void setNumCoreConstraints(int num)
Set variables and constraints.
Definition: BcpsModel.h:106
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:118
BcpsModel::getConstrints
std::vector< BcpsConstraint * > getConstrints() const
Return list of constraints.
Definition: BcpsModel.h:120
BcpsVariable
Definition: BcpsObject.h:383
BcpsModel::setNumCoreVariables
void setNumCoreVariables(int num)
Set variables and constraints.
Definition: BcpsModel.h:113
AlpsModel.h
AlpsModel
Definition: AlpsModel.h:36
BcpsModel::encodeBcps
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack Bcps portion of model into an encoded object.
BcpsMessage
Definition: BcpsMessage.h:43
BcpsModel::getVariables
std::vector< BcpsVariable * > getVariables() const
Return list of variables.
Definition: BcpsModel.h:117
BcpsModel::bcpsMessageHandler_
CoinMessageHandler * bcpsMessageHandler_
Message handler.
Definition: BcpsModel.h:60
BcpsModel::bcpsMessageHandler
CoinMessageHandler * bcpsMessageHandler() const
Get the message handler.
Definition: BcpsModel.h:123
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
BcpsModel::decodeBcps
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
Unpack Bcps portion of model from an encoded object.
BcpsModel::getVariables
std::vector< BcpsVariable * > & getVariables()
Get variables and constraints.
Definition: BcpsModel.h:93
BcpsConstraint
Definition: BcpsObject.h:355
BcpsModel::numCoreConstraints_
int numCoreConstraints_
Number of core constraints.
Definition: BcpsModel.h:54
BcpsModel::getNumCoreConstraints
int getNumCoreConstraints() const
Get variables and constraints.
Definition: BcpsModel.h:95
BcpsModel::setConstraints
void setConstraints(BcpsConstraint **con, int size)
Set variables and constraints.
Definition: BcpsModel.h:101
BcpsObject.h
BcpsMessage.h
BcpsModel
Definition: BcpsModel.h:40
CoinMessageHandler.hpp
This is a first attempt at a message handler.
CoinMessages
Class to hold and manipulate an array of massaged messages.
Definition: CoinMessageHandler.hpp:128
BcpsModel::constraints_
std::vector< BcpsConstraint * > constraints_
Constraints input by users (before preprocessing).
Definition: BcpsModel.h:45
BcpsModel::getNumCoreVariables
int getNumCoreVariables() const
Get variables and constraints.
Definition: BcpsModel.h:96
AlpsKnowledgeBroker.h
CoinMessageHandler::setLogLevel
void setLogLevel(int value)
Set current log (detail) level.
BcpsModel::BcpsModel
BcpsModel()
Definition: BcpsModel.h:67
BcpsModel::bcpsMessages_
CoinMessages bcpsMessages_
Bcps messages.
Definition: BcpsModel.h:63
BcpsModel::setVariables
void setVariables(BcpsVariable **var, int size)
Set variables and constraints.
Definition: BcpsModel.h:108
BcpsModel::bcpsMessages
CoinMessages bcpsMessages()
Return messages.
Definition: BcpsModel.h:127