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