feat(policy network stack): Policies can now return the network stack
Policies can now return the network stack which allows the caller more control over settings and running a solver against various levels of the stack. Further, policies can return the partition function used as well as a vector of enums which describe the structure of the network stack.
This commit is contained in:
@@ -2,3 +2,32 @@
|
||||
|
||||
#include "gridfire/engine/types/building.h"
|
||||
#include "gridfire/engine/types/reporting.h"
|
||||
|
||||
namespace gridfire {
|
||||
enum class EngineTypes {
|
||||
GRAPH_ENGINE,
|
||||
ADAPTIVE_ENGINE_VIEW,
|
||||
MULTISCALE_PARTITIONING_ENGINE_VIEW,
|
||||
PRIMING_ENGINE_VIEW,
|
||||
DEFINED_ENGINE_VIEW,
|
||||
FILE_DEFINED_ENGINE_VIEW
|
||||
};
|
||||
|
||||
inline std::string engine_type_to_string(const EngineTypes type) {
|
||||
switch (type) {
|
||||
case EngineTypes::GRAPH_ENGINE:
|
||||
return "GraphEngine";
|
||||
case EngineTypes::ADAPTIVE_ENGINE_VIEW:
|
||||
return "AdaptiveEngineView";
|
||||
case EngineTypes::MULTISCALE_PARTITIONING_ENGINE_VIEW:
|
||||
return "MultiscalePartitioningEngineView";
|
||||
case EngineTypes::PRIMING_ENGINE_VIEW:
|
||||
return "PrimingEngineView";
|
||||
case EngineTypes::DEFINED_ENGINE_VIEW:
|
||||
return "DefinedEngineView";
|
||||
case EngineTypes::FILE_DEFINED_ENGINE_VIEW:
|
||||
return "FileDefinedEngineView";
|
||||
}
|
||||
return "UnknownEngineType";
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,13 @@
|
||||
#include "fourdst/atomic/atomicSpecies.h"
|
||||
#include "gridfire/reaction/reaction.h"
|
||||
#include "gridfire/engine/engine_abstract.h"
|
||||
#include "gridfire/partition/partition.h"
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include "gridfire/engine/types/engine_types.h"
|
||||
|
||||
|
||||
namespace gridfire::policy {
|
||||
/**
|
||||
@@ -157,6 +160,12 @@ namespace gridfire::policy {
|
||||
* @endcode
|
||||
*/
|
||||
[[nodiscard]] virtual NetworkPolicyStatus getStatus() const = 0;
|
||||
|
||||
[[nodiscard]] virtual const std::vector<std::unique_ptr<DynamicEngine>> &get_engine_stack() const = 0;
|
||||
|
||||
[[nodiscard]] virtual std::vector<EngineTypes> get_engine_types_stack() const = 0;
|
||||
|
||||
[[nodiscard]] virtual const std::unique_ptr<partition::PartitionFunction>& get_partition_function() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -142,6 +142,12 @@ namespace gridfire::policy {
|
||||
* @return NetworkPolicyStatus The construction and verification status.
|
||||
*/
|
||||
[[nodiscard]] NetworkPolicyStatus getStatus() const override;
|
||||
|
||||
[[nodiscard]] const std::vector<std::unique_ptr<DynamicEngine>> &get_engine_stack() const override;
|
||||
|
||||
[[nodiscard]] std::vector<EngineTypes> get_engine_types_stack() const override;
|
||||
[[nodiscard]] const std::unique_ptr<partition::PartitionFunction>& get_partition_function() const override;
|
||||
|
||||
private:
|
||||
std::set<fourdst::atomic::Species> m_seed_species;
|
||||
|
||||
@@ -155,6 +161,8 @@ namespace gridfire::policy {
|
||||
static std::unique_ptr<partition::PartitionFunction> build_partition_function();
|
||||
[[nodiscard]] NetworkPolicyStatus check_status() const;
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ namespace gridfire::policy {
|
||||
);
|
||||
|
||||
auto& graphRepr = dynamic_cast<GraphEngine&>(*m_network_stack.back().get());
|
||||
// graphRepr.setPrecomputation(false);
|
||||
graphRepr.setUseReverseReactions(false);
|
||||
|
||||
|
||||
@@ -97,6 +96,25 @@ namespace gridfire::policy {
|
||||
return m_status;
|
||||
}
|
||||
|
||||
const std::vector<std::unique_ptr<DynamicEngine>> &MainSequencePolicy::get_engine_stack() const {
|
||||
if (m_status != NetworkPolicyStatus::INITIALIZED_VERIFIED) {
|
||||
throw exceptions::PolicyError("Cannot get engine stack from MainSequencePolicy: Policy is not initialized and verified. Call construct() first.");
|
||||
}
|
||||
return m_network_stack;
|
||||
}
|
||||
|
||||
std::vector<EngineTypes> MainSequencePolicy::get_engine_types_stack() const {
|
||||
return {
|
||||
EngineTypes::GRAPH_ENGINE,
|
||||
EngineTypes::MULTISCALE_PARTITIONING_ENGINE_VIEW,
|
||||
EngineTypes::ADAPTIVE_ENGINE_VIEW
|
||||
};
|
||||
}
|
||||
|
||||
const std::unique_ptr<partition::PartitionFunction>& MainSequencePolicy::get_partition_function() const {
|
||||
return m_partition_function;
|
||||
}
|
||||
|
||||
inline NetworkPolicyStatus MainSequencePolicy::check_status() const {
|
||||
for (const auto& species : m_seed_species) {
|
||||
if (!m_initializing_composition.contains(species)) {
|
||||
|
||||
@@ -9,6 +9,7 @@ gridfire_sources = files(
|
||||
'lib/engine/procedures/priming.cpp',
|
||||
'lib/engine/procedures/construction.cpp',
|
||||
'lib/engine/diagnostics/dynamic_engine_diagnostics.cpp',
|
||||
'lib/engine/types/jacobian.cpp',
|
||||
'lib/reaction/reaction.cpp',
|
||||
'lib/reaction/reaclib.cpp',
|
||||
'lib/reaction/weak/weak.cpp',
|
||||
|
||||
Reference in New Issue
Block a user