-
Notifications
You must be signed in to change notification settings - Fork 0
/
grb.h
91 lines (75 loc) · 1.99 KB
/
grb.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// Created by nandgate on 6/5/24.
//
//#ifndef SGUFP_SOLVER_GRB_H
//#define SGUFP_SOLVER_GRB_H
#pragma once
#include "gurobi_c++.h"
#include "Network.h"
#include <vector>
#include "Cut.h"
#include <memory>
using namespace std;
class GuroSolver{
const shared_ptr<Network> networkPtr;
public:
GRBEnv environment;
int n;
// gurobi variables
// GRBVar* alpha;
// GRBVar** beta;
// GRBVar** gamma;
// GRBVar** sigma;
// GRBVar** phi;
// GRBVar*** lambda;
// GRBVar*** mu;
// GRBModel model;
GuroSolver(const shared_ptr<Network>& networkPtr_, const GRBEnv& env_): networkPtr{networkPtr_},
environment(env_), n{static_cast<int>(networkPtr_->n)}/*, model {environment}*/ {
// set model parameters and initialize gurobi variables.
// model.set(GRB_IntParam_InfUnbdInfo, 1);
// alpha = model.addVars(n, GRB_CONTINUOUS);
// beta = new GRBVar*[n];
// gamma = new GRBVar*[n];
// sigma = new GRBVar*[n];
// phi = new GRBVar*[n];
// lambda = new GRBVar**[n];
// mu = new GRBVar**[n];
}
void initializeVariables();
Cut solveSubProblem(const vector<vector<vector<shi>>> &y_bar);
Cut solveSubProblemInstance(const vector<vector<vector<shi>>> &y_bar, int scenario);
void addConstraints(const Network& network, int scenario);
void setObjectiveFunction(const Network &network, const vector<vector<vector<shi>>> &y, int scenario);
~GuroSolver(){
// clear up the heap.
#ifdef DEBUG
// cout << "Cleaning up gurobi variables... ";
#endif
// for (int i = 0; i < n; i++){
// delete[](beta[i]);
// delete[](gamma[i]);
// delete[](sigma[i]);
// delete[](phi[i]);
//
// for (int j = 0; j < n; j++){
// delete[](lambda[i][j]);
// delete[](mu[i][j]);
// }
// delete[](lambda[i]);
// delete[](mu[i]);
// }
//
// delete[](alpha);
// delete[](beta);
// delete[](gamma);
// delete[](sigma);
// delete[](phi);
// delete[](lambda);
// delete[](mu);
#ifdef DEBUG
// cout << " Completed." << endl;
#endif
}
};
//#endif //SGUFP_SOLVER_GRB_H