Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opti algo solution improvement #83

Merged
merged 3 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/opti-lib/src/OptiEnProfitSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ double OptiSubjectEnProfit::GetVerbose(const EnjoLib::Matrix & dataMat, bool ver
{
if (LOG_UNACCEPTABLE_SOLUTIONS)
{
LOGL << "Unacceptable solution. Penality undervolt = " << pentalityUndervolted << " Overvolt: " << pentalityOvervolted << "\n";
LOGL << "Unacceptable solution. Penality undervolt = " << pentalityUndervolted << " Overvolt: " << pentalityOvervolted
<< ", hashes = " << resLocal.sumHashes << "\n";
}
const double penality = penalitySum * PENALITY_SUM_MUL;
const double penalityExtrapolated = penality * (n - i) * 3; // Extrapolate across the remaining simulation steps
if (not verbose)
{
return -penalityExtrapolated;
return resLocal.sumHashes -penalityExtrapolated;
}
}
//LOGL << "acceptable solution. Penality undervolt = " << pentalityUndervolted << " Overvolt: " << pentalityOvervolted << "\n";
Expand Down
16 changes: 8 additions & 8 deletions src/opti-lib/src/OptimizerEnProfit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ using namespace std;
using namespace EnjoLib;

const int OptimizerEnProfit::HOURS_IN_DAY = 24;
const int OptimizerEnProfit::MAX_FAILED_COMBINATIONS = 600000;
const int OptimizerEnProfit::MAX_NUM_COMBINATIONS = 1e7;
const double OptimizerEnProfit::MAX_FAILED_COMBINATIONS = 0.6;
const double OptimizerEnProfit::MIN_POS_2_NEG_CHANGE_RATIO = 0.01;

OptimizerEnProfit::OptimizerEnProfit(const OptiEnProfitDataModel & dataModel)
Expand Down Expand Up @@ -96,18 +97,18 @@ void OptimizerEnProfit::RandomSearch()
Matrix binarBest = binaryMat;

const bool useHash = IsUseHash();
const int maxEl = 1e7;
const int maxCombisFailed = MAX_NUM_COMBINATIONS * MAX_FAILED_COMBINATIONS;
short bit = 1;
char bitC = '1';
std::set<std::string> usedCombinations;
int alreadyCombined = 0;
const GMat gmat;
ProgressMonitHigh progressMonitor;
for (int i = 0; i < maxEl; ++i)
for (int i = 0; i < MAX_NUM_COMBINATIONS; ++i)
{
if (i % 100000 == 0)
{
progressMonitor.PrintProgressBarTime(i, maxEl);
progressMonitor.PrintProgressBarTime(i, MAX_NUM_COMBINATIONS);
}
const int icomp = gmat.round(rmath.Rand(0, numComputers-1));
//for (int icomp = 0; icomp < numComputers; ++icomp)
Expand Down Expand Up @@ -177,17 +178,16 @@ void OptimizerEnProfit::RandomSearch()
}
RecalcComputationCosts();
}
const int maxFail = MAX_FAILED_COMBINATIONS;
const bool changeLargeEnough = m_relPos2Neg == 0 || m_relPos2Neg > MIN_POS_2_NEG_CHANGE_RATIO;
const bool exceededNumFailed = m_numFailed >= maxFail;
const bool exceededNumFailed = m_numFailed >= maxCombisFailed;
//if (exceededNumFailed && not changeLargeEnough)
if (exceededNumFailed)
{
LOGL << "Early stop after " << m_numFailed << " last failed attempts "
// << and last change of " << m_relPos2Neg << " < " << MIN_POS_2_NEG_CHANGE_RATIO << Nl
<< Nl
<< "Repeated combinations = " << alreadyCombined << " of " << maxFail << ": " << GMat().round(alreadyCombined/double(maxFail) * 100) << "%" << Nl
<< "Unique combinations = " << usedCombinations.size() << " of " << maxFail << ": " << GMat().round(usedCombinations.size()/double(maxFail) * 100) << "%" << Nl;
<< "Repeated combinations = " << alreadyCombined << " of " << maxCombisFailed << ": " << GMat().round(alreadyCombined/double(maxCombisFailed) * 100) << "%" << Nl
<< "Unique combinations = " << usedCombinations.size() << " of " << maxCombisFailed << ": " << GMat().round(usedCombinations.size()/double(maxCombisFailed) * 100) << "%" << Nl;
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/opti-lib/src/OptimizerEnProfit.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class OptimizerEnProfit : public EnjoLib::IMultiDimIterConsumerTpl //OptimizerBa
bool IsUseHash() const;

const int static HOURS_IN_DAY;
const int static MAX_FAILED_COMBINATIONS;
const int static MAX_NUM_COMBINATIONS;
const double static MAX_FAILED_COMBINATIONS;
const double static MIN_POS_2_NEG_CHANGE_RATIO;

protected:
Expand Down
6 changes: 4 additions & 2 deletions src/system-cfg/computers-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"computers": [
{
"name" : "Fanless Intel, 4 core",
"count" : 0,
"count" : 1,
"cores" : 4,
"hash_per_core" : 250,
"watt_per_core" : 11.5,
Expand All @@ -13,7 +13,8 @@
},
{
"name" : "Fanless Ryzen, 2 core",
"cores" : 1,
"count" : 0,
"cores" : 2,
"hash_per_core" : 100,
"watt_per_core" : 20,
"watt_idle" : 8,
Expand All @@ -23,6 +24,7 @@
},
{
"name" : "Ryzen 7, 8 cores",
"count" : 1,
"cores" : 8,
"hash_per_core" : 400,
"watt_per_core" : 8,
Expand Down