Skip to content

Commit

Permalink
upper bound output and gap objective
Browse files Browse the repository at this point in the history
  • Loading branch information
Aszarsha committed Dec 16, 2014
1 parent fee19da commit d0ff8af
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/Solver.cpp
Expand Up @@ -85,6 +85,7 @@ namespace xHeinz {
);

OutputSolution sol;
sol.upperBound = cplex.getBestObjValue();
sol.weight = score1 + score2;
sol.alpha = get< 0 >( alphas );
sol.graphsSolutions.emplace_back( move( sol1 ), score1, get< 1 >( alphas ) );
Expand Down Expand Up @@ -654,6 +655,11 @@ namespace xHeinz {
cplex.setParam( IloCplex::Threads, config.numThreads );
}

if ( config.gapObjective >= 0 ) {
cplex.setParam( IloCplex::EpGap, config.gapObjective );
cplex.setParam( IloCplex::MIPEmphasis, 1 );
}

cplex.setParam( IloCplex::HeurFreq , -1 );
cplex.setParam( IloCplex::Cliques , -1 );
cplex.setParam( IloCplex::Covers , -1 );
Expand Down
3 changes: 2 additions & 1 deletion src/Solver/Config.cpp
Expand Up @@ -22,7 +22,8 @@ namespace solver {
out << "\n-- size = " << config.size
<< "\n-- time limit = " << config.timeLimit
<< "\n-- root time limit = " << config.rootTimeLimit
<< "\n-- # threads = " << config.numThreads;
<< "\n-- # threads = " << config.numThreads
<< "\n-- gap objective = " << config.gapObjective;
return out;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Solver/Config.hpp
Expand Up @@ -23,6 +23,7 @@ namespace solver {
int maxCutIterations;
double timeLimit;
double rootTimeLimit;
double gapObjective;

Config( double cp = 0.6
, std::array< double, 2 > pp = std::array< double, 2 >{ 0.0, 0.0 }
Expand All @@ -32,6 +33,7 @@ namespace solver {
, int mi = 20
, double tl = std::numeric_limits< double >::infinity()
, double rtl = std::numeric_limits< double >::infinity()
, double go = -1
)
: connectivityPercentage{ cp }
, positivePercentage( pp )
Expand All @@ -40,7 +42,8 @@ namespace solver {
, size{ s }
, maxCutIterations{ mi }
, timeLimit{ tl }
, rootTimeLimit{ rtl } {
, rootTimeLimit{ rtl }
, gapObjective{ go } {
}

friend std::ostream & operator<<( std::ostream & out, Config const & conf );
Expand Down
1 change: 1 addition & 0 deletions src/Solver/Solution.cpp
Expand Up @@ -33,6 +33,7 @@ namespace solver {
out << get< 1 >( gs );
});
out << ")";
out << "\n-- Objective UpperBound = " << sol.upperBound;

for ( int i = 0, e = sol.graphsSolutions.size(); i != e; ++i ) {
auto const & graphSol = sol.graphsSolutions[i];
Expand Down
1 change: 1 addition & 0 deletions src/Solver/Solution.hpp
Expand Up @@ -16,6 +16,7 @@ namespace solver {
using SolutionSet = std::vector< NodeBoolPair >;
using GraphSolution = std::tuple< SolutionSet, WeightScore, AlphaScore >;

WeightScore upperBound;
WeightScore weight;
AlphaScore alpha;
std::vector< GraphSolution > graphsSolutions;
Expand Down
10 changes: 9 additions & 1 deletion src/xHeinz.cpp
Expand Up @@ -36,7 +36,7 @@ int main( int argc, char * argv[] ) {
.refOption( "a", "Conservation ratio threshold (default: 0.6)"
, config.connectivityPercentage, false
)
.synonym("alpha", "a" )
.synonym( "alpha", "a" )
#if 0
.refOption( "b1", "Graph 1: positive node ratio threshold (default: 0.0) TODO"
, config.positivePercentage[0], false
Expand All @@ -47,6 +47,9 @@ int main( int argc, char * argv[] ) {
)
.synonym("beta2", "b2" )
#endif
.refOption( "gap", "Specifies the target gap (in [0, 1] or < 0 for disabled, default: -1)"
, config.gapObjective, false
)
.refOption( "w", "Specifies the type of mapping weighting:\n"
" 0 - Sum mapped nodes (default)\n"
" 1 - Sum mapped node weights\n"
Expand Down Expand Up @@ -113,6 +116,11 @@ int main( int argc, char * argv[] ) {
config.connectivityType =
static_cast< solver::Config::ConnectivityType >(connectivityType);

if ( config.gapObjective > 1 ) {
cerr << "Invalid omega (mapping weighting)" << endl;
return 1;
}

if ( ap.given( "version" ) ) {
cout << "Version number: " << XHEINZ_VERSION << endl;
return 0;
Expand Down

0 comments on commit d0ff8af

Please sign in to comment.