-
Notifications
You must be signed in to change notification settings - Fork 0
/
PenalizingSubnetworks.h
85 lines (70 loc) · 2.85 KB
/
PenalizingSubnetworks.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
/*
Copyright 2021
Alexander Belyi <alexander.belyi@gmail.com>,
Stanislav Sobolevsky <sobolevsky@nyu.edu>
This file is part of BestPartition project.
BestPartition is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BestPartition is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BestPartition. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PENALIZING_SUBNETWORKS_H
#define PENALIZING_SUBNETWORKS_H
#include <vector>
struct Edge
{
size_t node1, node2;
double weight;
Edge(size_t n1, size_t n2, double w) : node1(n1), node2(n2), weight(w) {}
bool operator<(const Edge& e) const
{
return weight < e.weight;
}
bool operator>(const Edge& e) const
{
return weight > e.weight;
}
};
struct PenalizingChain
{
std::vector<size_t> chain;
std::vector<double> weights;
double penalty;
Edge operator[](size_t index) const
{
if(index + 1 == chain.size())
return {chain[0], chain[chain.size()-1], weights[index]};
return {chain[index], chain[index+1], weights[index]};
}
size_t size() const
{
return chain.size();
}
};
double AddPenalizingChainsHeuristic(size_t chain_len,
std::vector<PenalizingChain>& chains,
Matrix& Q,
const MatrixInt& fixedEdges,
int text_level);
double AddPenalizingChainsLP(const std::vector<PenalizingChain>& old_chains,
std::vector<PenalizingChain>& chains,
const Matrix& Q,
const MatrixInt& fixedEdges,
int max_chain_len,
bool only_nonzero_solution,
bool prefer_cplex,
int text_level);
double GetPenaltyUsingChainsAndStars(const Matrix& Q,
const MatrixInt& fixedEdges,
int max_chain_len,
bool prefer_cplex,
int text_level);
bool OnlyPositiveEdgesInPositiveConnComp(const Matrix& Q, const MatrixInt& fixedEdges);
bool OnlyPositiveEdgesInPositiveConnComp(const Matrix& Q);
#endif //PENALIZING_SUBNETWORKS_H