Skip to content

Commit

Permalink
Fix hashrate sum (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
endorxmr committed Oct 13, 2022
1 parent c3aa7fb commit fff8976
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/opti-lib/src/OptiEnProfitSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Solution OptiSubjectEnProfit::GetVerbose(const EnjoLib::Matrix & dataMat, bool v
//LOG << "i = " << i << ", val = " << inp[i] << Nl;
//if (not battery.initial_load)
//if (false)
const PowerUsageSimulation::SimResult & resLocal = powSim.Simulate(i, m_currHour, dataMat, bonusMul, battery.initial_load);
const PowerUsageSimulation::SimResult & resLocal = powSim.Simulate(i, m_currHour, dataMat, bonusMul, battery.initial_load); // TODO: currently the function assumes a hardcoded 1h time window, needs to be configurable
simResult.Add(resLocal);
battery.iter_get_load(powerProd, resLocal.sumPowerUsage);
//const double pentalityUndervolted = load < 0 ? GMat().Fabs(load * load * load) : 0;
Expand Down Expand Up @@ -171,7 +171,7 @@ Solution OptiSubjectEnProfit::GetVerbose(const EnjoLib::Matrix & dataMat, bool v
const SolUtil sut;
ELO
const double maxHashes2display = maxHashes > 0 ? maxHashes : m_hashes.Max();
LOG << "Hashes cumul. [Hh]: (max = " << sut.round(m_hashes.Max(), 1) << ")\n";
LOG << "Hashes cumul. [H]: (max = " << sut.round(m_hashes.Max(), 1) << ")\n";
LOG << AsciiMisc().GenChars("", m_hashes.size()) << Nl;
LOG << StrColour::GenNorm(StrColour::Col::Magenta, AsciiPlot::Build()(Par::MAXIMUM, maxHashes2display).Finalize().Plot(m_hashes)) << Nl;
LOG << "Energy input [W] : (max = " << sut.round(m_prod.Max(), 1) << ")\n";
Expand Down
6 changes: 3 additions & 3 deletions src/opti-lib/src/PowerUsageSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PowerUsageSimulation::PowerUsageSimulation(const OptiEnProfitDataModel & dataMod
{}

PowerUsageSimulation::SimResult PowerUsageSimulation::Simulate(int i, int currHour, const EnjoLib::Matrix & dataMat,
double bonusMul, bool isInitialLoad) const
double bonusMul, bool isInitialLoad, double hours) const
{
SimResult res{};
//const EnjoLib::Array<Computer> & comps = m_dataModel.GetComputers();
Expand All @@ -29,11 +29,11 @@ PowerUsageSimulation::SimResult PowerUsageSimulation::Simulate(int i, int currHo
const double hashe = comp.GetHashRate(val) * bonusMul;
if (ic < comp.minRunHours + 1) // Assuming, that the bonus will last at least for the number of computer's running hours
{
res.sumHashes += hashe * (1 + bonusMulMA);
res.sumHashes += hashe * (1 + bonusMulMA) * hours * 3600; // [H] = [H/s] * [adim] * [h] * 3600 [s/h]
}
else
{
res.sumHashes += hashe;
res.sumHashes += hashe * hours * 3600; // [H] = [H/s] * 3600 [s/h]
}
res.sumPowerUsage += comp.GetUsage(val);
}
Expand Down
2 changes: 1 addition & 1 deletion src/opti-lib/src/PowerUsageSimulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PowerUsageSimulation
};

SimResult Simulate(int i, int currHour, const EnjoLib::Matrix & dataMat,
double bonusMul, bool isInitialLoad) const;
double bonusMul, bool isInitialLoad, double hours=1) const;

protected:

Expand Down
2 changes: 2 additions & 0 deletions src/profitability.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def historical_diff(self, height:int=None, timestamp:int=None, batch_size:int=10
print(f"Creating {path}")
diff, blocked = self._request_headers_batcher(0, height, batch_size=batch_size)
if blocked:
diff.to_pickle(path)
print(diff)
raise KeyboardInterrupt
else:
diff.to_pickle(path)
Expand Down

0 comments on commit fff8976

Please sign in to comment.