Bcps 0.95.1
Loading...
Searching...
No Matches
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-2023, 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 "BcpsConfig.h"
36#include "BcpsMessage.h"
37#include "BcpsObject.h"
38
39//#############################################################################
40
41class BCPSLIB_EXPORT BcpsModel : public AlpsModel {
42
43 protected:
44
46 std::vector<BcpsConstraint *> constraints_;
47
49 std::vector<BcpsVariable *> variables_;
50
51
56
59
61 CoinMessageHandler * bcpsMessageHandler_;
62
64 CoinMessages bcpsMessages_;
65
66 public:
67
69 :
70 numCoreConstraints_(0),
71 numCoreVariables_(0)
72 {
73 bcpsMessageHandler_ = new CoinMessageHandler();
74 bcpsMessageHandler_->setLogLevel(2);
75 bcpsMessages_ = BcpsMessage();
76 }
77
78 virtual ~BcpsModel() {
79 int i = 0;
80 int size = static_cast<int> (constraints_.size());
81 for (i = 0; i < size; ++i) {
82 delete constraints_[i];
83 }
84 size = static_cast<int> (variables_.size());
85 for (i = 0; i < size; ++i) {
86 delete variables_[i];
87 }
88 delete bcpsMessageHandler_;
89 }
90
93 std::vector<BcpsConstraint *> & getConstraints() { return constraints_; }
94 std::vector<BcpsVariable *> & getVariables() { return variables_; }
95
96 int getNumCoreConstraints() const { return numCoreConstraints_; }
97 int getNumCoreVariables() const { return numCoreVariables_; }
102 void setConstraints(BcpsConstraint **con, int size) {
103 for (int j = 0; j < size; ++j) {
104 constraints_.push_back(con[j]);
105 }
106 }
107 void setNumCoreConstraints(int num) { numCoreConstraints_ = num; }
108
109 void setVariables(BcpsVariable **var, int size) {
110 for (int j = 0; j < size; ++j) {
111 variables_.push_back(var[j]);
112 }
113 }
114 void setNumCoreVariables(int num) { numCoreVariables_ = num; }
118 std::vector<BcpsVariable *> getVariables() const { return variables_; }
119
121 std::vector<BcpsConstraint *> getConstrints() const { return constraints_; }
122
124 CoinMessageHandler * bcpsMessageHandler() const
125 { return bcpsMessageHandler_; }
126
128 CoinMessages bcpsMessages() { return bcpsMessages_; }
129
130
132 AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const;
133
135 AlpsReturnStatus decodeBcps(AlpsEncoded &encoded);
136
137};
138
139
140#endif
int getNumCoreConstraints() const
Definition BcpsModel.h:96
std::vector< BcpsVariable * > variables_
Variables input by users (before preprocessing).
Definition BcpsModel.h:49
CoinMessageHandler * bcpsMessageHandler_
Message handler.
Definition BcpsModel.h:61
void setNumCoreVariables(int num)
Definition BcpsModel.h:114
CoinMessageHandler * bcpsMessageHandler() const
Get the message handler.
Definition BcpsModel.h:124
int numCoreVariables_
Number of core variables.
Definition BcpsModel.h:58
std::vector< BcpsConstraint * > & getConstraints()
Get variables and constraints.
Definition BcpsModel.h:93
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack Bcps portion of model into an encoded object.
int getNumCoreVariables() const
Definition BcpsModel.h:97
std::vector< BcpsConstraint * > getConstrints() const
Return list of constraints.
Definition BcpsModel.h:121
CoinMessages bcpsMessages()
Return messages.
Definition BcpsModel.h:128
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
Unpack Bcps portion of model from an encoded object.
virtual ~BcpsModel()
Definition BcpsModel.h:78
void setConstraints(BcpsConstraint **con, int size)
Set variables and constraints.
Definition BcpsModel.h:102
CoinMessages bcpsMessages_
Bcps messages.
Definition BcpsModel.h:64
void setVariables(BcpsVariable **var, int size)
Definition BcpsModel.h:109
int numCoreConstraints_
Number of core constraints.
Definition BcpsModel.h:55
std::vector< BcpsConstraint * > constraints_
Constraints input by users (before preprocessing).
Definition BcpsModel.h:46
void setNumCoreConstraints(int num)
Definition BcpsModel.h:107
std::vector< BcpsVariable * > & getVariables()
Definition BcpsModel.h:94
std::vector< BcpsVariable * > getVariables() const
Return list of variables.
Definition BcpsModel.h:118
#define BCPSLIB_EXPORT
Definition config.h:5