Skip to content

Commit

Permalink
+ adjustable time horizon for long-term plots
Browse files Browse the repository at this point in the history
+ detaching -> ready transition for no cell death consequences
  • Loading branch information
chrxh committed Sep 17, 2024
1 parent 60461aa commit 3f877f6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
2 changes: 2 additions & 0 deletions source/EngineGpuKernels/CellProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ __inline__ __device__ void CellProcessor::livingStateTransition(SimulationData&
atomicCAS(&connectedCell->livingState, LivingState_UnderConstruction, LivingState_Detaching);
}
}
} else {
atomicExch(&cell->livingState, LivingState_Ready);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ void _SimulationParametersWindow::processBase()
.textWidth(RightColumnWidth)
.colorDependence(true)
.min(0.0f)
.max(20.0f)
.max(4.0f)
.format("%.1f")
.defaultValue(origParameters.genomeComplexityNeuronFactor)
.tooltip("This parameter takes into account the number of encoded neurons in the genome for the complexity value."),
Expand Down
45 changes: 32 additions & 13 deletions source/Gui/StatisticsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ _StatisticsWindow::_StatisticsWindow(SimulationController const& simController)
_startingPath = GlobalSettings::getInstance().getString("windows.statistics.starting path", path.string());
_plotHeight = GlobalSettings::getInstance().getFloat("windows.statistics.plot height", _plotHeight);
_mode = GlobalSettings::getInstance().getInt("windows.statistics.mode", _mode);
_timeHorizonForLiveStatistics = GlobalSettings::getInstance().getFloat("windows.statistics.live statistics horizon", _timeHorizonForLiveStatistics);
_timeHorizonForLiveStatistics = GlobalSettings::getInstance().getFloat("windows.statistics.live horizon", _timeHorizonForLiveStatistics);
_timeHorizonForLongtermStatistics = GlobalSettings::getInstance().getFloat("windows.statistics.long term horizon", _timeHorizonForLongtermStatistics);
_plotType = GlobalSettings::getInstance().getInt("windows.statistics.plot type", _plotType);
auto collapsedPlotIndexJoinedString = GlobalSettings::getInstance().getString("windows.statistics.collapsed plot indices", "");

Expand All @@ -59,7 +60,8 @@ _StatisticsWindow::~_StatisticsWindow()
GlobalSettings::getInstance().setString("windows.statistics.starting path", _startingPath);
GlobalSettings::getInstance().setFloat("windows.statistics.plot height", _plotHeight);
GlobalSettings::getInstance().setInt("windows.statistics.mode", _mode);
GlobalSettings::getInstance().setFloat("windows.statistics.live statistics horizon", _timeHorizonForLiveStatistics);
GlobalSettings::getInstance().setFloat("windows.statistics.live horizon", _timeHorizonForLiveStatistics);
GlobalSettings::getInstance().setFloat("windows.statistics.long term horizon", _timeHorizonForLongtermStatistics);
GlobalSettings::getInstance().setInt("windows.statistics.plot type", _plotType);

std::vector<std::string> collapsedPlotIndexStrings;
Expand Down Expand Up @@ -113,17 +115,27 @@ void _StatisticsWindow::processTimelinesTab()
{"Real-time plots", "Entire history plots"}),
_mode);

ImGui::BeginDisabled(_mode == 1);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - scale(RightColumnWidth));
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Time horizon")
.min(1.0f)
.max(TimelineLiveStatistics::MaxLiveHistory)
.format("%.1f s")
.textWidth(RightColumnWidth),
&_timeHorizonForLiveStatistics);
ImGui::EndDisabled();
if (_mode == 0) {
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Time horizon")
.min(1.0f)
.max(TimelineLiveStatistics::MaxLiveHistory)
.format("%.1f s")
.textWidth(RightColumnWidth),
&_timeHorizonForLiveStatistics);
}
if (_mode == 1) {
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Time horizon")
.min(1.0f)
.max(100.0f)
.format("%.0f percent")
.textWidth(RightColumnWidth),
&_timeHorizonForLongtermStatistics);
}

AlienImGui::Switcher(
AlienImGui::SwitcherParameters()
Expand Down Expand Up @@ -467,7 +479,8 @@ void _StatisticsWindow::processPlot(int row, DataPoint DataPointCollection::*val

auto const& dataPointCollectionHistory = _timelineLiveStatistics.getDataPointCollectionHistory();
auto count = _mode == 0 ? toInt(dataPointCollectionHistory.size()) : toInt(longtermStatistics->size());
auto startTime = _mode == 0 ? dataPointCollectionHistory.back().time - toDouble(_timeHorizonForLiveStatistics) : longtermStatistics->front().time;
auto startTime = _mode == 0 ? dataPointCollectionHistory.back().time - toDouble(_timeHorizonForLiveStatistics)
: longtermStatistics->back().time - (longtermStatistics->back().time - longtermStatistics->front().time) * toDouble(_timeHorizonForLongtermStatistics) / 100;
auto endTime = _mode == 0 ? dataPointCollectionHistory.back().time : longtermStatistics->back().time;
auto values = _mode == 0 ? &(dataPointCollectionHistory[0].*valuesPtr) : &((*longtermStatistics)[0].*valuesPtr);
auto timePoints = _mode == 0 ? &dataPointCollectionHistory[0].time : &(*longtermStatistics)[0].time;
Expand Down Expand Up @@ -646,6 +659,12 @@ void _StatisticsWindow::plotForColorIntern(
ImGui::PopID();
}

void _StatisticsWindow::validationAndCorrection()
{
_timeHorizonForLiveStatistics = std::max(1.0f, std::min(TimelineLiveStatistics::MaxLiveHistory, _timeHorizonForLiveStatistics));
_timeHorizonForLongtermStatistics = std::max(1.0f, std::min(100.0f, _timeHorizonForLongtermStatistics));
}

float _StatisticsWindow::calcPlotHeight(int row) const
{
auto isCollapsed = _collapsedPlotIndices.contains(row);
Expand Down
3 changes: 3 additions & 0 deletions source/Gui/StatisticsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class _StatisticsWindow : public _AlienWindow
double endTime,
int fracPartDecimals);

void validationAndCorrection();

float calcPlotHeight(int row) const;

SimulationController _simController;
Expand All @@ -60,6 +62,7 @@ class _StatisticsWindow : public _AlienWindow
std::unordered_set<int> _collapsedPlotIndices;

float _timeHorizonForLiveStatistics = 10.0f; //in seconds
float _timeHorizonForLongtermStatistics = 100.0f; //in percent
std::optional<std::chrono::steady_clock::time_point> _lastTimepoint;
TimelineLiveStatistics _timelineLiveStatistics;
HistogramLiveStatistics _histogramLiveStatistics;
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/TimelineLiveStatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TimelineLiveStatistics
{
public:
static auto constexpr MaxLiveHistory = 240.0; //in seconds
static auto constexpr MaxLiveHistory = 240.0f; //in seconds

std::vector<DataPointCollection> const& getDataPointCollectionHistory() const;
void update(TimelineStatistics const& statistics, uint64_t timestep);
Expand Down

0 comments on commit 3f877f6

Please sign in to comment.