56 int v0 = 5,
int q0 = 3,
int lambda0 = 2,
int d0 = 4)
58 _v(
"v",
"number of sequences", v0 ),
59 _q(
"q",
"number of symbols", q0 ),
60 _l(
"l",
"sets of symbols per sequence (lambda)", lambda0),
61 _d(
"d",
"Hamming distance between sequences", d0 ),
62 _permutation(
"permutation",
"use permutation constraints if d=4",
73 _permutation.add(
true,
"full" );
74 _permutation.add(
false,
"none");
80 void parse(
int& argc,
char* argv[]) {
84 int v(
void)
const {
return _v.value(); }
86 int q(
void)
const {
return _q.value(); }
88 int l(
void)
const {
return _l.value(); }
90 int d(
void)
const {
return _d.value(); }
93 bool permutation(
void)
const {
return d() == 4 && _permutation.value(); }
146 for (
int i =
q; i--; )
values[i] = i+1;
148 for (
int i =
v; i--; )
155 for (
int a = 0; a <
v; ++a) {
156 for (
int b = a+1; b <
v; ++b) {
157 for (
int i =
n; i--; ) {
158 rel(*
this, cm(i, a),
IRT_NQ, cm(i, b), diffm(i, nseqi));
174 if (opt.symmetry()) {
177 for (
int r = 0; r<
v-1; ++r) {
178 rel(*
this, cm.
row(r), row_less, cm.
row(r+1));
181 for (
int c = 0;
c<
n-1; ++
c) {
187 for (
int c = 0;
c <
n; ++
c) {
197 if (opt.permutation()) {
204 for (
int r1 = 0; r1 <
v; ++r1) {
205 for (
int r2 = r1+1; r2 <
v; ++r2) {
210 for (
int i =
d; i--; ) perm[i] =
IntVar(*
this, 0,
n-1);
212 IntVar cform(*
this, 0, 1);
218 for (
int i = 2*
d; i--; ) _p[i] =
IntVar(*
this, 1,
q);
220 for (
int i = 0; i < 2; ++i) {
221 for (
int j = 0; j <
d; ++j) {
222 element(*
this, row1, perm[k[i][j]], p(j, i));
227 for (
int i = 0; i <
d; ++i) {
229 rel(*
this, cform*
d + i == index);
231 element(*
this, _p, index, value);
232 element(*
this, row2, perm[i], value);
245 for (
int i =
n; i--; ) {
248 rel(*
this, (!p1b[i] && !p2b[i] && !p3b[i] && !p4b[i]) ==
249 (row1[i] == row2[i]));
258 rel(*
this, perm[0],
IRT_NQ, perm[2], cformb);
259 rel(*
this, perm[0],
IRT_NQ, perm[3], cformb);
260 rel(*
this, perm[1],
IRT_NQ, perm[2], cformb);
261 rel(*
this, perm[1],
IRT_NQ, perm[3], cformb);
267 rel(*
this, (!cformb) >> (perm[2] < perm[3]));
279 for (
int i = 0; i <
v; ++i) {
281 os << r << std::endl;
296 c.update(*
this, s.
c);
302 return new EFPA(*
this);
311 EFPAOptions opt(
"Equidistant Frequency Permutation Arrays");
313 opt.
parse(argc,argv);
Options for EFPA problems
int v(void) const
Get v, number of sequences.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc).
bool symmetry(void) const
Whether to use symmetry breaking.
int q(void) const
Get q, number of symbols.
int l(void) const
Get lambda, sets of symbols per sequence.
int d(void) const
Get d, Hamming distance between sequences.
EFPAOptions(const char *s, int v0=5, int q0=3, int lambda0=2, int d0=4)
Initialize options for example with name s.
bool permutation(void) const
Whether to use permutation constraints. Only active if d=4.
int v
Number of sequences.
IntVarArray c
Variables for sequences.
int d
Hamming distance between any pair of sequences.
int main(int argc, char *argv[])
Main-function.
int nseqpair
Number of sequence pairs ( ).
int n
Length of sequence ( ).
EFPA(const EFPAOptions &opt)
Actual model.
int l
Number of sets of symbols for a sequence ( ).
BoolVarArray diff
Differences between sequences.
virtual void print(std::ostream &os) const
Print instance and solution.
virtual Space * copy(void)
Copy during cloning.
EFPA(EFPA &s)
Constructor for cloning s.
void add(Driver::BaseOption &o)
Add new option o.
void parse_strict(int &argc, char *argv[])
Parse options with strict checking (equivalent to parse() with true).
Passing Boolean variables.
Boolean integer variables.
static void run(const Options &opt, Script *s=nullptr)
String-valued option (integer value defined by strings).
Passing integer arguments.
Passing integer variables.
Matrix-interface for arrays.
Slice< A > col(int c) const
Access column c.
Slice< A > row(int r) const
Access row r.
Options(const char *s)
Initialize options for script with name s.
Driver::StringOption _symmetry
General symmetry options.
void parse(int argc, char *argv[])
Parse commandline arguments.
Driver::ScriptBase< Driver::IgnoreStepOption< Space > > Script
Base-class for scripts.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
IntRelType
Relation types for integers.
@ IRT_LQ
Less or equal ( ).
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
Gecode toplevel namespace
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel ipl=IPL_DEF)
Post propagator for .
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
void element(Home home, IntSharedArray n, IntVar x0, IntVar x1, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for .
void values(Home home, const IntVarArgs &x, IntSet y, IntPropLevel ipl=IPL_DEF)
Post constraint .
IntValBranch INT_VAL_MIN(void)
Select smallest value.
LinIntExpr cardinality(const SetExpr &)
Cardinality of set expression.