Skip to content

Commit 6d18baa

Browse files
committed
Hot Start
1 parent 98fbdf4 commit 6d18baa

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

src/ilppmhprsolver.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -734,28 +734,28 @@ GRBLinExpr IlpPmhPrSolver::initObjective(const IntTriple& bounds)
734734
obj += migrationNumber
735735
+ (1. / (nrAnatomicalSites * nrAnatomicalSites)) * comigrationNumber;
736736

737-
double factor = (1. / (nrAnatomicalSites * nrAnatomicalSites))
738-
* (1. / (nrNodes * nrNodes));
739-
740-
for (NodeIt v_i(getTree()); v_i != lemon::INVALID; ++v_i)
741-
{
742-
const int i = (*_pNodeToIndex)[v_i];
743-
for (int s = 0; s < nrAnatomicalSites; ++s)
744-
{
745-
const int size_L_s = _L[s].size();
746-
for (int c = 0; c < size_L_s; ++c)
747-
{
748-
for (int t = 0; t < nrAnatomicalSites; ++t)
749-
{
750-
const int size_L_t = _L[t].size();
751-
for (int d = 0; d < size_L_t; ++d)
752-
{
753-
obj += factor * _x[i][s][c];
754-
}
755-
}
756-
}
757-
}
758-
}
737+
// double factor = (1. / (nrAnatomicalSites * nrAnatomicalSites))
738+
// * (1. / (nrNodes * nrNodes));
739+
//
740+
// for (NodeIt v_i(getTree()); v_i != lemon::INVALID; ++v_i)
741+
// {
742+
// const int i = (*_pNodeToIndex)[v_i];
743+
// for (int s = 0; s < nrAnatomicalSites; ++s)
744+
// {
745+
// const int size_L_s = _L[s].size();
746+
// for (int c = 0; c < size_L_s; ++c)
747+
// {
748+
// for (int t = 0; t < nrAnatomicalSites; ++t)
749+
// {
750+
// const int size_L_t = _L[t].size();
751+
// for (int d = 0; d < size_L_t; ++d)
752+
// {
753+
// obj += factor * _x[i][s][c];
754+
// }
755+
// }
756+
// }
757+
// }
758+
// }
759759

760760
GRBLinExpr seedingSiteNumber;
761761
for (int s = 0; s < nrAnatomicalSites; ++s)
@@ -768,9 +768,9 @@ GRBLinExpr IlpPmhPrSolver::initObjective(const IntTriple& bounds)
768768
_model.addConstr(seedingSiteNumber <= bounds.second.second);
769769
}
770770

771-
factor = (1. / (nrAnatomicalSites * nrAnatomicalSites))
772-
* (1. / (nrNodes * nrNodes))
773-
* (1. / (nrAnatomicalSites + 1));
771+
double factor = (1. / (nrAnatomicalSites * nrAnatomicalSites))
772+
// * (1. / (nrNodes * nrNodes))
773+
* (1. / (nrAnatomicalSites + 1));
774774

775775
obj += factor * seedingSiteNumber;
776776

src/ilppmhsolver.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,33 @@ void IlpPmhSolver::init(const IntTriple& bounds)
6464
initLeafConstraints();
6565
initObjective(bounds);
6666
initCallbacks();
67+
initWarmStart();
68+
}
69+
70+
void IlpPmhSolver::initWarmStart()
71+
{
72+
const int nrAnatomicalSites = _anatomicalSiteToIndex.size();
73+
for (NodeIt v_i(getTree()); v_i != lemon::INVALID; ++v_i)
74+
{
75+
if (isLeaf(v_i)) continue;
76+
77+
const int i = (*_pNodeToIndex)[v_i];
78+
for (int s = 0; s < nrAnatomicalSites; ++s)
79+
{
80+
const int size_L_s = _L[s].size();
81+
for (int c = 0; c < size_L_s; ++c)
82+
{
83+
if (s == _primaryIndex && c == 0)
84+
{
85+
_x[i][s][c].set(GRB_DoubleAttr_Start, 1);
86+
}
87+
else
88+
{
89+
_x[i][s][c].set(GRB_DoubleAttr_Start, 0);
90+
}
91+
}
92+
}
93+
}
6794
}
6895

6996
void IlpPmhSolver::initIndices()

src/ilppmhsolver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ class IlpPmhSolver
155155
/// Initialize ILP S constraints
156156
virtual void initSingleSourceSeedingConstraints();
157157

158+
/// Initialize initial solution
159+
virtual void initWarmStart();
160+
158161
/// Initialize ILP objective function
159162
///
160163
/// @param bounds Upper bounds on mu, gamma and sigma

0 commit comments

Comments
 (0)