Program Listing for File temporalconstraints.h
↰ Return to documentation for file (src/popf/temporalconstraints.h)
/************************************************************************
* Copyright 2010, Strathclyde Planning Group,
* Department of Computer and Information Sciences,
* University of Strathclyde, Glasgow, UK
* http://planning.cis.strath.ac.uk/
*
* Andrew Coles, Amanda Coles - Code for POPF
* Maria Fox, Richard Howey and Derek Long - Code from VAL
* Stephen Cresswell - PDDL Parser
*
* This file is part of the planner POPF.
*
* POPF is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* POPF is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with POPF. If not, see <http://www.gnu.org/licenses/>.
*
************************************************************************/
#ifndef TEMPORALCONSTRAINTS_H
#define TEMPORALCONSTRAINTS_H
#include <vector>
#include <set>
#include <map>
#include <cassert>
using std::vector;
using std::set;
using std::map;
using std::pair;
namespace Planner
{
#ifndef NDEBUG
extern pair<map<int, int>::iterator, bool> INVARIANTINSERT(map<int, int> & dest, const pair<int, int> & toInsert, const int & bound);
extern void INVARIANTERASE(map<int, int> & dest, const int & toErase, const int & bound);
#else
#define INVARIANTINSERT(x,y,z) x.insert(y)
#define INVARIANTERASE(x,y,z) x.erase(y)
#endif
struct FluentInteraction {
int lastInstantaneousEffect;
set<int> activeCTSEffects;
map<int, int> activeInvariants; // end step maps to start step
FluentInteraction() : lastInstantaneousEffect(-1) {
}
};
class TemporalConstraints
{
protected:
vector<map<int, bool> * > stepsComeBeforeThisOne;
int mostRecentStep;
public:
vector<FluentInteraction> lastStepToTouchPNE;
TemporalConstraints();
TemporalConstraints(const TemporalConstraints &, const int extendBy = 0);
virtual ~TemporalConstraints();
virtual void addOrdering(const unsigned int & comesFirst, const unsigned int & comesSecond, const bool & epsilon);
virtual void extend(const int & extendBy);
const map<int, bool> * stepsBefore(const int & i) const {
return stepsComeBeforeThisOne[i];
}
const unsigned int size() const {
return stepsComeBeforeThisOne.size();
}
const int & getMostRecentStep() const {
return mostRecentStep;
}
void setMostRecentStep(const int & last) {
mostRecentStep = last;
}
};
};
#endif // TEMPORALCONSTRAINTS_H