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

Stability: replace Array with Vector for now #140

Merged
merged 1 commit into from
Nov 9, 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
8 changes: 4 additions & 4 deletions src/opti-lib/src/JsonReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const rapidjson::Value & JsonValueWrapper::GetValueJson(const EnjoLib::Str & nam
return m_obj[name.c_str()];
}

EnjoLib::Array<BatteryParams> JsonReader::ReadBatteries(bool verbose) const
std::vector<BatteryParams> JsonReader::ReadBatteries(bool verbose) const
{
const CharManipulations cman;
std::vector<BatteryParams> ret;
Expand Down Expand Up @@ -116,7 +116,7 @@ EnjoLib::Array<BatteryParams> JsonReader::ReadBatteries(bool verbose) const
return ret;
}

EnjoLib::Array<Computer> JsonReader::ReadComputers(bool verbose) const
std::vector<Computer> JsonReader::ReadComputers(bool verbose) const
{
const CharManipulations cman;
std::vector<Computer> ret;
Expand Down Expand Up @@ -183,7 +183,7 @@ EnjoLib::Array<Computer> JsonReader::ReadComputers(bool verbose) const
return ret;
}

EnjoLib::Array<Habit> JsonReader::ReadHabits(bool verbose) const
std::vector<Habit> JsonReader::ReadHabits(bool verbose) const
{
const CharManipulations cman;
std::vector<Habit> ret;
Expand Down Expand Up @@ -271,7 +271,7 @@ ConfigSol JsonReader::ReadConfigSol(bool verbose) const
rapidjson::Document d;
parseJsonOrThrow(jsonFile, m_verbose, d);
JsonValueWrapper jwrap(d, idd);

/// TODO: This should be secured better, like the rest, but it's multilayered.
ret.m_outDir = d["paths"]["DIR_TMP"].GetString();
return ret;
Expand Down
9 changes: 5 additions & 4 deletions src/opti-lib/src/JsonReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <Util/StrFwd.hpp>
#include <Template/Array.hpp>
#include <STD/Vector.hpp>

class ConfigSol;

Expand All @@ -16,14 +17,14 @@ class JsonReader
public:
JsonReader(bool verbose = true);
virtual ~JsonReader();
EnjoLib::Array<Computer> ReadComputers(bool verbose = false) const;
EnjoLib::Array<BatteryParams> ReadBatteries(bool verbose = false) const;
EnjoLib::Array<Habit> ReadHabits (bool verbose = false) const;
std::vector<Computer> ReadComputers(bool verbose = false) const;
std::vector<BatteryParams> ReadBatteries(bool verbose = false) const;
std::vector<Habit> ReadHabits (bool verbose = false) const;
System ReadSystem(bool verbose = false) const;
ConfigSol ReadConfigSol(bool verbose = false) const;

static EnjoLib::Str GetJson(const EnjoLib::Str & fileName, bool verbose);

protected:

private:
Expand Down
4 changes: 2 additions & 2 deletions src/opti-lib/src/OptiEnProfitDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OptiEnProfitDataModel
const ConfigSol & GetConf() const { return m_confSol; }
//const EnjoLib::Array<Computer> & GetComputers() const { return m_comps; }
const std::vector<Computer> & GetComputers() const { return m_comps; }
const EnjoLib::Array<Habit> & GetHabits() const { return m_habits; }
const std::vector<Habit> & GetHabits() const { return m_habits; }
double GetHabitsUsage(int i) const;
const BatteryParams & GetBatPars() const { return m_batPars; }
const System & GetSystem() const { return m_sys; }
Expand All @@ -60,7 +60,7 @@ class OptiEnProfitDataModel
mutable std::vector<double> m_habitsCache;
//EnjoLib::Array<Computer> m_comps;
std::vector<Computer> m_comps; // Choosing std::vector for runtime speed reasons.
EnjoLib::Array<Habit> m_habits;
std::vector<Habit> m_habits;

System m_sys;
BatteryParams m_batPars;
Expand Down
2 changes: 1 addition & 1 deletion src/opti-lib/src/OptimizerEnProfit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void OptimizerEnProfit::RandomSearch()
{
const ConfigSol & conf = m_dataModel.GetConf();
const int horizonHours = m_dataModel.GetHorizonHours();
const EnjoLib::Array<Computer> & comps = m_dataModel.GetComputers();
const std::vector<Computer> & comps = m_dataModel.GetComputers();
const int numComputers = comps.size();

const GMat gmat;
Expand Down