6 #include "CoinSort.hpp"
30 double* coefs =
new double[
n];
31 int* posedges =
new int[
n];
32 int* negedges =
new int[
n];
51 int* randomorder =
new int[
m];
52 CoinIotaN(randomorder, m, 0);
53 std::random_shuffle(randomorder, randomorder + m);
55 for (
int l = 0; l <
m; ++l) {
56 const int k = randomorder[l];
57 const int i = edges[
k].
tail;
58 const int j = edges[
k].
head;
60 if (parentnode[i] == j || parentnode[j] == i)
64 if ((nodesign[i] == nodesign[j] && x[k] < .3) ||
65 (nodesign[i] != nodesign[j] && x[k] > .7))
73 for (ii = i; ii != -1; ii = parentnode[ii]) {
77 for (jj = j; jj != -1; jj = parentnode[jj]) {
84 for (ii = nodepathi.
size()-1, jj = nodepathj.
size()-1;
85 ii >= 0 && jj >= 0; --ii, --jj) {
86 if (nodepathi[ii] != nodepathj[jj])
94 if (nodesign[i] == nodesign[j]) {
101 for ( ; ii >= 0; --ii) {
102 const int p0 = nodepathi[ii];
103 const int p1 = nodepathi[ii+1];
104 const int path_ind = edgepathi[ii];
105 if (nodesign[p0] == nodesign[p1]) {
107 negedges[neg++] = path_ind;
110 posedges[pos++] = path_ind;
113 for ( ; jj >= 0; --jj) {
114 const int p0 = nodepathj[jj];
115 const int p1 = nodepathj[jj+1];
116 const int path_ind = edgepathj[jj];
117 if (nodesign[p0] == nodesign[p1]) {
119 negedges[neg++] = path_ind;
122 posedges[pos++] = path_ind;
125 if (sum <= pos - 1.0 + minviol)
131 const int len = pos + neg;
132 CoinDisjointCopyN(negedges, neg, posedges + pos);
134 CoinFillN(coefs, pos, 1.0);
135 CoinFillN(coefs + pos, neg, -1.0);
136 CoinSort_2(posedges, posedges + len, coefs);
139 if (static_cast<int>(new_cuts.
size()) >= maxnewcuts)
143 delete[] randomorder;
153 const double alpha,
const double beta,
155 const int heurswitchround,
156 const bool do_edge_switch_heur,
const int struct_switch_heur,
157 const double minviol,
const int maxnewcuts,
172 switch (edge_ordering) {
174 if (w == NULL || beta == 0.0) {
175 for (i = 0; i <
m; ++i)
178 for (i = 0; i <
m; ++i)
183 if (w == NULL || beta == 0.0) {
184 for (i = 0; i <
m; ++i)
187 for (i = 0; i <
m; ++i)
192 if (w == NULL || beta == 0.0) {
193 for (i = 0; i <
m; ++i)
196 for (i = 0; i <
m; ++i)
201 for (i = 0; i <
m; ++i)
204 CoinSort_2(weights.
begin(), weights.
end(), edgeorder.
begin());
211 parentnode.begin(), parentedge.
begin());
215 if (static_cast<int>(new_cuts.
size()) < maxnewcuts)
217 nodesign, parentnode, parentedge,
218 maxnewcuts, new_cuts, new_rows);
222 do_edge_switch_heur, struct_switch_heur);
MC_solution * MC_mst_cutgen(const MC_problem &mc, const double *x, const double *w, const double alpha, const double beta, const MC_EdgeOrdering edge_ordering, const int heurswitchround, const bool do_edge_switch_heur, const int struct_switch_heur, const double minviol, const int maxnewcuts, BCP_vec< BCP_cut * > &new_cuts, BCP_vec< BCP_row * > &new_rows)
void MC_cuts_from_mst(const MC_problem &mc, const double *x, const double minviol, const BCP_vec< int > &nodesign, const BCP_vec< int > &parentnode, const BCP_vec< int > &parentedge, const int maxnewcuts, BCP_vec< BCP_cut * > &new_cuts, BCP_vec< BCP_row * > &new_rows)
pos
position where the operator should be printed when printing the expression
void clear()
Delete every entry.
iterator begin()
Return an iterator to the beginning of the object.
void reserve(const size_t n)
Reallocate the object to make space for n entries.
void MC_kruskal(const MC_problem &mc, const int *edgeorder, const double *x, int *nodesign, int *edges_in_tree)
void push_back(const_reference x)
Append x to the end of the vector.
size_t size() const
Return the current number of entries.
iterator end()
Return an iterator to the end of the object.
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
void fint fint fint real fint real real real real real real real real * w
void fint fint fint real fint real * x
This class holds a row in a compressed form.