Main Page | Class Hierarchy | Class List | File List | Class Members

CommonMain.h

00001 // CommonMain.h -- Stuff common to all mains.
00002 
00003 /*
00004  * Copyright (C) 1998, 2003-2005 Tudor Hulubei <tudor@hulubei.net>.
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as
00008  * published by the Free Software Foundation; either version 2, or (at
00009  * your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA,
00019  * 02111-1307, USA.
00020  */
00021 
00022 // $Id: CommonMain_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00023 
00024 #ifndef _CSP_EXAMPLES_CommonMain_H
00025 #define _CSP_EXAMPLES_CommonMain_H
00026 
00027 
00028 #ifndef __cplusplus
00029 #error Must use C++ for CommonMain.h.
00030 #endif
00031 
00032 
00033 #include <vector>
00034 #include <string>
00035 
00036 #include "Conversions.h"
00037 
00038 
00040 enum decomposition_t
00041 {
00042     D_Test,
00043     D_KWay,
00044     D_IDC,
00045     D_IDCMC,
00046     D_LC,
00047     D_LCMC,
00048     D_MC,
00049     D_NC
00050 };
00051 
00053 enum filter_t
00054 {
00055     F_Dummy,
00056     F_AC1,
00057     F_AC3,
00058     F_AC3d,
00059     F_AC3x,
00060     F_AC4,
00061     F_AC8,
00062     F_AC2000,
00063     F_AC2001,
00064     F_BC,
00065     F_BM,
00066     F_FP,
00067     F_RP
00068 };
00069 
00071 enum retraction_t
00072 {
00073     R_Chronological,
00074     R_CBJ
00075 };
00076 
00077 class CommonOptions
00078 {
00079   public:
00081     CommonOptions();
00082 
00084     CommonOptions(const CommonOptions& commonOptions);
00085 
00087     void addDecomposition(const char* name);
00088 
00090     void clearHeuristics(int index = 0);
00091 
00093     void addHeuristic(
00094         const std::wstring& name,
00095         const double quality,
00096         const std::vector<std::pair<double, double> > intervals,
00097         const bool analysis);
00098 
00100     void clearFFAIstHeuristics();
00101 
00103     void addFFAIstHeuristic(
00104         const std::wstring& name,
00105         const double quality,
00106         const std::vector<std::pair<double, double> > intervals);
00107 
00109     void clearFFAHeuristics();
00110 
00113     void addFFAHeuristic(
00114         const std::wstring& name,
00115         const double quality,
00116         const std::vector<std::pair<double, double> > intervals);
00117 
00119     int m_beep;
00120 
00122     int m_quiet;
00123 
00131     double m_staticOptimismPercentage;
00132 
00140     double m_dynamicOptimismPercentage;
00141 
00143     bool m_staticOptimismBucketing;
00144 
00146     bool m_dynamicOptimismBucketing;
00147 
00149     bool m_heuristicQualityBucketing;
00150 
00155     bool m_secondSearchOff;
00156 
00161     bool m_greedyVariableProcessing;
00162 
00167     bool m_deactivateLooseConstraints;
00168 
00170     bool m_averageUninstantiatedVariables;
00171 
00173     bool m_averageModifiedVariables;
00174 
00176     bool m_averageDomainSize;
00177 
00179     bool m_averageActiveConstraints;
00180 
00182     bool m_averageVariableDegree;
00183 
00185     bool m_averageConstrainedness;
00186 
00188     bool m_averageConstraintDensity;
00189 
00191     bool m_averageConstraintTightness;
00192 
00194     bool m_averageLooseConstraints;
00195 
00197     bool m_averageLeafDepth;
00198 
00200     bool m_nodes;
00201 
00203     bool m_leaves;
00204 
00210     bool m_extraPropagationStatistics;
00211 
00213     bool m_variableSelectionCounters;
00214 
00219     bool m_lastPathSelections;
00220 
00222     bool m_backdoor;
00223 
00228     bool m_backtracks;
00229 
00231     bool m_branchingAssignments;
00232 
00234     bool m_heuristicMistakes;
00235 
00237     bool m_failFirstnessAnalysis;
00238 
00240     bool m_consistencyOnly;
00241 
00243     bool m_noProcessing;
00244 
00246     bool m_useIndentation;
00247 
00249     bool m_fancy;
00250 
00252     bool m_verify;
00253 
00255     std::wstring m_problemGraphFileStem;
00256 
00261     int m_problemGraphGenerationDepth;
00262 
00264     std::wstring m_searchTreeFileStem;
00265 
00270     int m_searchTreeGenerationDepth;
00271 
00273     ulonglong m_solution;
00274 
00276     ulonglong m_solutionsRequested;
00277 
00279     timeval m_timeLimit;
00280 
00282     ulonglong m_nodeLimit;
00283 
00285     timeval m_ffaTimeLimit;
00286 
00288     int m_ffaDepthLimit;
00289 
00292     ulonglong m_ffaNodeLimit;
00293 
00295     int m_ffaLookAheadLevel;
00296 
00301     bool m_ffaIterativeDeepening;
00302 
00306     size_t m_ffaRapidRandomizedRestarts;
00307 
00309     ulonglong m_ffaRefutationsLimit;
00310 
00313     double m_ffaInitialReduction;
00314 
00317     double m_ffaReduction;
00318 
00320     int m_ffaProgressReportingDepthLimit;
00321 
00324     size_t m_ffaLowerBoundLookAheadLevel;
00325 
00326     // The number of variables a (sub)problem must contain for the
00327     // search for optimal refutations to attempt to obtain tighter
00328     // upper bounds dynamically by running a search in that subtree.
00329     size_t m_ffaDynamicUpperBoundThreshold;
00330 
00333     bool m_ffaOptimalRefutationCaching;
00334 
00336     double m_ffaOptimismPercentage;
00337 
00339     bool m_consistencyBeforeSearch;
00340 
00345     unsigned long m_kilobytes;
00346 
00348     bool m_outOfMemory;
00349 
00351     double m_idcChoiceFactor;
00352 
00354     double m_ac2000Ratio;
00355 
00360     char* m_beginningOfStack;
00361 
00363     char* m_beginningOfHeap;
00364 
00366     unsigned long m_maxHeapUsage;
00367 
00369     unsigned long m_maxStackUsage;
00370 
00372     bool m_systemPRNG;
00373 
00375     std::wstring m_problemSourceFileStem;
00376 
00378     std::wstring m_problemDestinationFileStem;
00379 
00381     std::wstring m_solutionsSourceFileStem;
00382 
00384     std::wstring m_solutionsDestinationFileStem;
00385 
00387     std::wofstream* m_solutionsDestinationStream;
00388 
00390     decomposition_t m_dAlgorithm;
00391 
00393     std::vector<decomposition_t> m_decompositions;
00394 
00396     filter_t m_fAlgorithm;
00397 
00399     retraction_t m_rAlgorithm;
00400 
00402     std::vector<std::vector<std::wstring> > m_heuristicNames;
00403 
00405     std::vector<std::vector<double> > m_heuristicQualities;
00406 
00408     std::vector<std::vector<
00409             std::vector<std::pair<double, double> > > > m_heuristicIntervals;
00410 
00415     std::vector<std::vector<bool> > m_heuristicAnalysis;
00416 
00418     std::vector<std::wstring> m_ffaIstHeuristicNames;
00419 
00421     std::vector<double> m_ffaIstHeuristicQualities;
00422 
00425     std::vector<std::vector<std::pair<double, double> > >
00426         m_ffaIstHeuristicIntervals;
00427 
00429     std::vector<std::wstring> m_ffaHeuristicNames;
00430 
00432     std::vector<double> m_ffaHeuristicQualities;
00433 
00436     std::vector<std::vector<std::pair<double, double> > >
00437         m_ffaHeuristicIntervals;
00438 
00440     bool m_predefinedHeuristics;
00441 
00444     std::vector<std::vector<csp::id_t> > m_predefinedVariables;
00445 
00448     std::vector<std::vector<csp::id_t> > m_predefinedValues;
00449 };
00450 
00451 
00453 extern std::wstring g_program;
00454 
00456 extern csp::Randomizer* g_randomizer;
00457 
00459 extern unsigned int g_seed;
00460 
00462 extern bool g_failFirstnessAnalysis;
00463 
00465 extern CommonOptions g_options;
00466 
00467 
00468 unsigned long arg2ul(const wchar_t* message);
00469 double arg2d(const wchar_t* message);
00470 void usage();
00471 void configureLogging();
00472 int sanityChecks(int argc, char* argv[]);
00473 bool isTeleType(int fd);
00474 int getProcessId();
00475 void printUnknownCharacterError(int c);
00476 void parseHeuristicSpecification(
00477     std::wstring& name,
00478     double& quality,
00479     std::vector<std::pair<double, double> >& intervals,
00480     bool& analysis);
00481 
00482 
00483 #define COMMON_CSP_DEFINES \
00484     CSP_HELP = 0x100,\
00485     CSP_FANCY,\
00486     CSP_VERIFY,\
00487     CSP_CONSISTENCY_ONLY,\
00488     CSP_NODE_LIMIT,\
00489     CSP_NO_PROCESSING,\
00490     CSP_IDC_CHOICE_FACTOR,\
00491     CSP_AC2000_RATIO,\
00492     CSP_SYSTEM_PRNG,\
00493     CSP_SAVE_PROBLEM,\
00494     CSP_LOAD_PROBLEM,\
00495     CSP_SAVE_SOLUTIONS,\
00496     CSP_LOAD_SOLUTIONS,\
00497     CSP_STATIC_OPTIMISM,\
00498     CSP_DYNAMIC_OPTIMISM,\
00499     CSP_STATIC_OPTIMISM_BUCKETING,\
00500     CSP_DYNAMIC_OPTIMISM_BUCKETING,\
00501     CSP_HEURISTIC_QUALITY_BUCKETING,\
00502     CSP_SECOND_SEARCH_OFF,\
00503     CSP_GREEDY_VARIABLE_PROCESSING,\
00504     CSP_DEACTIVATE_LOOSE_CONSTRAINTS,\
00505     CSP_PROBLEM_GRAPH,\
00506     CSP_PROBLEM_GRAPH_DEPTH,\
00507     CSP_SEARCH_TREE,\
00508     CSP_SEARCH_TREE_DEPTH,\
00509     CSP_STATISTICS,\
00510     CSP_AVERAGE_UNINSTANTIATED_VARIABLES,\
00511     CSP_AVERAGE_MODIFIED_VARIABLES,\
00512     CSP_AVERAGE_DOMAIN_SIZE,\
00513     CSP_AVERAGE_ACTIVE_CONSTRAINTS,\
00514     CSP_AVERAGE_VARIABLE_DEGREE,\
00515     CSP_AVERAGE_CONSTRAINEDNESS,\
00516     CSP_AVERAGE_CONSTRAINT_DENSITY,\
00517     CSP_AVERAGE_CONSTRAINT_TIGHTNESS,\
00518     CSP_AVERAGE_LOOSE_CONSTRAINTS,\
00519     CSP_AVERAGE_LEAF_DEPTH,\
00520     CSP_NODES,\
00521     CSP_LEAVES,\
00522     CSP_EXTRA_PROPAGATION_STATISTICS,\
00523     CSP_VARIABLE_SELECTION_COUNTERS,\
00524     CSP_LAST_PATH_SELECTIONS,\
00525     CSP_BACKDOOR,\
00526     CSP_BACKTRACKS,\
00527     CSP_BRANCHING_ASSIGNMENTS,\
00528     CSP_HEURISTIC_MISTAKES,\
00529     CSP_FFA,\
00530     CSP_FFA_IST_HEURISTIC,\
00531     CSP_FFA_HEURISTIC,\
00532     CSP_FFA_TIME_LIMIT,\
00533     CSP_FFA_DEPTH_LIMIT,\
00534     CSP_FFA_REFUTATIONS_LIMIT,\
00535     CSP_FFA_LOOK_AHEAD_LEVEL,\
00536     CSP_FFA_NO_ITERATIVE_DEEPENING,\
00537     CSP_FFA_RAPID_RANDOMIZED_RESTARTS,\
00538     CSP_FFA_INITIAL_REDUCTION,\
00539     CSP_FFA_REDUCTION,\
00540     CSP_FFA_PROGRESS_REPORTING_DEPTH_LIMIT,\
00541     CSP_FFA_LOWER_BOUND_LOOK_AHEAD_LEVEL,\
00542     CSP_FFA_DYNAMIC_UPPER_BOUND_THRESHOLD,\
00543     CSP_FFA_CACHING,\
00544     CSP_FFA_OPTIMISM
00545 
00546 #define COMMON_HELP \
00547 L" General options:\n\n"\
00548 L"  --help                  this help message; defaults between parenthesis.\n"\
00549 L"  -q, --quiet             don't print solutions, just count them.\n"\
00550 L"  --system-prng           use the system's pseudo-random number generator\n"\
00551 L"                          by default we use the algorithm presented in\n"\
00552 L"                          'Numerical Recipes in C' by William H. Press.\n"\
00553 L"  -s, --seed=[S]          initialize the random number generator to `S'.\n"\
00554 L"  -n N                    request `N' solutions.\n"\
00555 L"  -a, --all               request all the solutions.\n"\
00556 L"  -t, --time-limit=S      timeout in `S' seconds if no solution is found.\n"\
00557 L"  --node-limit=N          limit the number of nodes to `N'.  This\n"\
00558 L"                          requires `--nodes' and so it activates it.\n"\
00559 L"                          Note that nodes are counted upon backtracking.\n"\
00560 L"  -m, --memory=M          limit the heap+stack memory used to `M' Kb.\n"\
00561 L"  -d, --decomposition=D   the decomposition algorithm\n"\
00562 L"                          [k-way|idc|idc-mc|lc|lc-mc|mc|nc].\n"\
00563 L"  -f, --filter=F          the filter [rp|bc|bm|fp|ac1|ac3|ac3d|ac3x|\n"\
00564 L"                          ac4|ac8|ac2000|ac2001] (ac3).\n"\
00565 L"  -r, --retraction=R      the retraction method [chronological|cbj]\n"\
00566 L"                          (chronological).\n"\
00567 L"  -h, --heuristic=H       append `H' to the list of variable or value\n"\
00568 L"                          ordering heuristics.  Multiple -h options are\n"\
00569 L"                          accepted, and the heuristics are applied in the\n"\
00570 L"                          order in which their corresponding switches are\n"\
00571 L"                          given.  Currently only variable and value\n"\
00572 L"                          ordering heuristics are implemented.\n"\
00573 L"                          Variable ordering heuristics:\n"\
00574 L"                            min-domain-variable,\n"\
00575 L"                            max-domain-variable,\n"\
00576 L"                            max-degree-variable,\n"\
00577 L"                            min-degree-variable,\n"\
00578 L"                            static-max-impact-variable,\n"\
00579 L"                            static-min-impact-variable,\n"\
00580 L"                            dynamic-max-impact-variable,\n"\
00581 L"                            dynamic-min-impact-variable,\n"\
00582 L"                            min-branching-variable,\n"\
00583 L"                            max-branching-variable,\n"\
00584 L"                            min-domain/degree-variable,\n"\
00585 L"                            max-domain/degree-variable,\n"\
00586 L"                            min-domain/weighted-degree-variable,\n"\
00587 L"                            max-domain/weighted-degree-variable,\n"\
00588 L"                            max-domain-wipeouts-variable,\n"\
00589 L"                            min-domain-wipeouts-variable,\n"\
00590 L"                            max-weighted-degree-variable,\n"\
00591 L"                            min-weighted-degree-variable,\n"\
00592 L"                            static-max-solution-probability-variable,\n"\
00593 L"                            static-min-solution-probability-variable,\n"\
00594 L"                            dynamic-max-solution-probability-variable,\n"\
00595 L"                            dynamic-min-solution-probability-variable,\n"\
00596 L"                            random-variable,\n"\
00597 L"                            lexical-variable\n"\
00598 L"                            min-value-variable (Queens),\n"\
00599 L"                            column-zero-variable (QuasiGroup),\n"\
00600 L"                          Value ordering heuristics:\n"\
00601 L"                            static-min-conflicts-value,\n"\
00602 L"                            static-max-conflicts-value,\n"\
00603 L"                            dynamic-min-conflicts-value,\n"\
00604 L"                            dynamic-max-conflicts-value,\n"\
00605 L"                            max-solution-probability-value,\n"\
00606 L"                            min-solution-probability-value,\n"\
00607 L"                            max-branching-value,\n"\
00608 L"                            min-branching-value,\n"\
00609 L"                            min-failulres-value,\n"\
00610 L"                            max-failures-value,\n"\
00611 L"                            max-min-domain-value,\n"\
00612 L"                            min-min-domain-value,\n"\
00613 L"                            random-value,\n"\
00614 L"                            lexical-value,\n"\
00615 L"                            acceptable-weight (Random)\n"\
00616 L"                          The heuristic's quality, depth ranges and the\n"\
00617 L"                          analysis flag can be specified after the name,\n"\
00618 L"                          colon-separated, like in the following example:\n"\
00619 L"                            -h min-domain-variable:0.89:20-40:off.\n"\
00620 L"  --idc-choice-factor=CF  set the IDC[[-MC]-PDS] choice factor (1.08).\n"\
00621 L"  --ac2000-ratio=R        set the AC2000 filter's ratio to `R' (0.2).\n"\
00622 L"  -b, --beep=S            beep if the search took longer than `S'\n"\
00623 L"                          seconds.\n"\
00624 L"  -p, --predictable       cause the library to behave in a predictable\n"\
00625 L"                          way, i.e. keep the order of variables and\n"\
00626 L"                          constraints stable during backtracking (false).\n"\
00627 L"  --static-optimism=%     turn on static optimistic in search; the\n"\
00628 L"                          argument is the percentage of values that are\n"\
00629 L"                          to be removed from the domain of each variable;\n"\
00630 L"                          values are sorted before search with the first\n"\
00631 L"                          value ordering heuristic.\n"\
00632 L"  --dynamic-optimism=%    turn on dynamic optimistic in search; the\n"\
00633 L"                          argument is the percentage of values that are\n"\
00634 L"                          to be removed from the domain of each variable;\n"\
00635 L"                          values are sorted during search with the first\n"\
00636 L"                          value ordering heuristic.\n"\
00637 L"  --static-optimism-bucketing\n"\
00638 L"                          turn on bucketing in static optimism, i.e.\n"\
00639 L"                          group together values that are considered\n"\
00640 L"                          equally good byb the heuristic.\n"\
00641 L"  --dynamic-optimism-bucketing\n"\
00642 L"                          turn on bucketing in dynamic optimism, i.e.\n"\
00643 L"                          group together values that are considered\n"\
00644 L"                          equally good by the heuristic.\n"\
00645 L"  --heuristic-quality-bucketing\n"\
00646 L"                          turn on bucketing in heuristic quality, i.e.\n"\
00647 L"                          group together values that are considered\n"\
00648 L"                          equally good by the heuristic.\n"\
00649 L"  --second-search-off     no second search when optimistic search fails\n"\
00650 L"  --greedy                turn on greedy processing of variables whose\n"\
00651 L"                          domains have been reduced to a single value.\n"\
00652 L"                          Such variables are immediately removed from the\n"\
00653 L"                          list of active variables, greatly reducing the\n"\
00654 L"                          depth of the search tree.\n"\
00655 L"  --deactivate-loose-constraints\n"\
00656 L"                          deactivate constraints that become loose, i.e.\n"\
00657 L"                          tightness=0.  This can increase the accuracy of\n"\
00658 L"                          some degree-based heuristics and reveal the\n"\
00659 L"                          underlying problem structure.\n"\
00660 L"  -V, --log-verbosity-level=L\n"\
00661 L"                          set the log level [info|error|warning|notice|\n"\
00662 L"                          debug0|debug1|debug2|debug] (notice).\n"\
00663 L"  -l, --log=[P]           enable logging for categories matching patterns\n"\
00664 L"                          in P; P is a comma separated list of patterns;\n"\
00665 L"                          if P is empty, logging is on for all categories\n"\
00666 L"                          (csp::Log,main,$Problem).\n"\
00667 L"  -i, --indentation       turn on logging indentation.\n"\
00668 L"  --fancy                 display solutions in a fancy way, if possible.\n"\
00669 L"  --verify                verify the solution.\n"\
00670 L"  --consistency-only      verify consistency using filter, don't search.\n"\
00671 L"  --no-processing         don't enforce consistency, don't search\n"\
00672 L"                          useful in conjunction with --save-problem.\n"\
00673 L"  --problem-graph=STEM    generate a graph of the current (sub)problem in\n"\
00674 L"                          AT&T's Graphviz DOT format.  Put it in a file\n"\
00675 L"                          named `STEMgraph-[downwards|upwards].dot'.  The\n"\
00676 L"                          graph can be later converted to a PNG file\n"\
00677 L"                          with Graphviz's tools.  `twopi' is recommended\n"\
00678 L"                          for large problems.  Typical use:\n"\
00679 L"                              twopi STEMgraph.dot -Tpng -oSTEMgraph.png\n"\
00680 L"  --problem-graph-depth=D automatically trigger the generation of the\n"\
00681 L"                          graph at depth `D'.  Unless D==0,\n"\
00682 L"                          the graph will be that of a subproblem.\n"\
00683 L"  --search-tree=STEM      generate a search (sub)tree in AT&T's\n"\
00684 L"                          Graphviz DOT format.  Put it in a file named\n"\
00685 L"                          `STEMtree.dot'.  The graph can be later converted\n"\
00686 L"                          to a PNG file with Graphviz's tools. `twopi'\n"\
00687 L"                          is recommended for large trees.  Typical use:\n"\
00688 L"                              twopi STEMtree.dot -Tpng -oSTEMtree.png\n"\
00689 L"                          Note that the search tree will be nicely\n"\
00690 L"                          labeled only if --last-path-selections is\n"\
00691 L"                          given.\n"\
00692 L"  --search-tree-depth=D   automatically trigger the generation of the\n"\
00693 L"                          search (sub)tree at depth `D'.  Unless D==0,\n"\
00694 L"                          the result will be a subtree.\n"\
00695 L"\n"\
00696 L"  --load-problem=STEM     load the problem from `STEMproblem.txt'.\n"\
00697 L"  --save-problem=STEM     save the problem into `STEMproblem.txt'.\n"\
00698 L"  --load-solutions=STEM   load the problem's solutions from\n"\
00699 L"                          `STEMsolutions.txt'.\n"\
00700 L"  --save-solutions=STEM   save the problem's solutions into\n"\
00701 L"                          `STEMsolutions.txt'.\n"\
00702 L"\n"\
00703 L" Statistics:\n"\
00704 L"\n"\
00705 L"  --statistics\n"\
00706 L"                          compute and report statistics that may be very\n"\
00707 L"                          time consuming.  They includes the following:\n"\
00708 L"  --average-uninstantiated-variables\n"\
00709 L"                          compute and report the average number of\n"\
00710 L"                          uninstantiated variables at each depth.\n"\
00711 L"  --average-modified-variables\n"\
00712 L"                          compute and report the average number of\n"\
00713 L"                          variables modified at each depth.\n"\
00714 L"  --average-domain-size\n"\
00715 L"                          compute and report the average domain size,\n"\
00716 L"                          average minimum domain size and average\n"\
00717 L"                          maximum domain size at each depth.\n"\
00718 L"  --average-active-constraints\n"\
00719 L"                          compute and report the average number of active\n"\
00720 L"                          constraints at each depth.\n"\
00721 L"  --average-variable-degree\n"\
00722 L"                          compute and report the average variable degree\n"\
00723 L"                          at each depth, i.e. the average number of other\n"\
00724 L"                          variables it is still connected to.\n"\
00725 L"  --average-constrainedness\n"\
00726 L"                          compute and report the average constrainedness\n"\
00727 L"                          at each depth.  Constrainedness is computed as\n"\
00728 L"                                      Sum    log2(1 - tc)\n"\
00729 L"                                      c in C\n"\
00730 L"                                k = - -------------------\n"\
00731 L"                                         Sum    log2(dv)\n"\
00732 L"                                         v in V\n"\
00733 L"                          where tc is the c's tightness and dv is v's\n"\
00734 L"                          domain size.  Note that this is very expensive!\n"\
00735 L"  --average-constraint-density\n"\
00736 L"                          compute and report the average constraint\n"\
00737 L"                          density at each depth.\n"\
00738 L"  --average-constraint-tightness\n"\
00739 L"                          compute and report the average constraint\n"\
00740 L"                          tightness at each depth.  Note that this is\n"\
00741 L"                          very expensive!\n"\
00742 L"  --average-loose-constraints\n"\
00743 L"                          compute and report the average number of loose\n"\
00744 L"                          constraints at each depth.\n"\
00745 L"  --average-leaf-depth\n"\
00746 L"                          compute and report the average leaf depth."\
00747 L"  --nodes\n"\
00748 L"                          compute and report the number of nodes touched\n"\
00749 L"                          by search, including the number of nodes per\n"\
00750 L"                          depth for each mistake point (per solution).\n"\
00751 L"  --leaves\n"\
00752 L"                          compute and report the number of leaves touched\n"\
00753 L"                          touched by search, including the number of\n"\
00754 L"                          nodes per depth for each mistake point (per\n"\
00755 L"                          solution).\n"\
00756 L"  --extra-propagation-statistics\n"\
00757 L"                          compute and report statistics about additional\n"\
00758 L"                          propations performed by certain decompositions.\n"\
00759 L"  --variable-selection-counters\n"\
00760 L"                          compute and report the variable selection\n"\
00761 L"                          counters for each depth.\n"\
00762 L"  --last-path-selections\n"\
00763 L"                          compute and report the variable and value\n"\
00764 L"                          selections made on the last path traversed,\n"\
00765 L"                          usually the one that led to the solution.\n"\
00766 L"  --backdoor\n"\
00767 L"                          compute and report the backdoor variables for\n"\
00768 L"                          each solution.\n"\
00769 L"  --backtracks\n"\
00770 L"                          report the total and per depth number of\n"\
00771 L"                          backtracks for each solution.\n"\
00772 L"  --branching-assignments\n"\
00773 L"                          compute and report the branching assignments for\n"\
00774 L"                          each solution.\n"\
00775 L"  --heuristic-mistakes\n"\
00776 L"                          report value ordering heuristic mistakes after\n"\
00777 L"                          after each solution.  Mistakes are always\n"\
00778 L"                          calculated by the library.\n"\
00779 L"\n"\
00780 L" Fail-firstness analysis (optimal refutations):\n"\
00781 L"\n"\
00782 L"  --ffa, --fail-firstness-analysis\n"\
00783 L"                          analyze the variable ordering heuristic's\n"\
00784 L"                          fail-firstness.  Try to find a better way to\n"\
00785 L"                          prove that each insoluble subtree is insoluble.\n"\
00786 L"  --ffa-rrr=N, --ffa-rapid-randomized-restarts=N\n"\
00787 L"                          Before starting the search for the optimal\n"\
00788 L"                          refutation for a mistake point, keep attempting\n"\
00789 L"                          to obtain tighter upper bound by re-running the\n"\
00790 L"                          search several times, until executing N successive\n"\
00791 L"                          runs with no improvement in the number of nodes.\n"\
00792 L"  --ffa-heuristic\n"\
00793 L"                          heuristic to be used by the search for optimal\n"\
00794 L"                          refutations.  If none given, the heuristics\n"\
00795 L"                          passed with the --heuristic flag will be used.\n"\
00796 L"  --ffa-ist-heuristic\n"\
00797 L"                          heuristic to be used to solve insoluble\n"\
00798 L"                          subtrees for the fail-firstness analysis.\n"\
00799 L"                          If none given, the heuristics passed with\n"\
00800 L"                          the --heuristic flag will be used.  The optimal\n"\
00801 L"                          refutation size obtained by the fail-firstness\n"\
00802 L"                          analysis will be compared against the refutation\n"\
00803 L"                          size obtained when using the heuristic(s)\n"\
00804 L"                          given here.  Useful for comparing a heuristic\n"\
00805 L"                          with its anti-heuristic.\n"\
00806 L"  --ffa-time-limit=TL\n"\
00807 L"                          time limit, in seconds, for the fail-firstness\n"\
00808 L"                          analysis of a mistake point.\n"\
00809 L"  --ffa-depth-limit[=DL]\n"\
00810 L"                          depth limit for the fail-firstness analysis of\n"\
00811 L"                          a mistake point; if no number is given, the\n"\
00812 L"                          limit is the depth of the original refutation.\n"\
00813 L"  --ffa-refutations-limit=RL\n"\
00814 L"                          limit for the number of better refutations to\n"\
00815 L"                          search for (default: unlimited).\n"\
00816 L"  --ffa-look-ahead-level=L\n"\
00817 L"                          the level of look-ahead, in [0..n] (2) for\n"\
00818 L"                          the fail-firstness analysis.\n"\
00819 L"  --ffa-no-iterative-deepening\n"\
00820 L"                          no iterative deepening in the fail-firstness\n"\
00821 L"                          analysis; iterate only with a depth limit as\n"\
00822 L"                          given by --ffa-depth-limit.\n"\
00823 L"  --ffa-initial-reduction=IR\n"\
00824 L"                          the percentage to be substracted from the size\n"\
00825 L"                          of the initial refutation when setting the\n"\
00826 L"                          initial upper bound.\n"\
00827 L"  --ffa-reduction=R\n"\
00828 L"                          the percentage to be substracted from the size\n"\
00829 L"                          of the latest refutation when setting the new\n"\
00830 L"                          upper bound.\n"\
00831 L"  --ffa-progress-reporting-depth-limit=D\n"\
00832 L"                          the depth past which completion progress is\n"\
00833 L"                          not reported (1).\n"\
00834 L"  --ffa-lower-bound-look-ahead-level=D\n"\
00835 L"                          the look-ahead level used during the search\n"\
00836 L"                          for a refutation size lower bound (3).\n"\
00837 L"  --ffa-dynamic-upper-bound-threshold=N\n"\
00838 L"                          the number of variables a (sub)problem must\n"\
00839 L"                          contain for the search for optimal refutations\n"\
00840 L"                          to attempt to obtain tighter upper bounds\n"\
00841 L"                          dynamically by re-searching that subtree.\n"\
00842 L"  --ffa-caching\n"\
00843 L"                          if given, caching of optimal refutations is\n"\
00844 L"                          turned on in the fail-firstness analysis.\n"\
00845 L"  --ffa-optimism=%        turn on optimistic during the search for\n"\
00846 L"                          refutations; the argument is the percentage\n"\
00847 L"                          of work that will NOT be done at each depth.\n"\
00848 L"\n"\
00849 L" Problem specific options:\n"\
00850 L"\n"
00851 
00852 #define COMMON_LONG_OPTIONS \
00853     { "help", 0, 0, CSP_HELP },\
00854     { "quiet", 0, 0, 'q' },\
00855     { "statistics", 0, 0, CSP_STATISTICS },\
00856     { "average-uninstantiated-variables", 0, 0,\
00857        CSP_AVERAGE_UNINSTANTIATED_VARIABLES },\
00858     { "average-modified-variables", 0, 0, CSP_AVERAGE_MODIFIED_VARIABLES },\
00859     { "average-domain-size", 0, 0, CSP_AVERAGE_DOMAIN_SIZE },\
00860     { "average-active-constraints", 0, 0, CSP_AVERAGE_ACTIVE_CONSTRAINTS },\
00861     { "average-variable-degree", 0, 0, CSP_AVERAGE_VARIABLE_DEGREE },\
00862     { "average-constrainedness", 0, 0, CSP_AVERAGE_CONSTRAINEDNESS },\
00863     { "average-constraint-density", 0, 0, CSP_AVERAGE_CONSTRAINT_DENSITY },\
00864     { "average-constraint-tightness", 0, 0, CSP_AVERAGE_CONSTRAINT_TIGHTNESS },\
00865     { "average-loose-constraints", 0, 0, CSP_AVERAGE_LOOSE_CONSTRAINTS },\
00866     { "average-leaf-depth", 0, 0, CSP_AVERAGE_LEAF_DEPTH },\
00867     { "nodes", 0, 0, CSP_NODES },\
00868     { "leaves", 0, 0, CSP_LEAVES },\
00869     { "extra-propagation-statistics", 0, 0,\
00870        CSP_EXTRA_PROPAGATION_STATISTICS },\
00871     { "variable-selection-counters", 0, 0, CSP_VARIABLE_SELECTION_COUNTERS },\
00872     { "last-path-selections", 0, 0, CSP_LAST_PATH_SELECTIONS },\
00873     { "backdoor", 0, 0, CSP_BACKDOOR },\
00874     { "backtracks", 0, 0, CSP_BACKTRACKS },\
00875     { "branching-assignments", 0, 0, CSP_BRANCHING_ASSIGNMENTS },\
00876     { "heuristic-mistakes", 0, 0, CSP_HEURISTIC_MISTAKES },\
00877     { "ffa", 0, 0, CSP_FFA },\
00878     { "fail-firstness-analysis", 0, 0, CSP_FFA },\
00879     { "ffa-time-limit", 1, 0, CSP_FFA_TIME_LIMIT },\
00880     { "ffa-depth-limit", 2, 0, CSP_FFA_DEPTH_LIMIT },\
00881     { "ffa-refutations-limit", 1, 0, CSP_FFA_REFUTATIONS_LIMIT },\
00882     { "ffa-look-ahead-level", 1, 0, CSP_FFA_LOOK_AHEAD_LEVEL },\
00883     { "ffa-no-iterative-deepening", 0, 0, CSP_FFA_NO_ITERATIVE_DEEPENING },\
00884     { "ffa-rrr", 1, 0, CSP_FFA_RAPID_RANDOMIZED_RESTARTS },\
00885     { "ffa-rapid-randomized-restarts", 1, 0,\
00886        CSP_FFA_RAPID_RANDOMIZED_RESTARTS },\
00887     { "ffa-initial-reduction", 1, 0, CSP_FFA_INITIAL_REDUCTION },\
00888     { "ffa-reduction", 1, 0, CSP_FFA_REDUCTION },\
00889     { "ffa-progress-reporting-depth-limit", 1, 0,\
00890        CSP_FFA_PROGRESS_REPORTING_DEPTH_LIMIT },\
00891     { "ffa-lower-bound-look-ahead-level", 1, 0,\
00892        CSP_FFA_LOWER_BOUND_LOOK_AHEAD_LEVEL },\
00893     { "ffa-dynamic-upper-bound-threshold", 1, 0,\
00894        CSP_FFA_DYNAMIC_UPPER_BOUND_THRESHOLD },\
00895     { "ffa-caching", 0, 0, CSP_FFA_CACHING },\
00896     { "ffa-optimism", 1, 0, CSP_FFA_OPTIMISM },\
00897     { "system-prng", 0, 0, CSP_SYSTEM_PRNG },\
00898     { "seed", 2, 0, 's' },\
00899     { "all", 0, 0, 'a' },\
00900     { "time-limit", 1, 0, 't' },\
00901     { "node-limit", 1, 0, CSP_NODE_LIMIT },\
00902     { "memory", 1, 0, 'm' },\
00903     { "decomposition", 1, 0, 'd' },\
00904     { "filter", 1, 0, 'f' },\
00905     { "retraction", 1, 0, 'r' },\
00906     { "heuristic", 1, 0, 'h' },\
00907     { "ffa-ist-heuristic", 1, 0, CSP_FFA_IST_HEURISTIC },\
00908     { "ffa-heuristic", 1, 0, CSP_FFA_HEURISTIC },\
00909     { "idc-choice-factor", 1, 0, CSP_IDC_CHOICE_FACTOR },\
00910     { "ac2000-ratio", 1, 0, CSP_AC2000_RATIO },\
00911     { "beep", 1, 0, 'b' },\
00912     { "predictable", 0, 0, 'p' },\
00913     { "static-optimism", 1, 0, CSP_STATIC_OPTIMISM },\
00914     { "dynamic-optimism", 1, 0, CSP_DYNAMIC_OPTIMISM },\
00915     { "dynamic-optimism-bucketing", 0, 0, CSP_DYNAMIC_OPTIMISM_BUCKETING },\
00916     { "static-optimism-bucketing", 0, 0, CSP_STATIC_OPTIMISM_BUCKETING },\
00917     { "heuristic-quality-bucketing", 0, 0, CSP_HEURISTIC_QUALITY_BUCKETING },\
00918     { "second-search-off", 0, 0, CSP_SECOND_SEARCH_OFF },\
00919     { "greedy", 0, 0, CSP_GREEDY_VARIABLE_PROCESSING },\
00920     { "deactivate-loose-constraints", 0, 0,\
00921        CSP_DEACTIVATE_LOOSE_CONSTRAINTS },\
00922     { "log-verbosity-level", 1, 0, 'V' },\
00923     { "log", 2, 0, 'l' },\
00924     { "indentation", 0, 0, 'i' },\
00925     { "fancy", 0, 0, CSP_FANCY },\
00926     { "verify", 0, 0, CSP_VERIFY },\
00927     { "consistency-only", 0, 0, CSP_CONSISTENCY_ONLY },\
00928     { "no-processing", 0, 0, CSP_NO_PROCESSING },\
00929     { "save-problem", 1, 0, CSP_SAVE_PROBLEM },\
00930     { "load-problem", 1, 0, CSP_LOAD_PROBLEM },\
00931     { "save-solutions", 1, 0, CSP_SAVE_SOLUTIONS },\
00932     { "load-solutions", 1, 0, CSP_LOAD_SOLUTIONS },\
00933     { "problem-graph", 1, 0, CSP_PROBLEM_GRAPH },\
00934     { "problem-graph-depth", 1, 0, CSP_PROBLEM_GRAPH_DEPTH },\
00935     { "search-tree", 1, 0, CSP_SEARCH_TREE },\
00936     { "search-tree-depth", 1, 0, CSP_SEARCH_TREE_DEPTH },\
00937 
00938 
00939 #define COMMON_GETOPT_STRING "qen:s::at:m:d:f:r:h:b:pV:l::i"
00940 
00941 #define COMMON_OPTIONS_CODE \
00942     case CSP_HELP:\
00943         usage();\
00944         return 0;\
00945     case 'q':\
00946         g_options.m_quiet = true;\
00947         break;\
00948     case CSP_STATISTICS:\
00949         g_options.m_averageUninstantiatedVariables = true;\
00950         g_options.m_averageModifiedVariables = true;\
00951         g_options.m_averageDomainSize = true;\
00952         g_options.m_averageActiveConstraints = true;\
00953         g_options.m_averageVariableDegree = true;\
00954         g_options.m_averageConstrainedness = true;\
00955         g_options.m_averageConstraintDensity = true;\
00956         g_options.m_averageConstraintTightness = true;\
00957         g_options.m_averageLooseConstraints = true;\
00958         g_options.m_averageLeafDepth = true;\
00959         g_options.m_nodes = true;\
00960         g_options.m_leaves = true;\
00961         g_options.m_extraPropagationStatistics = true;\
00962         g_options.m_variableSelectionCounters = true;\
00963         g_options.m_lastPathSelections = true;\
00964         g_options.m_backdoor = true;\
00965         g_options.m_backtracks = true;\
00966         g_options.m_branchingAssignments = true;\
00967         g_options.m_heuristicMistakes = true;\
00968         break;\
00969     case CSP_AVERAGE_UNINSTANTIATED_VARIABLES:\
00970         g_options.m_averageUninstantiatedVariables = true;\
00971         break;\
00972     case CSP_AVERAGE_MODIFIED_VARIABLES:\
00973         g_options.m_averageModifiedVariables = true;\
00974         break;\
00975     case CSP_AVERAGE_DOMAIN_SIZE:\
00976         g_options.m_averageDomainSize = true;\
00977         break;\
00978     case CSP_AVERAGE_ACTIVE_CONSTRAINTS:\
00979         g_options.m_averageActiveConstraints = true;\
00980         break;\
00981     case CSP_AVERAGE_VARIABLE_DEGREE:\
00982         g_options.m_averageVariableDegree = true;\
00983         break;\
00984     case CSP_AVERAGE_CONSTRAINEDNESS:\
00985         g_options.m_averageConstrainedness = true;\
00986         break;\
00987     case CSP_AVERAGE_CONSTRAINT_DENSITY:\
00988         g_options.m_averageConstraintDensity = true;\
00989         break;\
00990     case CSP_AVERAGE_CONSTRAINT_TIGHTNESS:\
00991         g_options.m_averageConstraintTightness = true;\
00992         break;\
00993     case CSP_AVERAGE_LOOSE_CONSTRAINTS:\
00994         g_options.m_averageLooseConstraints = true;\
00995         break;\
00996     case CSP_AVERAGE_LEAF_DEPTH:\
00997         g_options.m_averageLeafDepth = true;\
00998         break;\
00999     case CSP_NODES:\
01000         g_options.m_nodes = true;\
01001         break;\
01002     case CSP_LEAVES:\
01003         g_options.m_leaves = true;\
01004         break;\
01005     case CSP_EXTRA_PROPAGATION_STATISTICS:\
01006         g_options.m_extraPropagationStatistics = true;\
01007         break;\
01008     case CSP_VARIABLE_SELECTION_COUNTERS:\
01009         g_options.m_variableSelectionCounters = true;\
01010         break;\
01011     case CSP_LAST_PATH_SELECTIONS:\
01012         g_options.m_lastPathSelections = true;\
01013         break;\
01014     case CSP_BACKDOOR:\
01015         g_options.m_backdoor = true;\
01016         break;\
01017     case CSP_BACKTRACKS:\
01018         g_options.m_backtracks = true;\
01019         break;\
01020     case CSP_BRANCHING_ASSIGNMENTS:\
01021         g_options.m_branchingAssignments = true;\
01022         break;\
01023     case CSP_HEURISTIC_MISTAKES:\
01024         g_options.m_heuristicMistakes = true;\
01025         break;\
01026     case CSP_FFA:\
01027         g_failFirstnessAnalysis = true;\
01028         g_options.m_lastPathSelections = true;\
01029         g_options.m_nodes = true;\
01030         break;\
01031     case CSP_FFA_TIME_LIMIT:\
01032         g_options.m_ffaTimeLimit.tv_sec =\
01033             arg2ul(L"Invalid number of seconds for the FFA time limit");\
01034         g_options.m_ffaTimeLimit.tv_usec = 0;\
01035         break;\
01036     case CSP_FFA_DEPTH_LIMIT:\
01037         if (optarg == 0)\
01038             g_options.m_ffaDepthLimit = -1;\
01039         else\
01040             g_options.m_ffaDepthLimit = arg2ul(L"Invalid FFA depth limit");\
01041         break;\
01042     case CSP_FFA_REFUTATIONS_LIMIT:\
01043         g_options.m_ffaRefutationsLimit =\
01044             arg2ul(L"Invalid number of refutations for "\
01045                    L"the FFA refutations limit");\
01046         break;\
01047     case CSP_FFA_LOOK_AHEAD_LEVEL:\
01048         {\
01049             wstring error =\
01050                 L"Invalid FFA look-ahead level; should be greater than 0";\
01051             g_options.m_ffaLookAheadLevel = arg2ul(error.c_str());\
01052             if (g_options.m_ffaLookAheadLevel < 0)\
01053             {\
01054                 ILOG(Error, error);\
01055                 exit(13);\
01056             }\
01057         }\
01058         break;\
01059     case CSP_FFA_RAPID_RANDOMIZED_RESTARTS:\
01060         g_options.m_ffaRapidRandomizedRestarts =\
01061             arg2ul(L"Invalid number of rapid randomized restarts");\
01062         break;\
01063     case CSP_FFA_NO_ITERATIVE_DEEPENING:\
01064         g_options.m_ffaIterativeDeepening = false;\
01065         break;\
01066     case CSP_FFA_INITIAL_REDUCTION:\
01067         {\
01068             wstring error =\
01069                 L"Invalid FFA initial reduction; should be in [0-100)";\
01070             g_options.m_ffaInitialReduction = arg2d(error.c_str());\
01071             if (g_options.m_ffaInitialReduction < 0 ||\
01072                 g_options.m_ffaInitialReduction >= 100)\
01073             {\
01074                 ILOG(Error, error);\
01075                 exit(13);\
01076             }\
01077         }\
01078         break;\
01079     case CSP_FFA_REDUCTION:\
01080         {\
01081             wstring error = L"Invalid FFA reduction; should be in [0-100)";\
01082             g_options.m_ffaReduction = arg2d(error.c_str());\
01083             if (g_options.m_ffaReduction < 0 ||\
01084                 g_options.m_ffaReduction >= 100)\
01085             {\
01086                 ILOG(Error, error);\
01087                 exit(13);\
01088             }\
01089         }\
01090         break;\
01091     case CSP_FFA_PROGRESS_REPORTING_DEPTH_LIMIT:\
01092         g_options.m_ffaProgressReportingDepthLimit =\
01093             arg2ul(L"Invalid FFA progress reporting depth limit");\
01094         break;\
01095     case CSP_FFA_LOWER_BOUND_LOOK_AHEAD_LEVEL:\
01096         g_options.m_ffaLowerBoundLookAheadLevel =\
01097             arg2ul(L"Invalid FFA lower bound look-ahead level");\
01098         break;\
01099     case CSP_FFA_DYNAMIC_UPPER_BOUND_THRESHOLD:\
01100         {\
01101             wstring error =\
01102                 L"Invalid # of variables for the "\
01103                 L"FFA dynamic upper bound threshold";\
01104             g_options.m_ffaDynamicUpperBoundThreshold =\
01105                 arg2ul(error.c_str());\
01106         }\
01107         break;\
01108     case CSP_FFA_CACHING:\
01109         g_options.m_ffaOptimalRefutationCaching = true;\
01110         break;\
01111     case CSP_FFA_OPTIMISM:\
01112         {\
01113             wstring error =\
01114                 L"Invalid FFA optimism percentage; should be in [0-100)";\
01115             g_options.m_ffaOptimismPercentage = arg2d(error.c_str());\
01116             if (g_options.m_ffaOptimismPercentage < 0 ||\
01117                 g_options.m_ffaOptimismPercentage >= 100)\
01118             {\
01119                 ILOG(Error, error);\
01120                 exit(13);\
01121             }\
01122         }\
01123         break;\
01124     case 'n':\
01125         g_options.m_solutionsRequested =\
01126             arg2ul(L"Invalid number of solutions");\
01127         break;\
01128     case CSP_SYSTEM_PRNG:\
01129         g_options.m_systemPRNG = true;\
01130         break;\
01131     case 's':\
01132         if (optarg == 0)\
01133         {\
01134             g_seed = time(0) * getProcessId();\
01135         }\
01136         else\
01137             g_seed = arg2ul(L"Invalid seed");\
01138         break;\
01139     case 'a':\
01140         g_options.m_solutionsRequested = ULONG_MAX;\
01141         break;\
01142     case 't':\
01143         g_options.m_timeLimit.tv_sec =\
01144             arg2ul(L"Invalid number of seconds for the time limit");\
01145         g_options.m_timeLimit.tv_usec = 0;\
01146         break;\
01147     case CSP_NODE_LIMIT:\
01148         g_options.m_nodeLimit =\
01149             arg2ul(L"Invalid number of nodes for the node limit");\
01150         g_options.m_nodes = true;\
01151         break;\
01152     case 'm':\
01153         g_options.m_kilobytes = arg2ul(L"Invalid memory limit");\
01154         break;\
01155     case 'd':\
01156         g_options.addDecomposition(optarg);\
01157         break;\
01158     case 'f':\
01159              if (strcmp(optarg, "dummy") == 0) g_options.m_fAlgorithm = F_Dummy;\
01160         else if (strcmp(optarg, "ac1") == 0) g_options.m_fAlgorithm = F_AC1;\
01161         else if (strcmp(optarg, "ac3") == 0) g_options.m_fAlgorithm = F_AC3;\
01162         else if (strcmp(optarg, "ac3d") == 0) g_options.m_fAlgorithm = F_AC3d;\
01163         else if (strcmp(optarg, "ac3x") == 0) g_options.m_fAlgorithm = F_AC3x;\
01164         else if (strcmp(optarg, "ac4") == 0) g_options.m_fAlgorithm = F_AC4;\
01165         else if (strcmp(optarg, "ac8") == 0) g_options.m_fAlgorithm = F_AC8;\
01166         else if (strcmp(optarg, "ac2000") == 0) g_options.m_fAlgorithm = F_AC2000;\
01167         else if (strcmp(optarg, "ac2001") == 0) g_options.m_fAlgorithm = F_AC2001;\
01168         else if (strcmp(optarg, "bc") == 0) g_options.m_fAlgorithm = F_BC;\
01169         else if (strcmp(optarg, "bm") == 0) g_options.m_fAlgorithm = F_BM;\
01170         else if (strcmp(optarg, "fp") == 0) g_options.m_fAlgorithm = F_FP;\
01171         else if (strcmp(optarg, "rp") == 0) g_options.m_fAlgorithm = F_RP;\
01172         else\
01173         {\
01174             LOG(L"main", Error,\
01175                 L"Invalid filter: " << string2wstring(optarg));\
01176             exit(1);\
01177         }\
01178         break;\
01179     case 'r':\
01180         if (strcmp(optarg, "chronological") == 0)\
01181             g_options.m_rAlgorithm = R_Chronological;\
01182         else if (strcmp(optarg, "cbj") == 0)\
01183             g_options.m_rAlgorithm = R_CBJ;\
01184         else\
01185         {\
01186             LOG(L"main", Error,\
01187                 L"Invalid retraction: " << string2wstring(optarg));\
01188             exit(1);\
01189         }\
01190         break;\
01191     case 'h':\
01192         if (g_options.m_decompositions.empty())\
01193         {\
01194             LOG(L"main", Error,\
01195                 string2wstring(optarg) <<\
01196                 L" heuristic ignored, no decomposition algorithm specified");\
01197             break;\
01198         }\
01199         else\
01200         {\
01201             std::wstring name;\
01202             double quality;\
01203             std::vector<std::pair<double, double> > intervals;\
01204             bool analysis;\
01205             parseHeuristicSpecification(name, quality, intervals, analysis);\
01206             g_options.addHeuristic(name, quality, intervals, analysis);\
01207         }\
01208         break;\
01209     case CSP_FFA_IST_HEURISTIC:\
01210         if (g_options.m_decompositions.empty())\
01211         {\
01212             LOG(L"main", Error,\
01213                 string2wstring(optarg) <<\
01214                 L" ffa insoluble subtree heuristic ignored, "\
01215                 L"no decomposition algorithm specified");\
01216             break;\
01217         }\
01218         else\
01219         {\
01220             std::wstring name;\
01221             double quality;\
01222             std::vector<std::pair<double, double> > intervals;\
01223             bool analysis;\
01224             parseHeuristicSpecification(name, quality, intervals, analysis);\
01225             g_options.addFFAIstHeuristic(name, quality, intervals);\
01226         }\
01227         break;\
01228     case CSP_FFA_HEURISTIC:\
01229         if (g_options.m_decompositions.empty())\
01230         {\
01231             LOG(L"main", Error,\
01232                 string2wstring(optarg) <<\
01233                 L" ffa heuristic ignored, "\
01234                 L"no decomposition algorithm specified");\
01235             break;\
01236         }\
01237         else\
01238         {\
01239             std::wstring name;\
01240             double quality;\
01241             std::vector<std::pair<double, double> > intervals;\
01242             bool analysis;\
01243             parseHeuristicSpecification(name, quality, intervals, analysis);\
01244             g_options.addFFAHeuristic(name, quality, intervals);\
01245         }\
01246         break;\
01247     case CSP_IDC_CHOICE_FACTOR:\
01248         g_options.m_idcChoiceFactor =\
01249             arg2d(L"Invalid IDC[[-MC]-PDS] choice factor");\
01250         break;\
01251     case CSP_AC2000_RATIO:\
01252         g_options.m_ac2000Ratio = arg2d(L"Invalid AC2000 ratio");\
01253         break;\
01254     case 'p':\
01255         csp::g_predictable = true;\
01256         break;\
01257     case CSP_STATIC_OPTIMISM:\
01258         {\
01259             wstring error =\
01260                 L"Invalid static optimism percentage; should be in [0-100)";\
01261             g_options.m_staticOptimismPercentage = arg2d(error.c_str());\
01262             if (g_options.m_staticOptimismPercentage < 0 ||\
01263                 g_options.m_staticOptimismPercentage >= 100)\
01264             {\
01265                 ILOG(Error, error);\
01266                 exit(13);\
01267             }\
01268         }\
01269         break;\
01270     case CSP_DYNAMIC_OPTIMISM:\
01271         {\
01272             wstring error =\
01273                 L"Invalid dynamic optimism percentage; should be in [0-100)";\
01274             g_options.m_dynamicOptimismPercentage = arg2d(error.c_str());\
01275             if (g_options.m_dynamicOptimismPercentage < 0 ||\
01276                 g_options.m_dynamicOptimismPercentage >= 100)\
01277             {\
01278                 ILOG(Error, error);\
01279                 exit(13);\
01280             }\
01281         }\
01282         break;\
01283     case CSP_STATIC_OPTIMISM_BUCKETING:\
01284         g_options.m_staticOptimismBucketing = true;\
01285         break;\
01286     case CSP_DYNAMIC_OPTIMISM_BUCKETING:\
01287         g_options.m_dynamicOptimismBucketing = true;\
01288         break;\
01289     case CSP_HEURISTIC_QUALITY_BUCKETING:\
01290         g_options.m_heuristicQualityBucketing = true;\
01291         break;\
01292     case CSP_SECOND_SEARCH_OFF:\
01293         g_options.m_secondSearchOff = true;\
01294         break;\
01295     case CSP_GREEDY_VARIABLE_PROCESSING:\
01296         g_options.m_greedyVariableProcessing = true;\
01297         break;\
01298     case CSP_DEACTIVATE_LOOSE_CONSTRAINTS:\
01299         g_options.m_deactivateLooseConstraints = true;\
01300         break;\
01301     case 'b':\
01302         if (isTeleType(1))\
01303             g_options.m_beep = arg2ul(L"Invalid number of seconds");\
01304         else\
01305             LOG(L"main", Warning, L"Cannot beep on a non-tty");\
01306         break;\
01307     case 'V':\
01308         if (strcmp(optarg, "info") == 0)\
01309             csp::Log::setLevel(csp::Info);\
01310         else if (strcmp(optarg, "error") == 0)\
01311             csp::Log::setLevel(csp::Error);\
01312         else if (strcmp(optarg, "warning") == 0)\
01313             csp::Log::setLevel(csp::Warning);\
01314         else if (strcmp(optarg, "notice") == 0)\
01315             csp::Log::setLevel(csp::Notice);\
01316         else if (strcmp(optarg, "debug0") == 0)\
01317             csp::Log::setLevel(csp::Debug0);\
01318         else if (strcmp(optarg, "debug1") == 0)\
01319             csp::Log::setLevel(csp::Debug1);\
01320         else if (strcmp(optarg, "debug2") == 0)\
01321             csp::Log::setLevel(csp::Debug2);\
01322         else if (strcmp(optarg, "debug") == 0)\
01323             csp::Log::setLevel(csp::Debug);\
01324         else\
01325             LOG(L"main", Error,\
01326                 L"Unknown log verbosity level: `" << optarg << L"'");\
01327         break;\
01328     case 'l':\
01329         {\
01330             if (!optarg || (optarg[0] == '\0'))\
01331             {\
01332                 csp::Log::registerPattern(L"");\
01333                 break;\
01334             }\
01335             vector<std::wstring> v;\
01336             wstring2container(string2wstring(optarg), inserter(v, v.end()));\
01337             for_each(v.begin(), v.end(), csp::Log::registerPattern);\
01338         }\
01339         break;\
01340     case 'i':\
01341         g_options.m_useIndentation = true;\
01342         break;\
01343     case CSP_FANCY:\
01344         g_options.m_fancy = true;\
01345         break;\
01346     case CSP_VERIFY:\
01347         g_options.m_verify = true;\
01348         break;\
01349     case CSP_CONSISTENCY_ONLY:\
01350         g_options.m_consistencyOnly = true;\
01351         if (g_options.m_noProcessing)\
01352             LOG(L"main", Warning,\
01353                 L"--consistency-only discards --no-processing");\
01354         break;\
01355     case CSP_NO_PROCESSING:\
01356         g_options.m_noProcessing = true;\
01357         if (g_options.m_consistencyOnly)\
01358             LOG(L"main", Warning,\
01359                 L"--no-processing discards --consistency-only");\
01360         break;\
01361     case CSP_SAVE_PROBLEM:\
01362         g_options.m_problemDestinationFileStem = string2wstring(optarg);\
01363         break;\
01364     case CSP_LOAD_PROBLEM:\
01365         g_options.m_problemSourceFileStem = string2wstring(optarg);\
01366         break;\
01367     case CSP_SAVE_SOLUTIONS:\
01368         g_options.m_solutionsDestinationFileStem = string2wstring(optarg);\
01369         break;\
01370     case CSP_LOAD_SOLUTIONS:\
01371         g_options.m_solutionsSourceFileStem = string2wstring(optarg);\
01372         break;\
01373     case CSP_PROBLEM_GRAPH:\
01374         g_options.m_problemGraphFileStem = string2wstring(optarg);\
01375         break;\
01376     case CSP_PROBLEM_GRAPH_DEPTH:\
01377         g_options.m_problemGraphGenerationDepth = arg2ul(L"Invalid graph depth");\
01378         break;\
01379     case CSP_SEARCH_TREE:\
01380         g_options.m_searchTreeFileStem = string2wstring(optarg);\
01381         break;\
01382     case CSP_SEARCH_TREE_DEPTH:\
01383         g_options.m_searchTreeGenerationDepth = arg2ul(L"Invalid graph depth");\
01384         break;
01385 
01386 
01387 #endif // _CSP_EXAMPLES_CommonMain_H
01388 
01389 // Local Variables:
01390 // mode: C++
01391 // End:

Generated on Wed May 25 12:21:13 2005 for csp.kdevelop by  doxygen 1.3.9.1