44 extern const int* specs[];
46 extern const unsigned int n_examples;
88 int hints =
spec[spos++];
93 for (
int i=hints-1; i--; spos++)
114 for (
int w=0; w<
width(); w++)
117 for (
int h=0; h<
height(); h++)
123 switch (opt.branching()) {
140 for (
int w=0; w<
width(); w++) {
141 int hint =
spec[spos++];
142 cols += hint; spos += hint;
144 for (
int h=0; h<
height(); h++) {
145 int hint =
spec[spos++];
146 rows += hint; spos += hint;
150 for (
int w=0; w<
width(); w++)
153 for (
int h=0; h<
height(); h++)
184 for (
int h = 0; h <
height(); ++h) {
186 for (
int w = 0; w <
width(); ++w)
187 os << ((m(w,h).val() == 1) ?
'#' :
' ');
204 "Branch on rows/columns in order");
206 "Use AFC for branching");
207 opt.
parse(argc,argv);
208 if (opt.size() >= n_examples) {
209 std::cerr <<
"Error: size must be between 0 and "
210 << n_examples-1 << std::endl;
213 Script::run<Nonogram,DFS,SizeOptions>(opt);
284const int crocodile[] =
342const int pinwheel[] =
361const int difficult[] =
398const int non_unique[] =
435 const int dragonfly[] =
482 const int castle[] = {
488 10, 2,4,2,1,1,1,4,1,1,2,
491 9, 3,3,3,1,1,6,1,1,1,
492 9, 3,2,2,2,2,8,1,1,3,
530 10, 1,1,4,2,1,1,1,1,1,4,
540 9, 1,2,2,2,2,4,1,1,3,
551 13, 2,2,4,9,1,5,1,1,1,1,1,1,1,
555 12, 4,5,3,14,1,1,1,1,4,1,1,3,
556 19, 3,3,2,2,2,4,1,1,1,1,1,1,1,1,3,1,1,3,2,
557 11, 8,2,7,2,1,1,2,1,1,3,3,
558 13, 1,5,9,12,2,1,1,3,1,1,2,2,1,
559 17, 3,2,2,1,1,1,1,4,1,1,1,3,3,1,1,2,2,
560 12, 5,2,2,2,2,1,5,2,1,1,2,5,
561 12, 3,5,9,2,1,1,6,3,1,3,2,3,
562 12, 1,4,1,1,1,4,1,5,5,3,3,3,
563 10, 4,1,1,1,1,3,4,6,6,3,
564 12, 3,1,3,1,1,3,3,1,1,4,6,1,
565 11, 3,1,5,1,1,3,1,1,9,4,1,
566 14, 2,1,1,7,1,4,1,1,1,1,1,1,3,5,
567 11, 9,2,1,3,1,1,1,1,4,2,1,
568 10, 1,14,1,1,2,2,2,10,1,2,
569 10, 1,9,2,1,2,6,1,5,3,2,
570 12, 1,9,9,1,2,2,3,1,1,4,3,1,
571 10, 10,1,3,4,1,3,2,1,2,8,
572 9, 9,1,3,5,1,1,1,2,7,
573 12, 4,5,1,2,5,1,3,1,1,2,1,3,
574 14, 1,1,1,1,2,6,2,3,2,1,1,2,3,1,
575 11, 1,6,1,5,7,1,3,3,2,4,3,
576 10, 1,2,1,2,9,1,5,2,6,2,
577 8, 10,2,2,13,1,3,3,1,
578 11, 2,2,1,6,2,3,3,2,2,2,1,
579 12, 2,2,1,1,12,2,2,9,2,2,2,2,
580 9, 5,1,2,4,1,5,11,2,2,
650 const int webpbn436[]=
666 6, 12, 2, 3, 2, 3, 2,
676 7, 6, 2, 2, 2, 2, 2, 2,
701 7, 4, 2, 2, 2, 2, 3, 1,
702 7, 3, 1, 2, 2, 2, 3, 3,
703 7, 3, 2, 2, 2, 2, 2, 4,
711 7, 10, 2, 2, 2, 2, 2, 10,
712 9, 4, 2, 3, 3, 2, 2, 3, 2, 5,
732 const int webpbn21[]=
813 7, 2, 1, 3, 1, 3, 1, 4,
815 7, 5, 1, 3, 1, 3, 1, 3,
827 7, 1, 1, 1, 1, 1, 1, 3,
828 8, 1, 1, 1, 1, 1, 1, 1, 1,
829 7, 1, 1, 1, 1, 1, 1, 1,
904 const int webpbn23[]=
947 8, 2, 1, 1, 1, 1, 1, 1, 2,
948 8, 2, 1, 1, 2, 2, 1, 1, 2,
949 8, 2, 1, 1, 2, 2, 1, 1, 2,
954 8, 2, 1, 1, 2, 2, 1, 1, 2,
955 8, 2, 1, 1, 2, 2, 1, 1, 2,
956 8, 2, 1, 1, 1, 1, 1, 1, 2,
982 8, 2, 1, 1, 1, 1, 1, 1, 2,
983 8, 2, 1, 1, 2, 2, 1, 1, 2,
984 8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 1, 1, 1, 1,
1126 11, 1, 2, 1, 3, 1, 1, 6, 1, 1, 1, 1,
1127 11, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1128 6, 1, 7, 2, 16, 1, 1,
1129 11, 6, 1, 2, 3, 2, 2, 2, 2, 1, 1, 1,
1130 12, 3, 4, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1,
1131 11, 1, 7, 3, 2, 2, 2, 2, 2, 1, 1, 1,
1132 9, 6, 5, 2, 2, 2, 2, 6, 1, 1,
1133 10, 3, 2, 2, 2, 2, 2, 2, 4, 1, 1,
1134 9, 1, 2, 2, 2, 2, 2, 2, 13, 1,
1135 9, 1, 2, 2, 2, 2, 2, 2, 1, 2,
1136 7, 1, 2, 2, 2, 2, 2, 16,
1137 6, 3, 2, 2, 2, 2, 3,
1146 7, 1, 2, 2, 2, 2, 2, 1,
1147 7, 4, 2, 2, 4, 2, 2, 4,
1148 7, 4, 2, 2, 4, 2, 2, 4,
1149 7, 1, 2, 2, 2, 2, 2, 1,
1150 7, 6, 2, 2, 2, 2, 2, 6,
1151 7, 6, 2, 2, 2, 2, 2, 6,
1155 8, 1, 1, 2, 1, 1, 2, 1, 1,
1156 6, 9, 2, 2, 2, 2, 9,
1158 6, 1, 1, 1, 1, 1, 1,
1167 7, 1, 1, 1, 4, 1, 1, 1,
1170 7, 1, 2, 1, 2, 1, 2, 1,
1172 7, 1, 1, 6, 2, 6, 1, 1,
1173 9, 1, 1, 1, 1, 2, 1, 1, 1, 1,
1174 7, 1, 1, 6, 2, 6, 1, 1,
1175 6, 1, 1, 5, 5, 1, 1,
1176 7, 1, 1, 1, 8, 1, 1, 1,
1177 6, 1, 1, 4, 4, 1, 1,
1186 const int *specs[] = {heart, bear, crocodile, unknown,
1187 pinwheel, difficult, non_unique, dragonfly,
1200 const unsigned n_examples =
sizeof(specs)/
sizeof(
int*);
Deterministic finite automaton (DFA)
Parametric base-class for scripts.
Matrix-interface for arrays.
Slice< A > col(int c) const
Access column c.
Slice< A > row(int r) const
Access row r.
Regular expressions over integer values.
Options for scripts with additional size parameter
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
int main(int argc, char *argv[])
Main-function.
int width(void) const
Return width of board.
const int * specs[]
Specification for a heart-shaped picture.
virtual Space * copy(void)
Copy space during cloning.
@ BRANCH_NONE
Branch on rows/columns in order.
@ BRANCH_AFC
Use AFC for branching.
BoolVarArray b
Fields of board.
int height(void) const
Return height of board.
Nonogram(Nonogram &s)
Constructor for cloning s.
const int * spec
Specification to be used.
virtual void print(std::ostream &os) const
Print solution.
Nonogram(const SizeOptions &opt)
Construction of the model.
DFA line(int &spos)
Returns next regular expression for line starting from spos.
void parse(int argc, char *argv[])
Parse commandline arguments.
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 extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
Gecode toplevel namespace
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.
BoolValBranch BOOL_VAL_MAX(void)
Select largest value.
BoolVarBranch BOOL_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count with decay factor d.