Initial commit.

This commit is contained in:
2016-05-20 15:29:24 +02:00
commit 3ddf942a12
18 changed files with 969 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#ifndef __SAS__AXIOM_RULE_H
#define __SAS__AXIOM_RULE_H
#include <vector>
#include <plasp/sas/Variable.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// AxiomRule
//
////////////////////////////////////////////////////////////////////////////////////////////////////
struct AxiomRule
{
using Condition = AssignedVariable;
using Conditions = std::vector<Condition>;
Conditions conditions;
Condition postcondition;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,66 @@
#ifndef __SAS__DESCRIPTION_H
#define __SAS__DESCRIPTION_H
#include <vector>
#include <boost/filesystem/path.hpp>
#include <plasp/sas/MutexGroup.h>
#include <plasp/sas/Operator.h>
#include <plasp/sas/Variable.h>
#include <plasp/sas/AxiomRule.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Description
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class Description
{
public:
static Description fromFile(const boost::filesystem::path &path);
public:
Description();
void print(std::ostream &ostream) const;
private:
void parseSectionIdentifier(std::istream &istream, const std::string &expectedSectionIdentifier) const;
size_t parseNumber(std::istream &istream) const;
const Variable &parseVariable(std::istream &istream) const;
const Value &parseVariableValue(std::istream &istream, const Variable &variable) const;
AssignedVariable parseAssignedVariable(std::istream &istream) const;
VariableTransition parseVariableTransition(std::istream &istream) const;
void parseVersionSection(std::istream &istream) const;
void parseMetricSection(std::istream &istream);
void parseVariablesSection(std::istream &istream);
void parseMutexSection(std::istream &istream);
void parseInitialStateSection(std::istream &istream);
void parseGoalSection(std::istream &istream);
void parseOperatorSection(std::istream &istream);
void parseAxiomSection(std::istream &istream);
bool m_usesActionCosts;
std::vector<Variable> m_variables;
std::vector<MutexGroup> m_mutexGroups;
std::vector<AssignedVariable> m_initialStateFacts;
std::vector<AssignedVariable> m_goalFacts;
std::vector<Operator> m_operators;
std::vector<AxiomRule> m_axiomRules;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,33 @@
#ifndef __SAS__EFFECT_H
#define __SAS__EFFECT_H
#include <vector>
#include <plasp/sas/Variable.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Effect
//
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Effect
{
using Condition = AssignedVariable;
using Conditions = std::vector<Condition>;
Conditions conditions;
Condition postcondition;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,30 @@
#ifndef __SAS__MUTEX_GROUP_H
#define __SAS__MUTEX_GROUP_H
#include <plasp/sas/Variable.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// MutexGroup
//
////////////////////////////////////////////////////////////////////////////////////////////////////
struct MutexGroup
{
using Fact = AssignedVariable;
using Facts = std::vector<Fact>;
Facts facts;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,38 @@
#ifndef __SAS__OPERATOR_H
#define __SAS__OPERATOR_H
#include <string>
#include <vector>
#include <plasp/sas/Effect.h>
#include <plasp/sas/Variable.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Operator
//
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Operator
{
using Condition = AssignedVariable;
using Conditions = std::vector<Condition>;
using Effects = std::vector<Effect>;
std::string name;
Conditions preconditions;
Effects effects;
size_t costs;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,56 @@
#ifndef __SAS__PARSER_EXCEPTION_H
#define __SAS__PARSER_EXCEPTION_H
#include <exception>
#include <string>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// ParserException
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class ParserException: public std::exception
{
public:
explicit ParserException()
{
}
explicit ParserException(const char *message)
: m_message(message)
{
}
explicit ParserException(const std::string &message)
: m_message(message)
{
}
~ParserException() throw()
{
}
const char *what() const throw()
{
if (m_message.empty())
return "Unspecified error while parsing SAS description file";
return m_message.c_str();
}
private:
std::string m_message;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

29
include/plasp/sas/Value.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef __SAS__VALUE_H
#define __SAS__VALUE_H
#include <string>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Value
//
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Value
{
static const Value Any;
std::string name;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,51 @@
#ifndef __SAS__VARIABLE_H
#define __SAS__VARIABLE_H
#include <string>
#include <vector>
#include <plasp/sas/Value.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Variable
//
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Variable
{
using Values = std::vector<Value>;
std::string name;
int axiomLayer;
Values values;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
struct AssignedVariable
{
const Variable &variable;
const Value &value;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
struct VariableTransition
{
const Variable &variable;
const Value &valueBefore;
const Value &valueAfter;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif