Skip to content

Commit

Permalink
OperationalDecisionSystem Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
schroedtert committed Nov 22, 2023
1 parent c0cd764 commit a5f1e14
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions libsimulator/src/OperationalDecisionSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "NeighborhoodSearch.hpp"
#include "OperationalModel.hpp"
#include "OperationalModelType.hpp"
#include "OptimalStepsModel.hpp"
#include "SimulationError.hpp"

#include <boost/iterator/zip_iterator.hpp>
Expand All @@ -16,7 +17,24 @@
#include <memory>
#include <vector>

class OperationalDecisionSystem
class OperationalDecisionSystemInterface
{
public:
virtual ~OperationalDecisionSystemInterface() = default;
virtual void
Run(double dT,
double /*t_in_sec*/,
const NeighborhoodSearch<GenericAgent>& neighborhoodSearch,
const CollisionGeometry& geometry,
std::vector<GenericAgent>& agents) const = 0;

virtual void ValidateAgent(
const GenericAgent& agent,
const NeighborhoodSearch<GenericAgent>& neighborhoodSearch,
const CollisionGeometry& geometry) const = 0;
};

class OperationalDecisionSystem : public OperationalDecisionSystemInterface
{
std::unique_ptr<OperationalModel> _model{};

Expand All @@ -37,7 +55,7 @@ class OperationalDecisionSystem
double /*t_in_sec*/,
const NeighborhoodSearch<GenericAgent>& neighborhoodSearch,
const CollisionGeometry& geometry,
std::vector<GenericAgent>& agents) const
std::vector<GenericAgent>& agents) const override
{
std::vector<std::optional<OperationalModelUpdate>> updates{};
updates.reserve(agents.size());
Expand All @@ -64,8 +82,11 @@ class OperationalDecisionSystem
void ValidateAgent(
const GenericAgent& agent,
const NeighborhoodSearch<GenericAgent>& neighborhoodSearch,
const CollisionGeometry& geometry) const
const CollisionGeometry& geometry) const override
{
_model->CheckModelConstraint(agent, neighborhoodSearch, geometry);
}
};

std::unique_ptr<OperationalDecisionSystemInterface>
MakeOperationalDecisionSystem(std::unique_ptr<OperationalModel>&& model);

0 comments on commit a5f1e14

Please sign in to comment.