Initial commit.

This commit is contained in:
2018-12-06 16:01:56 +01:00
parent 10867b60c2
commit 18eb3f6047
1011 changed files with 345688 additions and 10 deletions

View File

@@ -0,0 +1,100 @@
/*******************************************************************************
* Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab) et de
* l'IRT AESE (IRT Saint Exupéry).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab) and of
* the IRT AESE (IRT Saint Exupéry).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
* Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
*
*******************************************************************************/
#include "ArrayDomain.hh"
#include "Variable.hh"
namespace epoch {
namespace altarica {
ArrayDomain::ArrayDomain(int asize, Domain*d):asize_(asize), adomain_(d) {
}
unsigned int ArrayDomain::index(std::string arg) const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("index asked on a Structured domain")));
return 0;
}
std::string ArrayDomain::text(unsigned int index) const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("text asked on a Structured domain")));
return 0;
}
Value * ArrayDomain::toValue() const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("toOpenValue asked on a Structured domain")));
return NULL;
}
int ArrayDomain::getMin() const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getMin asked on an ArrayDomain")));
return -1;
}
int ArrayDomain::getMax() const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getMax asked on a ArrayDomain")));
return -1;
}
// Value * ArrayDomain::getFixedValue(int i) {
// BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getFixedValue(i) asked on a ArrayDomain")));
// return NULL;
// }
Value * ArrayDomain::getValue(int i) {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getFixedValue(i) asked on a ArrayDomain")));
return NULL;
}
std::vector<Variable*> * ArrayDomain::flatten(Variable* v) const {
std::vector<Variable*> * nvv = new std::vector<Variable*>();
std::vector<Variable*> * fv = adomain_->flatten(v);
for (std::vector<Variable*>::iterator fvi= fv->begin(); fvi != fv->end(); ++fvi) {
for (int i = 0; i<asize_; ++i) {
Variable * nv = (*fvi)->clone();
nv->addToMASecond(i);
nvv->push_back(nv);
}
}
delete(fv);
return nvv;
}
std::string ArrayDomain::toString() const {
return "ARRAY";
}
ArrayDomain::~ArrayDomain() {
// delete(adomain_);
}
}
}

View File

@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_ARRAY_DOMAIN_H_
#define ALTA_ARRAY_DOMAIN_H_
#include "DiscreteDomain.hh"
#include <map>
#include <vector>
namespace epoch {
namespace altarica {
//! Array Domain
/*!
Stucture pour stocker les types array d'altarica
*/
class ArrayDomain : public DiscreteDomain {
protected:
//! les types sont stockes dans un vecteur
int asize_;
Domain* adomain_;
public:
//! constructeur qui ne fait rien
ArrayDomain(int asize, Domain* d);
//! calcule un index. attention aux debordements
virtual unsigned int index(std::string arg) const;
virtual std::string text(unsigned int index) const;
virtual std::vector<Variable*> * flatten(Variable* v) const;
virtual Value * toValue() const;
virtual int getMin() const;
virtual int getMax() const;
virtual Value * getValue(int i);
virtual std::string toString() const;
virtual ~ArrayDomain();
};
}
}
#endif

View File

@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_CONTINUOUS_DOMAIN_H_
#define ALTA_CONTINUOUS_DOMAIN_H_
#include "Domain.hh"
namespace epoch {
namespace altarica {
class ContinuousDomain : public Domain {
protected :
public:
virtual ~ContinuousDomain() {};
virtual std::vector<Variable*> * flatten(Variable* v) const = 0;
virtual Value * toValue() const = 0;
virtual std::string toString() const = 0;
};
}
#endif

View File

@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_DISCRETE_DOMAIN_H_
#define ALTA_DISCRETE_DOMAIN_H_
#include "Domain.hh"
namespace epoch {
namespace altarica {
class Value;
class DiscreteDomain : public Domain {
protected :
unsigned int arity_;
public:
virtual unsigned int getArity() const {return arity_;}
virtual int getMin() const = 0;
virtual int getMax() const = 0;
virtual unsigned int index(std::string arg) const =0;
virtual std::string text(unsigned int index) const = 0;
// virtual std::vector<Variable*> * flatten(Variable* v) const = 0;
virtual Value * toValue() const = 0;
virtual Value * getValue(int i) = 0;
virtual std::string toString() const = 0;
virtual ~DiscreteDomain() {};
};
}
}
#endif

View File

@@ -0,0 +1,73 @@
/*******************************************************************************
* Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab) et de
* l'IRT AESE (IRT Saint Exupéry).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab) and of
* the IRT AESE (IRT Saint Exupéry).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
* Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
*
*******************************************************************************/
#include "Domain.hh"
namespace epoch {
namespace altarica {
std::string Domain::get_name() {
if (name_.size() > 0)
return name_[0];
else return std::string("");
}
bool Domain::alias(std::string name) {
for (std::vector<std::string>::iterator nit = name_.begin();
nit != name_.end(); ++nit) {
if (name.compare(*nit) == 0)
return true;
}
return false;
}
void Domain::set_name(std::string n) {
name_.push_back(n);
}
// Domain* Domain::findDomainInVector(std::vector<Domain*> vd, std::string *name) {
// for (std::vector<Domain*>::iterator vdit = vd.begin();
// vdit != vd.end(); ++vdit)
// if ((*vdit)->alias(name))
// return *vdit;
// return NULL;
// }
std::vector<Variable*> * Domain::flatten(Variable* v) const {
std::vector<Variable*> * nv = new std::vector<Variable*>();
nv->push_back(v);
return nv;
}
}
}

View File

@@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_DOMAIN_H_
#define ALTA_DOMAIN_H_
#include <string>
#include <exception>
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <vector>
#include <string>
namespace epoch {
namespace altarica {
class Variable;
class Value;
class Domain {
protected :
std::vector<std::string> name_;
public :
virtual ~Domain() {};
Domain () {}
virtual unsigned int getArity() const = 0;
virtual std::string get_name();
bool alias(std::string name);
void set_name(std::string n);
static Domain* findDomainInVector(std::vector<Domain*>, std::string name);
virtual std::vector<Variable*> * flatten(Variable* v) const;
virtual Value * toValue() const = 0;
virtual std::string toString() const = 0;
};
}
}
#endif

View File

@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_DOMAINS_HH
#define ALTA_DOMAINS_HH
#include "EnumDomain.hh"
#include "RangeDomain.hh"
#include "RealDomain.hh"
#include "ArrayDomain.hh"
#include "StructuredDomain.hh"
#include "DiscreteDomain.hh"
#include "PredefinedDomain.hh"
#endif

View File

@@ -0,0 +1,153 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#include "EnumDomain.hh"
#include "Values.hh"
#include <stdlib.h>
namespace epoch {
namespace altarica {
EnumDomain::EnumDomain() {
indexes = NULL;
}
EnumDomain::EnumDomain(int nSymbols) {
symbols.reserve(nSymbols);
arity_ = nSymbols;
}
void EnumDomain::addSymbol(std::string s) {
// symbols.push_back(s);
std::vector<std::string>::iterator i = symbols.begin();
for (; i!= symbols.end() && s.compare(*i) > 0 ; ++i);
symbols.insert(i, s);
arity_ = symbols.size();
}
void EnumDomain::addSymbols(std::vector<std::string> *sv) {
for (std::vector<std::string>::iterator svit = sv->begin();
svit != sv->end(); ++svit)
addSymbol(*svit);
}
unsigned int EnumDomain::index(std::string arg) const {
// if (indexes == NULL) {
// indexes = new std::map<std::string, int>();
// int j = 0;
// for (std::vector<std::string>::const_iterator i = symbols.begin();i!=symbols.end(); ++i)
// (*indexes)[*i] = j++;
// }
// return (*indexes)[arg];
unsigned int i=0;
for (std::vector<std::string>::const_iterator sit = symbols.begin(); sit!=symbols.end(); ++sit) {
if (sit->compare(arg) == 0)
return i;
i++;
}
return i;
}
std::string EnumDomain::text(unsigned int index) const {
std::string s;
s+=symbols[index];
return s;
}
Value * EnumDomain::toValue() const {
return new ValueSymbol(this);
}
int EnumDomain::getMin() const {
return 0;
}
int EnumDomain::getMax() const {
return arity_-1;
}
// Value * EnumDomain::getFixedValue(int i) {
// return new FixedInt(i);
// }
Value * EnumDomain::getValue(int i) {
return new ValueInt(i);
}
const std::vector<std::string>* EnumDomain::getSymbols() const {
return &symbols;
}
std::string EnumDomain::toString() const {
std::string s;
s+= "{ ";
for (std::vector<std::string>::const_iterator i = symbols.begin(); i!= symbols.end(); ++i) {
s+=*i;
s+=" ";
}
s+= "}";
return s;
}
bool EnumDomain::equals(const EnumDomain *d) const {
if (d == this)
return true;
const std::vector<std::string> * os = d->getSymbols();
if (os->size() != symbols.size())
return false;
for (std::vector<std::string>::const_iterator i = os->begin();
i!= os->end(); ++i) {
bool isIn = false;
for (std::vector<std::string>::const_iterator j = symbols.begin();
j!= symbols.end() && !isIn; ++j) {
if (j->compare(*i) == 0)
isIn = true;
}
if (!isIn)
return false;
}
return true;
}
EnumDomain::~EnumDomain() {
symbols.clear();
}
bool EnumDomain::contains(const std::string s) const {
for (std::vector<std::string>::const_iterator i = symbols.begin(); i!= symbols.end(); ++i)
if (s.compare(*i)==0)
return true;
return false;
}
}
}

View File

@@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_ENUM_DOMAIN_H_
#define ALTA_ENUM_DOMAIN_H_
#include "DiscreteDomain.hh"
#include <vector>
#include <map>
namespace epoch {
namespace altarica {
class EnumDomain : public DiscreteDomain {
protected:
std::vector<std::string> symbols;
mutable std::map<std::string, int> *indexes;
public:
EnumDomain(int nSymbols);
EnumDomain();
const std::vector<std::string>* getSymbols() const;
virtual unsigned int index(std::string arg) const;
virtual std::string text(unsigned int index) const;
void addSymbol(std::string s);
void addSymbols(std::vector<std::string> * ss);
// virtual std::vector<Variable*> * flatten(Variable* v) const;
virtual Value * toValue() const;
virtual int getMin() const;
virtual int getMax() const;
virtual Value * getValue(int i);
virtual std::string toString() const ;
bool contains(const std::string s) const;
bool equals(const EnumDomain *d) const;
virtual ~EnumDomain();
};
}
}
#endif

View File

@@ -0,0 +1,146 @@
/*******************************************************************************
* Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab) et de
* l'IRT AESE (IRT Saint Exupéry).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab) and of
* the IRT AESE (IRT Saint Exupéry).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
* Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
*
*******************************************************************************/
#include "PredefinedDomain.hh"
#include <stdlib.h>
#include "Variable.hh"
#include "Values.hh"
namespace epoch {
namespace altarica {
PredefinedDomain::PredefinedDomain(bool type) {
if (type) {
bool_ = true;
arity_ = 2;
} else {
bool_ = false;
arity_ = UINT32_MAX;
}
}
unsigned int PredefinedDomain::index(std::string arg) const {
if (bool_) {
if (arg == "TRUE" || arg == "true")
return 1;
else
return 0;
} else {
return (atoi(arg.c_str()));
}
}
std::string PredefinedDomain::text(unsigned int index) const {
std::string s;
if (bool_) {
if (index == 1)
s+="true";
else
s+="false";
} else {
std::string *s = new std::string();
s +=index;
}
return s;
}
Value * PredefinedDomain::toValue() const {
if (bool_)
return new ValueBool();
else
return new ValueInt();
}
int PredefinedDomain::getMin() const {
if (bool_)
return 0;
else
return INT32_MIN;
}
int PredefinedDomain::getMax() const {
if (bool_)
return 1;
else
return INT32_MAX;
}
int PredefinedDomain::min(bool b) {
if (b)
return 0;
else
return INT32_MIN;
}
int PredefinedDomain::max(bool b) {
if (b)
return 1;
else
return INT32_MAX;
}
// Value * PredefinedDomain::getFixedValue(int i) {
// if (bool_) {
// if (i == 0)
// return new FixedBool(true);
// else
// return new FixedBool(false);
// } else {
// return new FixedInt(i);
// }
// }
Value * PredefinedDomain::getValue(int i) {
if (bool_) {
if (i == 1)
return new ValueBool(true,false);
else
return new ValueBool(false,true);
} else {
return new ValueInt(i);
}
}
std::string PredefinedDomain::toString() const {
if (bool_)
return "BOOL";
else
return "INTEGER";
}
PredefinedDomain::~PredefinedDomain() {}
}
}

View File

@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_PREDEFINED_DOMAIN_H_
#define ALTA_PREDEFINED_DOMAIN_H_
#include "DiscreteDomain.hh"
#include <vector>
#include <stdint.h>
namespace epoch {
namespace altarica {
class PredefinedDomain : public DiscreteDomain {
protected:
bool bool_; //or int
public:
PredefinedDomain(bool type);
virtual unsigned int index(std::string arg) const;
virtual std::string text(unsigned int index) const;
// virtual std::vector<Variable*> * flatten(Variable* v) const;
virtual Value * toValue() const;
virtual int getMin() const;
virtual int getMax() const;
virtual Value * getValue(int i);
virtual std::string toString() const ;
static int min(bool);
static int max(bool);
bool isBooleanDomain() const {return bool_;}
virtual ~PredefinedDomain();
};
}
}
#endif

View File

@@ -0,0 +1,85 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#include "RangeDomain.hh"
#include "Values.hh"
#include <stdlib.h>
#include <sstream>
namespace epoch {
namespace altarica {
RangeDomain::RangeDomain(int inf, int sup):
inf_(inf), sup_(sup) {
arity_ = sup-inf+1;
}
unsigned int RangeDomain::index(std::string arg) const {
return (atoi(arg.c_str()));
}
std::string RangeDomain::text(unsigned int index) const {
std::string s;
s += index;
return s;
}
Value * RangeDomain::toValue() const {
return new ValueInt(this);
}
int RangeDomain::getMin() const {
return inf_;
}
int RangeDomain::getMax() const {
return sup_;
}
// Value * RangeDomain::getFixedValue(int i) {
// return new FixedInt(i);
// }
Value * RangeDomain::getValue(int i) {
ValueInt * oi = new ValueInt();
oi->setValue(i);
return oi;
}
std::string RangeDomain::toString() const {
std::stringstream ss;
// std::string s;
ss<< "[";
ss<<inf_;
ss<<",";
ss<<sup_;
ss<<"]";
return ss.str();
}
}
}

View File

@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_RANGE_DOMAIN_H_
#define ALTA_RANGE_DOMAIN_H_
#include "DiscreteDomain.hh"
namespace epoch {
namespace altarica {
class RangeDomain : public DiscreteDomain {
protected:
int inf_;
int sup_;
public:
RangeDomain(int inf, int sup);
virtual unsigned int index(std::string arg) const;
virtual std::string text(unsigned int index) const;
// virtual std::vector<Variable*> * flatten(Variable* v) const;
virtual Value * toValue() const;
virtual int getMin() const;
virtual int getMax() const;
virtual Value * getValue(int i);
virtual std::string toString() const;
virtual ~RangeDomain() {};
};
}
}
#endif

View File

@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#include "RealDomain.hh"
#include "DiscreteDomain.hh"
#include "values/ValueReal.hh"
namespace epoch {
namespace altarica {
RealDomain::RealDomain(const DiscreteDomain *d) :Domain(){
if (d != NULL)
di = boost::icl::continuous_interval<double>(d->getMin(), d->getMax(), boost::icl::interval_bounds::closed());
else
di = boost::icl::continuous_interval<double>(std::numeric_limits<double>::min(), std::numeric_limits<double>::max(), boost::icl::interval_bounds::closed());
}
RealDomain::RealDomain() :Domain(){
di = boost::icl::continuous_interval<double>(std::numeric_limits<double>::min(), std::numeric_limits<double>::max(), boost::icl::interval_bounds::closed());
}
RealDomain::RealDomain(double inf, double sup, bool openleft, bool openright) {
if (openright)
if (openleft)
di = boost::icl::continuous_interval<double>(inf, sup, boost::icl::interval_bounds::open());
else
di = boost::icl::continuous_interval<double>(inf, sup, boost::icl::interval_bounds::right_open());
else
if (openleft)
di = boost::icl::continuous_interval<double>(inf, sup, boost::icl::interval_bounds::left_open());
else
di = boost::icl::continuous_interval<double>(inf, sup, boost::icl::interval_bounds::closed());
}
Value * RealDomain::toValue() const {
return new ValueReal(this);
}
std::string RealDomain::toString() const {
std::stringstream ss;
ss << di;
return ss.str();
}
unsigned int RealDomain::getArity() const {
if (di.upper() == di.lower() &&
di.bounds() == boost::icl::interval_bounds::closed())
return 1;
return std::numeric_limits<unsigned int>::infinity();
}
}
}

View File

@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_REAL_DOMAIN_H_
#define ALTA_REAL_DOMAIN_H_
#include "Domain.hh"
#include <boost/icl/continuous_interval.hpp>
namespace epoch {
namespace altarica {
class DiscreteDomain;
class RealDomain : public Domain {
protected:
boost::icl::continuous_interval<double> di;
public:
RealDomain(const DiscreteDomain *d);
RealDomain();
RealDomain(double inf, double sup,
bool openleft=false,
bool openright=false);
virtual ~RealDomain() {};
// virtual std::vector<Variable*> * flatten(Variable* v) const = 0;
virtual Value * toValue() const;
virtual std::string toString() const;
virtual unsigned int getArity() const;
const boost::icl::continuous_interval<double>& getBI() const {return di;}
double getMin() const {return di.lower();}
double getMax() const {return di.upper();}
};
}
}
#endif

View File

@@ -0,0 +1,122 @@
/*******************************************************************************
* Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab) et de
* l'IRT AESE (IRT Saint Exupéry).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab) and of
* the IRT AESE (IRT Saint Exupéry).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
* Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
*
*******************************************************************************/
#include "StructuredDomain.hh"
#include "Variable.hh"
namespace epoch {
namespace altarica {
StructuredDomain::StructuredDomain() {
arity_ = 1;
}
void StructuredDomain::addDomains(std::vector<std::string> *domainNames, Domain* domain) {
for (std::vector<std::string>::iterator idit = domainNames->begin(); idit!=domainNames->end(); ++idit)
addDomain(*idit, domain);
}
void StructuredDomain::addDomain(std::string domainName, Domain* domain) {
if (sdomain_.find(domainName) != sdomain_.end())
BOOST_THROW_EXCEPTION(std::runtime_error("bad identifier for domain name"));
sdomain_[domainName] = domain;
arity_ *= domain->getArity();
}
void StructuredDomain::addMyDomainsTo(StructuredDomain * sd) {
for (std::map<std::string, Domain*>::iterator dit = sdomain_.begin();
dit != sdomain_.end(); ++dit)
sd->addDomain((*dit).first,(*dit).second);
}
unsigned int StructuredDomain::index(std::string arg) const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("index asked on a Structured domain")));
return 0;
}
std::string StructuredDomain::text(unsigned int index) const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("text asked on a Structured domain")));
return "text associated to a structured domain";
}
Value * StructuredDomain::toValue() const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("toValue asked on a Structured domain")));
return NULL;
}
int StructuredDomain::getMin() const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getMin asked on a Structured domain")));
return -1;
}
int StructuredDomain::getMax() const {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getMax asked on a Structured domain")));
return -1;
}
// Value * StructuredDomain::getFixedValue(int i) {
// BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getFixedValue(i) asked on a structDomain")));
// return NULL;
// }
Value * StructuredDomain::getValue(int i) {
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getFixedValue(i) asked on a structDomain")));
return NULL;
}
std::vector<Variable*> * StructuredDomain::flatten(Variable* v) const {
std::vector<Variable*> * nvv = new std::vector<Variable*>();
for (std::map<std::string, Domain*>::const_iterator i = sdomain_.begin(); i != sdomain_.end(); ++i) {
std::vector<Variable*> * fv = (*i).second->flatten(v);
for (std::vector<Variable*>::iterator fvi= fv->begin(); fvi != fv->end(); ++fvi) {
Variable * nv = (*fvi)->clone();
nv->addToMASecond((*i).first);
nvv->push_back(nv);
}
delete(fv);
}
return nvv;
}
std::string StructuredDomain::toString() const {
return "STRUCTURED";
}
StructuredDomain::~StructuredDomain() {
sdomain_.clear();
}
}
}

View File

@@ -0,0 +1,75 @@
/*******************************************************************************
* Copyright (c) 2015-2016 ONERA.
* Ce logiciel est la propriété de lONERA (the French Aerospace Lab).
* Tous droits réservés.
*
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
* au droit français et respectant les principes de diffusion des logiciels libres.
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
* This software is property of ONERA (the French Aerospace Lab).
* All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.
* You can use, modify and/ or redistribute the software under the terms of
* the CeCILL-C license (http://www.cecill.info).
*
* Contributeurs/contributors:
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*
*******************************************************************************/
#ifndef ALTA_STRUCT_DOMAIN_H_
#define ALTA_STRUCT_DOMAIN_H_
#include "DiscreteDomain.hh"
#include <map>
#include <vector>
namespace epoch {
namespace altarica {
//! Structured Domain
/*!
Stucture pour stocker les types complexes d'altarica
*/
class StructuredDomain : public DiscreteDomain {
protected:
//! les types sont stockes dans une map id->type
std::map<std::string, Domain*> sdomain_;
public:
//! constructeur qui ne fait rien
StructuredDomain();
//! ajout des domaines, cas ou on a plusieurs id pour 1 domaine
void addDomains(std::vector<std::string>* domainNames, Domain* domain);
//! ajout d'un domaine au type structure
void addDomain(std::string domainName, Domain *domain);
void addMyDomainsTo(StructuredDomain * sd);
//! calcule un index. attention aux debordements
virtual unsigned int index(std::string arg) const;
virtual std::string text(unsigned int index) const;
virtual std::vector<Variable*> * flatten(Variable* v) const;
virtual Value * toValue() const;
virtual int getMin() const;
virtual int getMax() const;
virtual Value * getValue(int i);
virtual std::string toString() const;
virtual ~StructuredDomain();
};
}
}
#endif