varspec.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Guido Tack, 2007
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __GECODE_FLATZINC_VARSPEC__HH__
#define __GECODE_FLATZINC_VARSPEC__HH__
#include <gecode/flatzinc/option.hh>
#include <gecode/flatzinc/ast.hh>
#include <vector>
#include <iostream>
namespace Gecode { namespace FlatZinc {
class Alias {
public:
const int v;
Alias(int v0) : v(v0) {}
};
class VarSpec {
public:
virtual ~VarSpec(void) {}
int i;
bool alias;
bool assigned;
bool introduced;
bool funcDep;
VarSpec(bool introduced0, bool funcDep0)
: introduced(introduced0), funcDep(funcDep0) {}
};
class IntVarSpec : public VarSpec {
public:
Option<AST::SetLit* > domain;
IntVarSpec(const Option<AST::SetLit* >& d,
bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = false;
assigned = false;
domain = d;
}
IntVarSpec(int i0, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = false; assigned = true; i = i0; domain = Option<AST::SetLit* >::none();
}
IntVarSpec(const Alias& eq, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = true; i = eq.v;
}
~IntVarSpec(void) {
if (!alias && !assigned && domain())
delete domain.some();
}
};
class BoolVarSpec : public VarSpec {
public:
Option<AST::SetLit* > domain;
BoolVarSpec(Option<AST::SetLit* >& d, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = false; assigned = false; domain = d;
}
BoolVarSpec(bool b, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = false; assigned = true; i = b; domain = Option<AST::SetLit* >::none();
}
BoolVarSpec(const Alias& eq, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = true; i = eq.v;
}
~BoolVarSpec(void) {
if (!alias && !assigned && domain())
delete domain.some();
}
};
class FloatVarSpec : public VarSpec {
public:
Option<std::pair<double,double> > domain;
FloatVarSpec(Option<std::pair<double,double> >& d,
bool introduced, bool funcDep)
: VarSpec(introduced,funcDep), domain(d) {
alias = false; assigned = false;
}
FloatVarSpec(double d, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = false; assigned = true;
domain = Option<std::pair<double,double> >::some(std::pair<double,double>(d,d));
}
FloatVarSpec(const Alias& eq, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = true; i = eq.v;
}
};
class SetVarSpec : public VarSpec {
public:
Option<AST::SetLit*> upperBound;
SetVarSpec(bool introduced, bool funcDep) : VarSpec(introduced,funcDep) {
alias = false; assigned = false;
upperBound = Option<AST::SetLit* >::none();
}
SetVarSpec(const Option<AST::SetLit* >& v, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = false; assigned = false; upperBound = v;
}
SetVarSpec(AST::SetLit* v, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = false; assigned = true;
upperBound = Option<AST::SetLit*>::some(v);
}
SetVarSpec(const Alias& eq, bool introduced, bool funcDep)
: VarSpec(introduced,funcDep) {
alias = true; i = eq.v;
}
~SetVarSpec(void) {
if (!alias && upperBound())
delete upperBound.some();
}
};
}}
#endif
// STATISTICS: flatzinc-any
ast.hh
Gecode::FlatZinc::AST::SetLit
Set literal node
Definition ast.hh:171
Gecode::FlatZinc::Alias
Alias for a variable specification
Definition varspec.hh:45
Gecode::FlatZinc::Alias::Alias
Alias(int v0)
Definition varspec.hh:48
Gecode::FlatZinc::Alias::v
const int v
Definition varspec.hh:47
Gecode::FlatZinc::BoolVarSpec::~BoolVarSpec
~BoolVarSpec(void)
Definition varspec.hh:112
Gecode::FlatZinc::BoolVarSpec::BoolVarSpec
BoolVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition varspec.hh:108
Gecode::FlatZinc::BoolVarSpec::domain
Option< AST::SetLit * > domain
Definition varspec.hh:99
Gecode::FlatZinc::BoolVarSpec::BoolVarSpec
BoolVarSpec(Option< AST::SetLit * > &d, bool introduced, bool funcDep)
Definition varspec.hh:100
Gecode::FlatZinc::BoolVarSpec::BoolVarSpec
BoolVarSpec(bool b, bool introduced, bool funcDep)
Definition varspec.hh:104
Gecode::FlatZinc::FloatVarSpec::domain
Option< std::pair< double, double > > domain
Definition varspec.hh:121
Gecode::FlatZinc::FloatVarSpec::FloatVarSpec
FloatVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition varspec.hh:132
Gecode::FlatZinc::FloatVarSpec::FloatVarSpec
FloatVarSpec(Option< std::pair< double, double > > &d, bool introduced, bool funcDep)
Definition varspec.hh:122
Gecode::FlatZinc::FloatVarSpec::FloatVarSpec
FloatVarSpec(double d, bool introduced, bool funcDep)
Definition varspec.hh:127
Gecode::FlatZinc::IntVarSpec::IntVarSpec
IntVarSpec(int i0, bool introduced, bool funcDep)
Definition varspec.hh:82
Gecode::FlatZinc::IntVarSpec::domain
Option< AST::SetLit * > domain
Definition varspec.hh:74
Gecode::FlatZinc::IntVarSpec::IntVarSpec
IntVarSpec(const Option< AST::SetLit * > &d, bool introduced, bool funcDep)
Definition varspec.hh:75
Gecode::FlatZinc::IntVarSpec::~IntVarSpec
~IntVarSpec(void)
Definition varspec.hh:90
Gecode::FlatZinc::IntVarSpec::IntVarSpec
IntVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition varspec.hh:86
Gecode::FlatZinc::SetVarSpec::~SetVarSpec
~SetVarSpec(void)
Definition varspec.hh:159
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(const Option< AST::SetLit * > &v, bool introduced, bool funcDep)
Definition varspec.hh:146
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(AST::SetLit *v, bool introduced, bool funcDep)
Definition varspec.hh:150
Gecode::FlatZinc::SetVarSpec::upperBound
Option< AST::SetLit * > upperBound
Definition varspec.hh:141
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition varspec.hh:155
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(bool introduced, bool funcDep)
Definition varspec.hh:142
Gecode::FlatZinc::VarSpec::VarSpec
VarSpec(bool introduced0, bool funcDep0)
Constructor.
Definition varspec.hh:67
Gecode::FlatZinc::VarSpec::~VarSpec
virtual ~VarSpec(void)
Destructor.
Definition varspec.hh:55
Gecode::FlatZinc::VarSpec::i
int i
Variable index.
Definition varspec.hh:57
Gecode::FlatZinc::VarSpec::introduced
bool introduced
Whether the variable was introduced in the mzn2fzn translation.
Definition varspec.hh:63
Gecode::FlatZinc::VarSpec::assigned
bool assigned
Whether the variable is assigned.
Definition varspec.hh:61
Gecode::FlatZinc::VarSpec::alias
bool alias
Whether the variable aliases another variable.
Definition varspec.hh:59
Gecode::FlatZinc::VarSpec::funcDep
bool funcDep
Whether the variable functionally depends on another variable.
Definition varspec.hh:65
Gecode::FlatZinc
Interpreter for the FlatZinc language.
Gecode
Gecode toplevel namespace
option.hh
Gecode::FlatZinc::Option
Optional value.
Definition option.hh:41
Gecode::FlatZinc::Option::some
const Val & some(void) const
Definition option.hh:47
Gecode::FlatZinc::Option::none
static Option< Val > none(void)
Definition option.hh:49