Generated on Tue Apr 18 10:21:30 2017 for Gecode by doxygen 1.6.3

nonogram.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Mikael Lagerkvist, 2005
00008  *
00009  *  Last modified:
00010  *     $Date: 2017-02-16 12:11:51 +0100 (Thu, 16 Feb 2017) $ by $Author: schulte $
00011  *     $Revision: 15434 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #include <gecode/driver.hh>
00039 #include <gecode/int.hh>
00040 #include <gecode/minimodel.hh>
00041 
00042 
00043 using namespace Gecode;
00044 
00045 namespace {
00046 
00048   extern const int* specs[];
00050   extern const unsigned int n_examples;
00051 
00052 }
00053 
00071 class Nonogram : public Script {
00072 protected:
00074   const int* spec;
00076   BoolVarArray b;
00077 
00079   int width(void) const {
00080     return spec[0];
00081   }
00083   int height(void) const {
00084     return spec[1];
00085   }
00086 
00088   DFA line(int& spos) {
00089     REG r0(0), r1(1);
00090     REG border = *r0;
00091     REG between = +r0;
00092     int hints = spec[spos++];
00093     REG r = border;
00094     if (hints > 0) {
00095       r += r1(spec[spos],spec[spos]);
00096       spos++;
00097       for (int i=hints-1; i--; spos++)
00098         r += between + r1(spec[spos],spec[spos]);
00099     }
00100     return r + border;
00101   }
00102 
00103 public:
00104   // Branching variants
00105   enum {
00106     BRANCH_NONE, 
00107     BRANCH_AFC,  
00108   };
00109 
00111   Nonogram(const SizeOptions& opt)
00112     : Script(opt), spec(specs[opt.size()]), b(*this,width()*height(),0,1) {
00113     Matrix<BoolVarArray> m(b, width(), height());
00114 
00115     {
00116       int spos = 2;
00117       // Post constraints for columns
00118       for (int w=0; w<width(); w++)
00119         extensional(*this, m.col(w), line(spos));
00120       // Post constraints for rows
00121       for (int h=0; h<height(); h++)
00122         extensional(*this, m.row(h), line(spos));
00123     }
00124 
00125 
00126 
00127     switch (opt.branching()) {
00128     case BRANCH_NONE:
00129       {
00130         /*
00131          * The following branches either by columns or rows, depending on
00132          * whether there are more hints relative to the height or width
00133          * for columns or rows.
00134          *
00135          * This idea is due to Pascal Van Hentenryck and has been suggested
00136          * to us by Hakan Kjellerstrand.
00137          */
00138 
00139         // Number of hints for columns
00140         int cols = 0;
00141         // Number of hints for rows
00142         int rows = 0;
00143         int spos = 2;
00144         for (int w=0; w<width(); w++) {
00145           int hint = spec[spos++];
00146           cols += hint; spos += hint;
00147         }
00148         for (int h=0; h<height(); h++) {
00149           int hint = spec[spos++];
00150           rows += hint; spos += hint;
00151         }
00152 
00153         if (rows*width() > cols*height()) {
00154           for (int w=0; w<width(); w++)
00155             branch(*this, m.col(w), BOOL_VAR_NONE(), BOOL_VAL_MAX());
00156         } else {
00157           for (int h=0; h<height(); h++)
00158             branch(*this, m.row(h), BOOL_VAR_NONE(), BOOL_VAL_MAX());
00159         }
00160       }
00161       break;
00162     case BRANCH_AFC:
00163       /*
00164        * The following just uses the AFC for branching. This is
00165        * equivalent to SIZE/AFC in this case since the variables are
00166        * binary.
00167        */
00168       branch(*this, b, BOOL_VAR_AFC_MAX(opt.decay()), BOOL_VAL_MAX());
00169       break;
00170     }
00171   }
00172 
00174   Nonogram(bool share, Nonogram& s) : Script(share,s), spec(s.spec) {
00175     b.update(*this, share, s.b);
00176   }
00177 
00179   virtual Space*
00180   copy(bool share) {
00181     return new Nonogram(share,*this);
00182   }
00183 
00185   virtual void
00186   print(std::ostream& os) const {
00187     Matrix<BoolVarArray> m(b, width(), height());
00188     for (int h = 0; h < height(); ++h) {
00189       os << '\t';
00190       for (int w = 0; w < width(); ++w)
00191         os << ((m(w,h).val() == 1) ? '#' : ' ');
00192       os << std::endl;
00193     }
00194     os << std::endl;
00195   }
00196 };
00197 
00198 
00202 int
00203 main(int argc, char* argv[]) {
00204   SizeOptions opt("Nonogram");
00205   opt.size(8);
00206   opt.branching(Nonogram::BRANCH_AFC);
00207   opt.branching(Nonogram::BRANCH_NONE, "none",
00208                 "Branch on rows/columns in order");
00209   opt.branching(Nonogram::BRANCH_AFC, "afc",
00210                 "Use AFC for branching");
00211   opt.parse(argc,argv);
00212   if (opt.size() >= n_examples) {
00213     std::cerr << "Error: size must be between 0 and "
00214               << n_examples-1 << std::endl;
00215     return 1;
00216   }
00217   Script::run<Nonogram,DFS,SizeOptions>(opt);
00218   return 0;
00219 }
00220 
00221 namespace {
00222 
00234 
00235 const int heart[] =
00236   { 9, 9,
00237     // Column constraints.
00238     1, 3,
00239     2, 2, 3,
00240     2, 2, 2,
00241     2, 2, 2,
00242     2, 2, 2,
00243     2, 2, 2,
00244     2, 2, 2,
00245     2, 2, 3,
00246     1, 3,
00247     // Row constraints
00248     2, 2, 2,
00249     2, 4, 4,
00250     3, 1, 3, 1,
00251     3, 2, 1, 2,
00252     2, 1, 1,
00253     2, 2, 2,
00254     2, 2, 2,
00255     1, 3,
00256     1, 1
00257   };
00258 
00260 const int bear[] =
00261   { 13, 8,
00262     // Column constraints
00263     1, 2,
00264     2, 2, 1,
00265     2, 3, 2,
00266     1, 6,
00267     2, 1, 4,
00268     1, 3,
00269     1, 4,
00270     1, 4,
00271     1, 4,
00272     1, 5,
00273     1, 4,
00274     2, 1, 3,
00275     1, 2,
00276     // Row constraints
00277     1, 1,
00278     1, 2,
00279     2, 4, 4,
00280     1, 12,
00281     1, 8,
00282     1, 9,
00283     2, 3, 4,
00284     2, 2, 2
00285   };
00286 
00288 const int crocodile[] =
00289   { 15, 9,
00290     // Column constraints
00291     1, 3,
00292     1, 4,
00293     2, 2, 2,
00294     2, 3, 1,
00295     2, 2, 3,
00296     2, 3, 2,
00297     2, 2, 3,
00298     2, 4, 2,
00299     2, 3, 2,
00300     1, 6,
00301     2, 1, 3,
00302     2, 1, 3,
00303     2, 1, 4,
00304     1, 5,
00305     1, 5,
00306     // Row constraints
00307     1, 3,
00308     3, 2, 3, 2,
00309     2, 10, 3,
00310     1, 15,
00311     5, 1, 1, 1, 1, 6,
00312     2, 1, 7,
00313     2, 1, 4,
00314     2, 1, 4,
00315     1, 4
00316   };
00317 
00319 const int unknown[] =
00320   { 10, 10,
00321     // Column constraints
00322     1, 3,
00323     2, 2, 1,
00324     2, 2, 2,
00325     2, 2, 1,
00326     3, 1, 2, 1,
00327     2, 1, 1,
00328     3, 1, 4, 1,
00329     3, 1, 1, 2,
00330     2, 3, 1,
00331     1, 4,
00332     // Row constraints
00333     1, 3,
00334     2, 2, 1,
00335     2, 1, 1,
00336     2, 1, 4,
00337     4, 1, 1, 1, 1,
00338     4, 2, 1, 1, 1,
00339     3, 2, 1, 1,
00340     2, 1, 2,
00341     2, 2, 3,
00342     1, 3
00343   };
00344 
00346 const int pinwheel[] =
00347   { 6, 6,
00348     // Column constraints
00349     2, 1, 2,
00350     1, 1,
00351     1, 2,
00352     1, 2,
00353     1, 1,
00354     2, 2, 1,
00355     // Row constraints
00356     2, 2, 1,
00357     1, 1,
00358     1, 2,
00359     1, 2,
00360     1, 1,
00361     2, 1, 2
00362   };
00363 
00365 const int difficult[] =
00366   { 15, 15,
00367     // Column constraints
00368     1, 3,
00369     1, 2,
00370     1, 2,
00371     1, 1,
00372     1, 2,
00373     1, 3,
00374     1, 2,
00375     1, 4,
00376     1, 3,
00377     1, 4,
00378     2, 2, 1,
00379     2, 1, 1,
00380     2, 1, 1,
00381     2, 1, 1,
00382     1, 3,
00383     // Row constraints
00384     1, 3,
00385     2, 1, 1,
00386     2, 1, 1,
00387     2, 1, 1,
00388     2, 1, 2,
00389     1, 5,
00390     1, 1,
00391     1, 2,
00392     1, 1,
00393     1, 1,
00394     2, 1, 2,
00395     2, 1, 2,
00396     2, 2, 1,
00397     2, 2, 2,
00398     1, 3
00399   };
00400 
00402 const int non_unique[] =
00403   { 11, 15,
00404     // Column constraints
00405     1, 5,
00406     3, 1, 2, 4,
00407     3, 2, 1, 3,
00408     4, 2, 2, 1, 1,
00409     4, 1, 1, 1, 1,
00410     2, 1, 5,
00411     5, 2, 1, 1, 3, 2,
00412     5, 2, 1, 1, 1, 1,
00413     3, 1, 4, 1,
00414     2, 1, 1,
00415     1, 1,
00416     // Row constraints
00417     2, 2, 2,
00418     2, 2, 2,
00419     1, 4,
00420     2, 1, 1,
00421     2, 1, 1,
00422     4, 1, 1, 1, 1,
00423     2, 1, 1,
00424     2, 1, 4,
00425     3, 1, 1, 1,
00426     3, 1, 1, 4,
00427     2, 1, 3,
00428     2, 1, 2,
00429     1, 5,
00430     2, 2, 2,
00431     2, 3, 3
00432   };
00433 
00439   const int dragonfly[] =
00440     { 20, 20,
00441       // Column constraints.
00442       4, 1, 1, 1, 2,
00443       5, 3, 1, 2, 1, 1,
00444       5, 1, 4, 2, 1, 1,
00445       4, 1, 3, 2, 4,
00446       4, 1, 4, 6, 1,
00447       3, 1, 11, 1,
00448       4, 5, 1, 6, 2,
00449       1, 14,
00450       2, 7, 2,
00451       2, 7, 2,
00452       3, 6, 1, 1,
00453       2, 9, 2,
00454       4, 3, 1, 1, 1,
00455       3, 3, 1, 3,
00456       3, 2, 1, 3,
00457       3, 2, 1, 5,
00458       3, 3, 2, 2,
00459       3, 3, 3, 2,
00460       3, 2, 3, 2,
00461       2, 2, 6,
00462       // Row constraints
00463       2, 7, 1,
00464       3, 1, 1, 2,
00465       3, 2, 1, 2,
00466       3, 1, 2, 2,
00467       3, 4, 2, 3,
00468       3, 3, 1, 4,
00469       3, 3, 1, 3,
00470       3, 2, 1, 4,
00471       2, 2, 9,
00472       3, 2, 1, 5,
00473       2, 2, 7,
00474       1, 14,
00475       2, 8, 2,
00476       3, 6, 2, 2,
00477       4, 2, 8, 1, 3,
00478       4, 1, 5, 5, 2,
00479       5, 1, 3, 2, 4, 1,
00480       5, 3, 1, 2, 4, 1,
00481       5, 1, 1, 3, 1, 3,
00482       4, 2, 1, 1, 2
00483     };
00484 
00486   const int castle[]  = {
00487     60, 35,
00488     // Column constraints
00489     7, 2,3,1,5,1,7,1,
00490     7, 2,4,2,3,2,3,5,
00491     8, 2,6,3,1,1,5,1,5,
00492     10, 2,4,2,1,1,1,4,1,1,2,
00493     7, 2,8,2,1,5,2,5,
00494     7, 3,1,6,2,5,1,5,
00495     9, 3,3,3,1,1,6,1,1,1,
00496     9, 3,2,2,2,2,8,1,1,3,
00497     7, 1,4,4,3,7,1,1,
00498     7, 1,2,2,2,3,7,9,
00499     8, 1,2,3,1,1,5,2,2,
00500     7, 2,2,3,1,1,6,1,
00501     6, 1,3,1,5,4,1,
00502     8, 1,3,1,1,6,1,3,1,
00503     8, 3,3,4,5,1,4,2,1,
00504     6, 2,3,3,9,7,1,
00505     8, 2,3,2,2,1,1,3,5,
00506     8, 4,2,1,1,1,1,2,3,
00507     7, 4,2,2,1,4,3,2,
00508     4, 4,3,16,2,
00509     5, 1,2,5,7,1,
00510     6, 4,3,2,2,7,1,
00511     5, 2,3,1,10,1,
00512     6, 2,4,2,1,4,1,
00513     5, 1,6,7,3,1,
00514     4, 3,11,3,1,
00515     5, 7,1,11,2,1,
00516     7, 2,2,2,2,2,2,2,
00517     7, 3,1,1,1,1,2,1,
00518     7, 2,2,2,2,1,1,1,
00519     7, 1,1,1,1,2,1,2,
00520     8, 2,2,2,2,1,1,1,1,
00521     5, 4,1,1,2,2,
00522     5, 5,2,17,2,1,
00523     6, 9,2,3,1,4,2,
00524     6, 9,4,2,1,1,1,
00525     5, 5,4,2,1,4,
00526     7, 11,1,2,1,4,1,2,
00527     5, 3,4,2,4,4,
00528     8, 2,1,4,1,2,1,5,2,
00529     5, 8,4,1,1,2,
00530     5, 1,1,3,2,3,
00531     6, 1,3,1,8,1,6,
00532     4, 2,1,7,14,
00533     7, 1,2,4,4,1,2,3,
00534     10, 1,1,4,2,1,1,1,1,1,4,
00535     6, 3,5,3,1,1,4,
00536     6, 2,4,2,2,1,2,
00537     5, 4,2,3,8,4,
00538     5, 4,15,2,2,4,
00539     6, 4,1,10,2,1,2,
00540     6, 2,12,6,1,2,4,
00541     7, 3,1,3,1,3,3,4,
00542     6, 3,1,2,3,4,1,
00543     7, 5,2,2,2,3,3,3,
00544     9, 1,2,2,2,2,4,1,1,3,
00545     7, 2,1,4,2,7,1,1,
00546     6, 5,2,2,3,6,3,
00547     7, 3,3,2,2,3,2,3,
00548     7, 4,1,2,1,1,2,1,
00549 
00550     // Row constraints
00551     4, 12,1,1,1,
00552     5, 8,6,3,1,3,
00553     6, 5,8,4,3,1,5,
00554     8, 7,3,4,1,3,5,1,7,
00555     13, 2,2,4,9,1,5,1,1,1,1,1,1,1,
00556     8, 4,5,10,2,1,8,7,1,
00557     7, 5,1,3,3,16,1,2,
00558     8, 8,5,1,2,4,9,1,3,
00559     12, 4,5,3,14,1,1,1,1,4,1,1,3,
00560     19, 3,3,2,2,2,4,1,1,1,1,1,1,1,1,3,1,1,3,2,
00561     11, 8,2,7,2,1,1,2,1,1,3,3,
00562     13, 1,5,9,12,2,1,1,3,1,1,2,2,1,
00563     17, 3,2,2,1,1,1,1,4,1,1,1,3,3,1,1,2,2,
00564     12, 5,2,2,2,2,1,5,2,1,1,2,5,
00565     12, 3,5,9,2,1,1,6,3,1,3,2,3,
00566     12, 1,4,1,1,1,4,1,5,5,3,3,3,
00567     10, 4,1,1,1,1,3,4,6,6,3,
00568     12, 3,1,3,1,1,3,3,1,1,4,6,1,
00569     11, 3,1,5,1,1,3,1,1,9,4,1,
00570     14, 2,1,1,7,1,4,1,1,1,1,1,1,3,5,
00571     11, 9,2,1,3,1,1,1,1,4,2,1,
00572     10, 1,14,1,1,2,2,2,10,1,2,
00573     10, 1,9,2,1,2,6,1,5,3,2,
00574     12, 1,9,9,1,2,2,3,1,1,4,3,1,
00575     10, 10,1,3,4,1,3,2,1,2,8,
00576     9, 9,1,3,5,1,1,1,2,7,
00577     12, 4,5,1,2,5,1,3,1,1,2,1,3,
00578     14, 1,1,1,1,2,6,2,3,2,1,1,2,3,1,
00579     11, 1,6,1,5,7,1,3,3,2,4,3,
00580     10, 1,2,1,2,9,1,5,2,6,2,
00581     8, 10,2,2,13,1,3,3,1,
00582     11, 2,2,1,6,2,3,3,2,2,2,1,
00583     12, 2,2,1,1,12,2,2,9,2,2,2,2,
00584     9, 5,1,2,4,1,5,11,2,2,
00585     3, 15,6,18,
00586   };
00587 
00593   const int p200[] =
00594     { 25, 25,
00595       // Column constraints
00596       4, 1,1,2,2,
00597       3, 5,5,7,
00598       4, 5,2,2,9,
00599       4, 3,2,3,9,
00600       5, 1,1,3,2,7,
00601       3, 3,1,5,
00602       5, 7,1,1,1,3,
00603       6, 1,2,1,1,2,1,
00604       3, 4,2,4,
00605       4, 1,2,2,2,
00606       3, 4,6,2,
00607       4, 1,2,2,1,
00608       4, 3,3,2,1,
00609       3, 4,1,15,
00610       6, 1,1,1,3,1,1,
00611       6, 2,1,1,2,2,3,
00612       4, 1,4,4,1,
00613       4, 1,4,3,2,
00614       4, 1,1,2,2,
00615       5, 7,2,3,1,1,
00616       5, 2,1,1,1,5,
00617       3, 1,2,5,
00618       4, 1,1,1,3,
00619       3, 4,2,1,
00620       1, 3,
00621       // Row constraints
00622       3, 2,2,3,
00623       5, 4,1,1,1,4,
00624       5, 4,1,2,1,1,
00625       7, 4,1,1,1,1,1,1,
00626       6, 2,1,1,2,3,5,
00627       6, 1,1,1,1,2,1,
00628       5, 3,1,5,1,2,
00629       6, 3,2,2,1,2,2,
00630       7, 2,1,4,1,1,1,1,
00631       6, 2,2,1,2,1,2,
00632       6, 1,1,1,3,2,3,
00633       5, 1,1,2,7,3,
00634       5, 1,2,2,1,5,
00635       5, 3,2,2,1,2,
00636       4, 3,2,1,2,
00637       3, 5,1,2,
00638       4, 2,2,1,2,
00639       4, 4,2,1,2,
00640       4, 6,2,3,2,
00641       4, 7,4,3,2,
00642       3, 7,4,4,
00643       3, 7,1,4,
00644       3, 6,1,4,
00645       3, 4,2,2,
00646       2, 2,1
00647     };
00648 
00649   // The following instances are from the http://webpbn.com site and
00650   // are all designed by Jan Wolter.
00651   // See also the survey at http://webpbn.com/survey/
00652 
00654   const int webpbn436[]=
00655     { 40, 35,
00656       // Column constraints
00657       1, 1,
00658       2, 3, 2,
00659       3, 2, 3, 3,
00660       3, 3, 3, 3,
00661       4, 3, 3, 3, 3,
00662       4, 4, 2, 2, 2,
00663       4, 3, 3, 2, 3,
00664       4, 3, 2, 2, 2,
00665       3, 3, 2, 6,
00666       2, 2, 9,
00667       3, 2, 3, 3,
00668       5, 4, 4, 3, 2, 4,
00669       5, 7, 2, 5, 2, 6,
00670       6, 12, 2, 3, 2, 3, 2,
00671       6, 3, 1, 2, 2, 2, 3,
00672       6, 2, 2, 3, 2, 2, 2,
00673       6, 6, 2, 6, 2, 2, 2,
00674       5, 12, 4, 3, 2, 2,
00675       4, 12, 2, 2, 2,
00676       3, 2, 6, 2,
00677       4, 2, 6, 5, 2,
00678       4, 10, 9, 2, 2,
00679       5, 12, 3, 3, 2, 2,
00680       7, 6, 2, 2, 2, 2, 2, 2,
00681       6, 2, 2, 3, 2, 2, 2,
00682       6, 4, 3, 2, 2, 2, 3,
00683       6, 7, 3, 3, 2, 3, 2,
00684       5, 5, 3, 5, 2, 6,
00685       5, 4, 3, 3, 3, 4,
00686       3, 3, 5, 3,
00687       2, 3, 9,
00688       3, 4, 2, 6,
00689       4, 4, 2, 2, 2,
00690       4, 4, 2, 2, 3,
00691       4, 3, 2, 2, 3,
00692       3, 3, 3, 3,
00693       3, 3, 3, 3,
00694       3, 4, 3, 3,
00695       3, 2, 3, 3,
00696       2, 2, 1,
00697       // Row constraints
00698       2, 2, 2,
00699       3, 2, 3, 2,
00700       4, 3, 3, 3, 2,
00701       4, 3, 3, 3, 3,
00702       6, 2, 3, 3, 3, 3, 2,
00703       6, 3, 3, 3, 3, 3, 3,
00704       6, 4, 2, 3, 2, 2, 4,
00705       7, 4, 2, 2, 2, 2, 3, 1,
00706       7, 3, 1, 2, 2, 2, 3, 3,
00707       7, 3, 2, 2, 2, 2, 2, 4,
00708       5, 3, 2, 15, 2, 4,
00709       3, 5, 19, 4,
00710       4, 6, 4, 3, 3,
00711       3, 6, 4, 4,
00712       4, 2, 4, 6, 2,
00713       6, 2, 2, 3, 3, 3, 2,
00714       6, 9, 2, 2, 2, 3, 9,
00715       7, 10, 2, 2, 2, 2, 2, 10,
00716       9, 4, 2, 3, 3, 2, 2, 3, 2, 5,
00717       5, 2, 5, 2, 4, 2,
00718       5, 5, 3, 2, 2, 5,
00719       5, 6, 3, 2, 3, 7,
00720       4, 6, 8, 9, 7,
00721       4, 4, 8, 7, 5,
00722       1, 4,
00723       1, 2,
00724       1, 2,
00725       1, 14,
00726       1, 16,
00727       2, 3, 3,
00728       2, 2, 2,
00729       2, 2, 2,
00730       2, 4, 4,
00731       1, 16,
00732       1, 12,
00733     };
00734 
00736   const int webpbn21[]=
00737     { 14, 25,
00738       // Column constraints
00739       1, 2,
00740       2, 4, 6,
00741       4, 9, 4, 4, 2,
00742       4, 1, 6, 2, 6,
00743     3, 1, 5, 2,
00744     2, 1, 6,
00745     2, 1, 5,
00746     2, 1, 4,
00747     2, 1, 4,
00748     3, 1, 4, 2,
00749     3, 1, 4, 6,
00750     5, 1, 6, 4, 4, 2,
00751     3, 9, 2, 6,
00752     2, 4, 2,
00753     // Row constraints
00754     1, 9,
00755     2, 1, 1,
00756     3, 1, 1, 1,
00757     3, 1, 3, 1,
00758     1, 13,
00759     1, 13,
00760     1, 13,
00761     1, 13,
00762     2, 2, 2,
00763     2, 2, 2,
00764     0,
00765     2, 2, 2,
00766     2, 2, 2,
00767     2, 2, 2,
00768     2, 2, 2,
00769     2, 2, 2,
00770     2, 2, 2,
00771     2, 2, 2,
00772     2, 2, 2,
00773     2, 2, 2,
00774     2, 2, 2,
00775     2, 2, 2,
00776     2, 2, 2,
00777     2, 2, 2,
00778     2, 2, 2,
00779   };
00780 
00782 const int webpbn27[]=
00783   { 27, 23,
00784     // Column constraints
00785     2, 4, 12,
00786     3, 6, 1, 1,
00787     3, 8, 1, 1,
00788     5, 3, 2, 2, 1, 1,
00789     6, 2, 1, 1, 2, 1, 6,
00790     4, 1, 1, 1, 1,
00791     6, 3, 1, 1, 2, 1, 1,
00792     5, 3, 2, 3, 1, 1,
00793     3, 10, 1, 1,
00794     5, 4, 2, 2, 1, 1,
00795     6, 3, 1, 1, 2, 1, 1,
00796     4, 2, 1, 1, 1,
00797     6, 3, 1, 1, 2, 1, 1,
00798     5, 3, 2, 3, 1, 6,
00799     3, 10, 1, 1,
00800     5, 4, 2, 2, 1, 1,
00801     6, 3, 1, 1, 2, 1, 1,
00802     4, 1, 1, 1, 9,
00803     6, 2, 1, 1, 2, 1, 1,
00804     5, 2, 2, 3, 1, 3,
00805     3, 8, 1, 5,
00806     3, 6, 1, 1,
00807     3, 4, 9, 1,
00808     2, 1, 1,
00809     2, 2, 1,
00810     2, 1, 1,
00811     1, 4,
00812     // Row constraints
00813     1, 11,
00814     1, 17,
00815     4, 3, 5, 5, 3,
00816     4, 2, 2, 2, 1,
00817     7, 2, 1, 3, 1, 3, 1, 4,
00818     4, 3, 3, 3, 3,
00819     7, 5, 1, 3, 1, 3, 1, 3,
00820     4, 3, 2, 2, 4,
00821     4, 5, 5, 5, 5,
00822     1, 23,
00823     0,
00824     1, 23,
00825     2, 1, 1,
00826     2, 1, 1,
00827     3, 1, 2, 1,
00828     4, 1, 1, 1, 1,
00829     4, 1, 1, 1, 1,
00830     5, 1, 10, 1, 2, 1,
00831     7, 1, 1, 1, 1, 1, 1, 3,
00832     8, 1, 1, 1, 1, 1, 1, 1, 1,
00833     7, 1, 1, 1, 1, 1, 1, 1,
00834     6, 1, 1, 1, 1, 2, 2,
00835     3, 5, 5, 3,
00836   };
00837 
00839   const int webpbn1[]=
00840   { 5, 10,
00841     // Column constraints
00842     2, 2, 1,
00843     3, 2, 1, 3,
00844     1, 7,
00845     2, 1, 3,
00846     2, 2, 1,
00847     // Row constraints
00848     1, 2,
00849     2, 2, 1,
00850     2, 1, 1,
00851     1, 3,
00852     2, 1, 1,
00853     2, 1, 1,
00854     1, 2,
00855     2, 1, 1,
00856     2, 1, 2,
00857     1, 2,
00858   };
00859 
00861   const int webpbn6[]=
00862   { 20, 20,
00863     // Column constraints
00864     1, 5,
00865     2, 5, 3,
00866     3, 2, 3, 4,
00867     3, 1, 7, 2,
00868     1, 8,
00869     1, 9,
00870     1, 9,
00871     1, 8,
00872     1, 7,
00873     1, 8,
00874     1, 9,
00875     1, 10,
00876     1, 13,
00877     2, 6, 2,
00878     1, 4,
00879     1, 6,
00880     1, 6,
00881     1, 5,
00882     1, 6,
00883     1, 6,
00884     // Row constraints
00885     1, 2,
00886     1, 2,
00887     1, 1,
00888     1, 1,
00889     2, 1, 3,
00890     2, 2, 5,
00891     4, 1, 7, 1, 1,
00892     4, 1, 8, 2, 2,
00893     3, 1, 9, 5,
00894     2, 2, 16,
00895     2, 1, 17,
00896     2, 7, 11,
00897     3, 5, 5, 3,
00898     2, 5, 4,
00899     2, 3, 3,
00900     2, 2, 2,
00901     2, 2, 1,
00902     2, 1, 1,
00903     2, 2, 2,
00904     2, 2, 2,
00905   };
00906 
00908   const int webpbn23[]=
00909   { 10, 11,
00910     // Column constraints
00911     1, 1,
00912     1, 3,
00913     1, 1,
00914     2, 2, 2,
00915     1, 2,
00916     1, 4,
00917     1, 1,
00918     1, 3,
00919     1, 3,
00920     1, 1,
00921     // Row constraints
00922     1, 1,
00923     1, 3,
00924     1, 1,
00925     1, 2,
00926     1, 1,
00927     1, 3,
00928     1, 3,
00929     1, 1,
00930     1, 2,
00931     1, 2,
00932     1, 4,
00933   };
00934 
00936 const int webpbn16[]=
00937   { 34, 34,
00938     // Column constraints
00939     2, 1, 1,
00940     2, 2, 2,
00941     2, 3, 3,
00942     4, 2, 1, 1, 2,
00943     4, 2, 1, 1, 2,
00944     4, 1, 1, 1, 1,
00945     4, 1, 1, 1, 1,
00946     1, 18,
00947     6, 2, 1, 1, 1, 1, 2,
00948     6, 1, 1, 1, 1, 1, 1,
00949     6, 1, 1, 1, 1, 1, 1,
00950     1, 26,
00951     8, 2, 1, 1, 1, 1, 1, 1, 2,
00952     8, 2, 1, 1, 2, 2, 1, 1, 2,
00953     8, 2, 1, 1, 2, 2, 1, 1, 2,
00954     2, 14, 14,
00955     4, 1, 1, 1, 1,
00956     4, 1, 1, 1, 1,
00957     2, 14, 14,
00958     8, 2, 1, 1, 2, 2, 1, 1, 2,
00959     8, 2, 1, 1, 2, 2, 1, 1, 2,
00960     8, 2, 1, 1, 1, 1, 1, 1, 2,
00961     1, 26,
00962     6, 1, 1, 1, 1, 1, 1,
00963     6, 1, 1, 1, 1, 1, 1,
00964     6, 2, 1, 1, 1, 1, 2,
00965     1, 18,
00966     4, 1, 1, 1, 1,
00967     4, 1, 1, 1, 1,
00968     4, 2, 1, 1, 2,
00969     4, 2, 1, 1, 2,
00970     2, 3, 3,
00971     2, 2, 2,
00972     2, 1, 1,
00973     // Row constraints
00974     2, 1, 1,
00975     2, 2, 2,
00976     2, 3, 3,
00977     4, 2, 1, 1, 2,
00978     4, 2, 1, 1, 2,
00979     4, 1, 1, 1, 1,
00980     4, 1, 1, 1, 1,
00981     1, 18,
00982     6, 2, 1, 1, 1, 1, 2,
00983     6, 1, 1, 1, 1, 1, 1,
00984     6, 1, 1, 1, 1, 1, 1,
00985     1, 26,
00986     8, 2, 1, 1, 1, 1, 1, 1, 2,
00987     8, 2, 1, 1, 2, 2, 1, 1, 2,
00988     8, 2, 1, 1, 2, 2, 1, 1, 2,
00989     2, 14, 14,
00990     4, 1, 1, 1, 1,
00991     4, 1, 1, 1, 1,
00992     2, 14, 14,
00993     8, 2, 1, 1, 2, 2, 1, 1, 2,
00994     8, 2, 1, 1, 2, 2, 1, 1, 2,
00995     8, 2, 1, 1, 1, 1, 1, 1, 2,
00996     1, 26,
00997     6, 1, 1, 1, 1, 1, 1,
00998     6, 1, 1, 1, 1, 1, 1,
00999     6, 2, 1, 1, 1, 1, 2,
01000     1, 18,
01001     4, 1, 1, 1, 1,
01002     4, 1, 1, 1, 1,
01003     4, 2, 1, 1, 2,
01004     4, 2, 1, 1, 2,
01005     2, 3, 3,
01006     2, 2, 2,
01007     2, 1, 1,
01008   };
01009 
01011   const int webpbn529[]=
01012   { 45, 45,
01013     // Column constraints
01014     6, 7, 1, 1, 1, 1, 1,
01015     13, 2, 2, 4, 1, 4, 1, 5, 1, 4, 1, 4, 1, 2,
01016     10, 3, 1, 4, 1, 4, 1, 14, 4, 1, 2,
01017     8, 1, 1, 5, 1, 2, 3, 4, 1,
01018     4, 3, 13, 1, 10,
01019     3, 1, 9, 4,
01020     4, 6, 7, 2, 2,
01021     4, 8, 4, 1, 4,
01022     6, 2, 8, 3, 2, 5, 3,
01023     5, 10, 1, 3, 7, 2,
01024     6, 8, 6, 2, 8, 1, 2,
01025     7, 1, 1, 2, 2, 8, 1, 1,
01026     11, 2, 1, 1, 1, 2, 1, 3, 1, 3, 3, 1,
01027     8, 2, 1, 1, 1, 5, 4, 2, 1,
01028     8, 2, 1, 1, 1, 1, 7, 2, 1,
01029     8, 2, 1, 1, 2, 9, 1, 2, 1,
01030     5, 4, 6, 12, 1, 3,
01031     4, 16, 13, 3, 2,
01032     3, 12, 21, 2,
01033     3, 2, 13, 23,
01034     3, 2, 14, 19,
01035     4, 2, 14, 20, 2,
01036     6, 2, 13, 7, 2, 8, 2,
01037     5, 12, 8, 1, 7, 2,
01038     9, 5, 1, 1, 1, 2, 8, 1, 5, 2,
01039     8, 2, 1, 1, 1, 9, 1, 1, 4,
01040     8, 2, 1, 1, 1, 6, 1, 3, 5,
01041     6, 2, 2, 1, 5, 6, 2,
01042     8, 2, 1, 3, 1, 3, 7, 3, 2,
01043     9, 2, 3, 2, 1, 1, 2, 4, 4, 2,
01044     9, 2, 2, 1, 1, 2, 3, 1, 8, 2,
01045     5, 9, 3, 1, 7, 2,
01046     5, 12, 4, 1, 6, 2,
01047     5, 7, 4, 1, 2, 5,
01048     5, 2, 6, 6, 5, 6,
01049     4, 8, 8, 6, 3,
01050     5, 3, 10, 8, 4, 2,
01051     5, 5, 11, 9, 5, 2,
01052     5, 3, 1, 12, 16, 2,
01053     4, 3, 1, 12, 16,
01054     4, 5, 2, 13, 21,
01055     6, 6, 1, 3, 3, 1, 1,
01056     14, 5, 1, 3, 1, 3, 1, 1, 2, 1, 4, 1, 3, 1, 3,
01057     13, 5, 1, 3, 1, 3, 1, 4, 1, 4, 1, 3, 1, 3,
01058     6, 1, 1, 1, 1, 1, 1,
01059     // Row constraints
01060     6, 7, 1, 1, 1, 1, 1,
01061     13, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 2,
01062     14, 1, 1, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 2,
01063     9, 2, 1, 2, 1, 1, 1, 1, 6, 2,
01064     4, 3, 30, 1, 5,
01065     9, 1, 5, 8, 1, 1, 7, 1, 1, 3,
01066     7, 3, 4, 8, 1, 5, 1, 2,
01067     4, 3, 20, 6, 6,
01068     6, 3, 3, 7, 2, 5, 1,
01069     9, 3, 3, 1, 1, 9, 1, 1, 5, 6,
01070     7, 2, 3, 8, 1, 3, 4, 2,
01071     7, 5, 3, 1, 10, 4, 5, 2,
01072     6, 1, 2, 3, 8, 4, 6,
01073     5, 2, 2, 3, 11, 10,
01074     5, 2, 2, 3, 10, 7,
01075     6, 2, 3, 1, 7, 12, 2,
01076     6, 2, 3, 1, 4, 11, 2,
01077     6, 4, 1, 2, 1, 11, 2,
01078     4, 9, 1, 2, 9,
01079     5, 6, 2, 1, 4, 11,
01080     6, 2, 5, 1, 2, 6, 6,
01081     5, 6, 2, 4, 8, 4,
01082     4, 4, 2, 16, 1,
01083     4, 2, 2, 15, 2,
01084     4, 3, 2, 15, 4,
01085     4, 3, 3, 13, 4,
01086     3, 4, 12, 9,
01087     3, 1, 9, 10,
01088     5, 2, 1, 17, 7, 2,
01089     6, 2, 2, 8, 3, 8, 2,
01090     6, 2, 3, 6, 3, 8, 2,
01091     6, 2, 4, 5, 4, 7, 2,
01092     5, 2, 5, 5, 4, 6,
01093     5, 4, 4, 5, 4, 9,
01094     5, 1, 4, 6, 4, 4,
01095     6, 4, 3, 6, 4, 3, 2,
01096     7, 2, 1, 2, 7, 4, 4, 2,
01097     7, 2, 2, 2, 9, 5, 5, 2,
01098     6, 2, 2, 2, 10, 6, 6,
01099     5, 3, 2, 1, 9, 18,
01100     3, 8, 4, 23,
01101     9, 1, 2, 1, 2, 2, 1, 1, 1, 2,
01102     12, 2, 1, 4, 2, 1, 4, 1, 5, 1, 3, 1, 2,
01103     11, 2, 1, 5, 4, 4, 1, 5, 1, 3, 1, 2,
01104     5, 1, 10, 1, 1, 1,
01105   };
01106 
01107 
01109   const int webpbn65[]=
01110   { 34, 40,
01111     // Column constraints
01112     1, 5,
01113     3, 3, 2, 1,
01114     4, 3, 2, 2, 1,
01115     5, 3, 2, 2, 2, 2,
01116     6, 3, 2, 2, 2, 2, 3,
01117     7, 1, 2, 2, 2, 2, 2, 16,
01118     9, 1, 2, 2, 2, 2, 2, 2, 1, 2,
01119     9, 1, 2, 2, 2, 2, 2, 2, 13, 1,
01120     10, 3, 2, 2, 2, 2, 2, 2, 4, 1, 1,
01121     9, 6, 5, 2, 2, 2, 2, 6, 1, 1,
01122     11, 1, 7, 3, 2, 2, 2, 2, 2, 1, 1, 1,
01123     12, 3, 4, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1,
01124     11, 6, 1, 2, 3, 2, 2, 2, 2, 1, 1, 1,
01125     6, 1, 7, 2, 16, 1, 1,
01126     11, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1,
01127     11, 1, 2, 1, 3, 1, 1, 6, 1, 1, 1, 1,
01128     9, 2, 7, 1, 1, 11, 1, 1, 1, 1,
01129     9, 2, 7, 1, 1, 11, 1, 1, 1, 1,
01130     11, 1, 2, 1, 3, 1, 1, 6, 1, 1, 1, 1,
01131     11, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1,
01132     6, 1, 7, 2, 16, 1, 1,
01133     11, 6, 1, 2, 3, 2, 2, 2, 2, 1, 1, 1,
01134     12, 3, 4, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1,
01135     11, 1, 7, 3, 2, 2, 2, 2, 2, 1, 1, 1,
01136     9, 6, 5, 2, 2, 2, 2, 6, 1, 1,
01137     10, 3, 2, 2, 2, 2, 2, 2, 4, 1, 1,
01138     9, 1, 2, 2, 2, 2, 2, 2, 13, 1,
01139     9, 1, 2, 2, 2, 2, 2, 2, 1, 2,
01140     7, 1, 2, 2, 2, 2, 2, 16,
01141     6, 3, 2, 2, 2, 2, 3,
01142     5, 3, 2, 2, 2, 2,
01143     4, 3, 2, 2, 1,
01144     3, 3, 2, 1,
01145     1, 5,
01146     // Row constraints
01147     1, 12,
01148     3, 5, 2, 5,
01149     4, 5, 2, 2, 5,
01150     7, 1, 2, 2, 2, 2, 2, 1,
01151     7, 4, 2, 2, 4, 2, 2, 4,
01152     7, 4, 2, 2, 4, 2, 2, 4,
01153     7, 1, 2, 2, 2, 2, 2, 1,
01154     7, 6, 2, 2, 2, 2, 2, 6,
01155     7, 6, 2, 2, 2, 2, 2, 6,
01156     3, 1, 14, 1,
01157     2, 10, 10,
01158     4, 8, 3, 3, 8,
01159     8, 1, 1, 2, 1, 1, 2, 1, 1,
01160     6, 9, 2, 2, 2, 2, 9,
01161     2, 9, 9,
01162     6, 1, 1, 1, 1, 1, 1,
01163     3, 12, 2, 12,
01164     2, 12, 12,
01165     5, 1, 1, 4, 1, 1,
01166     2, 14, 14,
01167     2, 12, 12,
01168     5, 2, 1, 4, 1, 2,
01169     3, 9, 4, 9,
01170     5, 1, 7, 4, 7, 1,
01171     7, 1, 1, 1, 4, 1, 1, 1,
01172     5, 1, 7, 4, 7, 1,
01173     5, 1, 7, 4, 7, 1,
01174     7, 1, 2, 1, 2, 1, 2, 1,
01175     5, 1, 7, 2, 7, 1,
01176     7, 1, 1, 6, 2, 6, 1, 1,
01177     9, 1, 1, 1, 1, 2, 1, 1, 1, 1,
01178     7, 1, 1, 6, 2, 6, 1, 1,
01179     6, 1, 1, 5, 5, 1, 1,
01180     7, 1, 1, 1, 8, 1, 1, 1,
01181     6, 1, 1, 4, 4, 1, 1,
01182     5, 1, 2, 6, 2, 1,
01183     4, 2, 4, 4, 2,
01184     3, 2, 6, 2,
01185     2, 4, 4,
01186     1, 6,
01187   };
01188 
01189 
01190   const int *specs[] = {heart, bear, crocodile, unknown,
01191                         pinwheel, difficult, non_unique, dragonfly,
01192                         castle, p200,
01193                         // From the webpbn survey
01194                         webpbn1,    // 10
01195                         webpbn6,    // 11
01196                         webpbn21,   // 12
01197                         webpbn27,   // 13
01198                         webpbn23,   // 14
01199                         webpbn16,   // 15
01200                         webpbn529,  // 16
01201                         webpbn65,   // 17
01202                         webpbn436,  // 18
01203   };
01204   const unsigned n_examples = sizeof(specs)/sizeof(int*);
01206 
01207 }
01208 
01209 // STATISTICS: example-any