Last active
September 27, 2017 14:27
-
-
Save Sumith1896/ee699d2541d5c0f8ca64b945aa293863 to your computer and use it in GitHub Desktop.
weightgen calculate weight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float Main::CalculateSolutionWeightNonFactored(Solver &solver){ | |
double weightTotal = 0; | |
for (int i = 0;i<conf.weightVariables;i++){ | |
Var var = weightVariables.at(i); | |
//printf("%d %d\n",var, solver.model[var]); | |
if (solver.model[var] == l_True){ | |
weightTotal = weightTotal*2+1; | |
} | |
else{ | |
weightTotal *= 2; | |
} | |
} | |
weightTotal = conf.minAssignWeight*(1 + (conf.ratio-1)*weightTotal*1.0/ | |
(pow(2,conf.weightVariables)-1)); | |
return weightTotal/maxProb; | |
} | |
float Main::CalculateSolutionWeight(Solver &solver, vec<lbool> model){ | |
if (conf.non_factored){ | |
return CalculateSolutionWeightNonFactored(solver); | |
} | |
float weightTotal = 1; | |
for (Var var = 0; var != solver.nOrigVars();var++){ | |
weightTotal *= solver.getWeight(var+1,model[var]); | |
} | |
weightTotal = weightTotal/maxProb; | |
return weightTotal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment