main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Jan 10 2020 11:38:25 for Gecode by
doxygen
1.8.16
gecode
flatzinc
varspec.hh
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Guido Tack <tack@gecode.org>
5
*
6
* Copyright:
7
* Guido Tack, 2007
8
*
9
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
#ifndef __GECODE_FLATZINC_VARSPEC__HH__
35
#define __GECODE_FLATZINC_VARSPEC__HH__
36
37
#include <
gecode/flatzinc/option.hh
>
38
#include <
gecode/flatzinc/ast.hh
>
39
#include <vector>
40
#include <iostream>
41
42
namespace
Gecode
{
namespace
FlatZinc {
43
45
class
Alias
{
46
public
:
47
const
int
v
;
48
Alias
(
int
v0) :
v
(v0) {}
49
};
50
52
class
VarSpec
{
53
public
:
55
virtual
~VarSpec
(
void
) {}
57
int
i
;
59
bool
alias
;
61
bool
assigned
;
63
bool
introduced
;
65
bool
funcDep
;
67
VarSpec
(
bool
introduced0,
bool
funcDep0)
68
:
introduced
(introduced0),
funcDep
(funcDep0) {}
69
};
70
72
class
IntVarSpec
:
public
VarSpec
{
73
public
:
74
Option<AST::SetLit* >
domain
;
75
IntVarSpec
(
const
Option<AST::SetLit* >
&
d
,
76
bool
introduced
,
bool
funcDep
)
77
:
VarSpec
(
introduced
,
funcDep
) {
78
alias
=
false
;
79
assigned
=
false
;
80
domain
=
d
;
81
}
82
IntVarSpec
(
int
i0,
bool
introduced
,
bool
funcDep
)
83
:
VarSpec
(
introduced
,
funcDep
) {
84
alias
=
false
;
assigned
=
true
;
i
= i0;
domain
=
Option<AST::SetLit* >::none
();
85
}
86
IntVarSpec
(
const
Alias
& eq,
bool
introduced
,
bool
funcDep
)
87
:
VarSpec
(
introduced
,
funcDep
) {
88
alias
=
true
;
i
= eq.
v
;
89
}
90
~IntVarSpec
(
void
) {
91
if
(!
alias
&& !
assigned
&&
domain
())
92
delete
domain
.some();
93
}
94
};
95
97
class
BoolVarSpec
:
public
VarSpec
{
98
public
:
99
Option<AST::SetLit* >
domain
;
100
BoolVarSpec
(
Option<AST::SetLit* >
&
d
,
bool
introduced
,
bool
funcDep
)
101
:
VarSpec
(
introduced
,
funcDep
) {
102
alias
=
false
;
assigned
=
false
;
domain
=
d
;
103
}
104
BoolVarSpec
(
bool
b
,
bool
introduced
,
bool
funcDep
)
105
:
VarSpec
(
introduced
,
funcDep
) {
106
alias
=
false
;
assigned
=
true
;
i
=
b
;
domain
=
Option<AST::SetLit* >::none
();
107
}
108
BoolVarSpec
(
const
Alias
& eq,
bool
introduced
,
bool
funcDep
)
109
:
VarSpec
(
introduced
,
funcDep
) {
110
alias
=
true
;
i
= eq.
v
;
111
}
112
~BoolVarSpec
(
void
) {
113
if
(!
alias
&& !
assigned
&&
domain
())
114
delete
domain
.some();
115
}
116
};
117
119
class
FloatVarSpec
:
public
VarSpec
{
120
public
:
121
Option<std::pair<double,double>
>
domain
;
122
FloatVarSpec
(
Option
<std::pair<double,double> >&
d
,
123
bool
introduced
,
bool
funcDep
)
124
:
VarSpec
(
introduced
,
funcDep
),
domain
(
d
) {
125
alias
=
false
;
assigned
=
false
;
126
}
127
FloatVarSpec
(
double
d
,
bool
introduced
,
bool
funcDep
)
128
:
VarSpec
(
introduced
,
funcDep
) {
129
alias
=
false
;
assigned
=
true
;
130
domain
=
Option<std::pair<double,double>
>::some(std::pair<double,double>(
d
,
d
));
131
}
132
FloatVarSpec
(
const
Alias
& eq,
bool
introduced
,
bool
funcDep
)
133
:
VarSpec
(
introduced
,
funcDep
) {
134
alias
=
true
;
i
= eq.
v
;
135
}
136
};
137
139
class
SetVarSpec
:
public
VarSpec
{
140
public
:
141
Option<AST::SetLit*>
upperBound
;
142
SetVarSpec
(
bool
introduced
,
bool
funcDep
) :
VarSpec
(
introduced
,
funcDep
) {
143
alias
=
false
;
assigned
=
false
;
144
upperBound
=
Option<AST::SetLit* >::none
();
145
}
146
SetVarSpec
(
const
Option<AST::SetLit* >
&
v
,
bool
introduced
,
bool
funcDep
)
147
:
VarSpec
(
introduced
,
funcDep
) {
148
alias
=
false
;
assigned
=
false
;
upperBound
=
v
;
149
}
150
SetVarSpec
(
AST::SetLit
*
v
,
bool
introduced
,
bool
funcDep
)
151
:
VarSpec
(
introduced
,
funcDep
) {
152
alias
=
false
;
assigned
=
true
;
153
upperBound
=
Option<AST::SetLit*>::some
(
v
);
154
}
155
SetVarSpec
(
const
Alias
& eq,
bool
introduced
,
bool
funcDep
)
156
:
VarSpec
(
introduced
,
funcDep
) {
157
alias
=
true
;
i
= eq.
v
;
158
}
159
~SetVarSpec
(
void
) {
160
if
(!
alias
&&
upperBound
())
161
delete
upperBound
.some();
162
}
163
};
164
165
}}
166
167
#endif
168
169
// STATISTICS: flatzinc-any
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::FlatZinc::FloatVarSpec::domain
Option< std::pair< double, double > > domain
Definition:
varspec.hh:121
Gecode::FlatZinc::IntVarSpec::~IntVarSpec
~IntVarSpec(void)
Definition:
varspec.hh:90
Gecode::FlatZinc::IntVarSpec::IntVarSpec
IntVarSpec(const Option< AST::SetLit * > &d, bool introduced, bool funcDep)
Definition:
varspec.hh:75
ast.hh
Gecode::FlatZinc::BoolVarSpec::BoolVarSpec
BoolVarSpec(Option< AST::SetLit * > &d, bool introduced, bool funcDep)
Definition:
varspec.hh:100
Gecode::FlatZinc::Option
Optional value.
Definition:
option.hh:41
Gecode::FlatZinc::BoolVarSpec::~BoolVarSpec
~BoolVarSpec(void)
Definition:
varspec.hh:112
Gecode::FlatZinc::BoolVarSpec::BoolVarSpec
BoolVarSpec(bool b, bool introduced, bool funcDep)
Definition:
varspec.hh:104
Gecode::FlatZinc::FloatVarSpec::FloatVarSpec
FloatVarSpec(Option< std::pair< double, double > > &d, bool introduced, bool funcDep)
Definition:
varspec.hh:122
Gecode::FlatZinc::VarSpec::~VarSpec
virtual ~VarSpec(void)
Destructor.
Definition:
varspec.hh:55
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(AST::SetLit *v, bool introduced, bool funcDep)
Definition:
varspec.hh:150
Gecode::FlatZinc::SetVarSpec::~SetVarSpec
~SetVarSpec(void)
Definition:
varspec.hh:159
Gecode::FlatZinc::Alias::Alias
Alias(int v0)
Definition:
varspec.hh:48
Gecode
Gecode toplevel namespace
Gecode::FlatZinc::BoolVarSpec::BoolVarSpec
BoolVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition:
varspec.hh:108
Gecode::FlatZinc::IntVarSpec
Specification for integer variables.
Definition:
varspec.hh:72
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(bool introduced, bool funcDep)
Definition:
varspec.hh:142
Gecode::FlatZinc::VarSpec::alias
bool alias
Whether the variable aliases another variable.
Definition:
varspec.hh:59
Gecode::FlatZinc::IntVarSpec::domain
Option< AST::SetLit * > domain
Definition:
varspec.hh:74
Gecode::FlatZinc::IntVarSpec::IntVarSpec
IntVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition:
varspec.hh:86
Gecode::FlatZinc::VarSpec
Base class for variable specifications.
Definition:
varspec.hh:52
Gecode::FlatZinc::BoolVarSpec
Specification for Boolean variables.
Definition:
varspec.hh:97
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition:
varspec.hh:155
Gecode::FlatZinc::FloatVarSpec
Specification for floating point variables.
Definition:
varspec.hh:119
Gecode::FlatZinc::VarSpec::VarSpec
VarSpec(bool introduced0, bool funcDep0)
Constructor.
Definition:
varspec.hh:67
Gecode::FlatZinc::Option::none
static Option< Val > none(void)
Definition:
option.hh:49
Gecode::FlatZinc::VarSpec::funcDep
bool funcDep
Whether the variable functionally depends on another variable.
Definition:
varspec.hh:65
Gecode::FlatZinc::SetVarSpec::SetVarSpec
SetVarSpec(const Option< AST::SetLit * > &v, bool introduced, bool funcDep)
Definition:
varspec.hh:146
Gecode::FlatZinc::SetVarSpec
Specification for set variables.
Definition:
varspec.hh:139
Gecode::FlatZinc::AST::SetLit
Set literal node
Definition:
ast.hh:171
Gecode::FlatZinc::VarSpec::assigned
bool assigned
Whether the variable is assigned.
Definition:
varspec.hh:61
Test::Int::Distinct::v
const int v[7]
Definition:
distinct.cpp:259
Gecode::FlatZinc::FloatVarSpec::FloatVarSpec
FloatVarSpec(double d, bool introduced, bool funcDep)
Definition:
varspec.hh:127
Gecode::FlatZinc::FloatVarSpec::FloatVarSpec
FloatVarSpec(const Alias &eq, bool introduced, bool funcDep)
Definition:
varspec.hh:132
Gecode::FlatZinc::IntVarSpec::IntVarSpec
IntVarSpec(int i0, bool introduced, bool funcDep)
Definition:
varspec.hh:82
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::FlatZinc::Alias::v
const int v
Definition:
varspec.hh:47
Gecode::FlatZinc::VarSpec::i
int i
Variable index.
Definition:
varspec.hh:57
Gecode::FlatZinc::BoolVarSpec::domain
Option< AST::SetLit * > domain
Definition:
varspec.hh:99
Gecode::FlatZinc::SetVarSpec::upperBound
Option< AST::SetLit * > upperBound
Definition:
varspec.hh:141
Gecode::FlatZinc::Alias
Alias for a variable specification
Definition:
varspec.hh:45
option.hh
Gecode::FlatZinc::Option::some
const Val & some(void) const
Definition:
option.hh:47
Gecode::FlatZinc::VarSpec::introduced
bool introduced
Whether the variable was introduced in the mzn2fzn translation.
Definition:
varspec.hh:63