    void run_sequence_search(int solveKind, SimpleNode kind, SearchItem si) {
	singleSearch = false;
	this.si = si;
	if (options.getVerbose()) {
	    String solve="notKnown";
	    switch (solveKind) {
	    case 0: solve = "%% satisfy"; break; 
	    case 1: 
		solve = "%% minimize("+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+") "; break; 
	    case 2: 
		solve = "%% maximize("+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+") "; break; 
	    }
	    System.out.println(solve + " : seq_search([" + si + "])");
	}
	DepthFirstSearch<Var> masterLabel = null;
	DepthFirstSearch<Var> last_search = null;
	SelectChoicePoint<Var> masterSelect = null;
	list_seq_searches = new ArrayList<Search<Var>>();
	for (int i=0; i<si.getSearchItems().size(); i++) {
	    if (i == 0) { 
		masterLabel = sub_search(si.getSearchItems().get(i), masterLabel, true);
		last_search = masterLabel;
		masterSelect = variable_selection;
		if (!print_search_info) masterLabel.setPrintInfo(false);
	    }
	    else {
		DepthFirstSearch<Var> label = sub_search(si.getSearchItems().get(i), last_search, false);
		last_search.addChildSearch(label);
		last_search = label;
		if (!print_search_info) last_search.setPrintInfo(false);
	    }
	}
 	DepthFirstSearch<Var>[] complementary_search = setSubSearchForAll(last_search, options);	
        for (DepthFirstSearch<Var> aComplementary_search : complementary_search) {
            if (aComplementary_search != null) {
                list_seq_searches.add(aComplementary_search);
                if (!print_search_info) aComplementary_search.setPrintInfo(false);
            }
        }
	Result = false;	
	IntVar cost;
	optimization = false;
	Search<Var> final_search_seq = list_seq_searches.get(list_seq_searches.size()-1);
	tread = java.lang.Thread.currentThread();
	java.lang.management.ThreadMXBean b = java.lang.management.ManagementFactory.getThreadMXBean();
	searchTimeMeter = b;
	startCPU = b.getThreadCpuTime(tread.getId());
	int to = options.getTimeOut();
	if (to > 0)
	    for (Search s : list_seq_searches)
		s.setTimeOut(to);
	int ns = options.getNumberSolutions();
	if (si.exploration() == null || si.exploration().equals("complete"))
	    switch (solveKind) {
	    case 0: 
 		if (options.getAll() ) { 
  		    for (int i=0; i<si.getSearchItems().size(); i++) {  
  			list_seq_searches.get(i).getSolutionListener().searchAll(true);
  			list_seq_searches.get(i).getSolutionListener().recordSolutions(false);
       			if ( ns>0 )
     			    list_seq_searches.get(i).getSolutionListener().setSolutionLimit(ns);
 		    }
 		}
		Result = masterLabel.labeling(store, masterSelect);
		break;
	    case 1: 
		optimization = true;
		cost = getCost((ASTSolveExpr)kind.jjtGetChild(0));
		for (Search<Var> list_seq_searche : list_seq_searches)
		    list_seq_searche.setOptimize(true);
		if (ns > 0) {
		    for (int i=0; i<list_seq_searches.size()-1; i++)
		     	((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice = true;
		    final_search_seq.getSolutionListener().setSolutionLimit(ns);
		    ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice = true;
		}
		Result = masterLabel.labeling(store, masterSelect, cost);
		break;
	    case 2: 
		optimization = true;
		cost = getCost((ASTSolveExpr)kind.jjtGetChild(0));
		IntVar max_cost = new IntVar(store, "-"+cost.id(), IntDomain.MinInt, 
		 						 IntDomain.MaxInt);
		pose(new XplusYeqC(max_cost, cost, 0));
            for (Search<Var> list_seq_searche : list_seq_searches)
                list_seq_searche.setOptimize(true);
		if (ns > 0) {
		    for (int i=0; i<list_seq_searches.size()-1; i++)
			((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice=true;
		    final_search_seq.getSolutionListener().setSolutionLimit(ns);
		    ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice=true;
		}
		Result = masterLabel.labeling(store, masterSelect, max_cost);
		break;
	    }
	else {
	    System.err.println("Not recognized or supported "+si.exploration()+
			       " search explorarion strategy ; compilation aborted");
	    System.exit(0);
	}
	printStatisticsForSeqSearch(false);
    }
    void printStatisticsForSeqSearch(boolean interrupted) {
	if (list_seq_searches == null) {
	    System.out.println ("%% =====INTERRUPTED=====\n%% Model not yet posed..");
	    return;
	}
	if (Result) {
	    if (!optimization && options.getAll()) {
		if (!heuristicSeqSearch)
		    if (! anyTimeOutOccured(list_seq_searches)) {
			if (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())
			    System.out.println("==========");
		    }
		    else
			System.out.println("%% =====TIME-OUT=====");
		else
		    if (anyTimeOutOccured(list_seq_searches)) 
			System.out.println("%% =====TIME-OUT=====");
	    }
	    else if (optimization) {
		if (!heuristicSeqSearch)
		    if (! anyTimeOutOccured(list_seq_searches)) {
			if (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())
			    System.out.println("==========");
		    }
		    else
			System.out.println("%% =====TIME-OUT=====");
		else
		    if (anyTimeOutOccured(list_seq_searches)) 
			System.out.println("%% =====TIME-OUT=====");
	    }
	}
	else
	    if (anyTimeOutOccured(list_seq_searches)) {
		System.out.println("=====UNKNOWN=====");
		System.out.println("%% =====TIME-OUT=====");
	    }
	    else
		if (interrupted)
		    System.out.println ("%% =====INTERRUPTED=====");
		else
		    System.out.println("=====UNSATISFIABLE=====");
	if (options.getStatistics()) {
	    int nodes=0, decisions=0, wrong=0, backtracks=0, depth=0,solutions=0;
        for (Search<Var> label : list_seq_searches) {
            nodes += label.getNodes();
            decisions += label.getDecisions();
            wrong += label.getWrongDecisions();
            backtracks += label.getBacktracks();
            depth += label.getMaximumDepth();
            solutions = label.getSolutionListener().solutionsNo();
        }
	System.out.println("\n%% Model variables : "+ (store.size()+ NumberBoolVariables) +
			   "\n%% Model constraints : "+initNumberConstraints+
			   "\n\n%% Search CPU time : " + (searchTimeMeter.getThreadCpuTime(tread.getId()) - startCPU)/(long)1e+6 + "ms"+
			   "\n%% Search nodes : "+nodes+
			   "\n%% Search decisions : "+decisions+
			   "\n%% Wrong search decisions : "+wrong+
			   "\n%% Search backtracks : "+backtracks+
			   "\n%% Max search depth : "+depth+
			   "\n%% Number solutions : "+ solutions 
			   );
	}
    }
    boolean anyTimeOutOccured(ArrayList<Search<Var>> list_seq_searches) {
        for (Search<Var> list_seq_searche : list_seq_searches)
            if (((DepthFirstSearch) list_seq_searche).timeOutOccured)
                return true;
	return false;
    }
    DepthFirstSearch<Var> sub_search(SearchItem si, DepthFirstSearch<Var> l, boolean master) {
	DepthFirstSearch<Var> last_search = l;
	DepthFirstSearch<Var> label = null;
	if (si.type().equals("int_search") || si.type().equals("bool_search")) {
	    label = int_search(si);
	    if (!master) label.setSelectChoicePoint(variable_selection);
	    if (si.exploration().equals("lds")) {
		lds_search(label, si.ldsValue);
		heuristicSeqSearch = true;
	    }
	    if (si.exploration().equals("credit")) {
		credit_search(label, si.creditValue, si.bbsValue);
		heuristicSeqSearch = true;
	    }
	    list_seq_searches.add(label);
	}
	else if (si.type().equals("set_search")) {
	    setSearch=true;
	    label = set_search(si);
	    if (!master) 
		label.setSelectChoicePoint(variable_selection);
	    if (si.exploration().equals("lds")) {
		lds_search(label, si.ldsValue);
		heuristicSeqSearch = true;
	    }
	    if (si.exploration().equals("credit")) {
		credit_search(label, si.creditValue, si.bbsValue);
		heuristicSeqSearch = true;
	    }
	    list_seq_searches.add(label);
	}
	else if (si.type().equals("seq_search")) {
	    for (int i=0; i<si.getSearchItems().size(); i++)
		if (i == 0) { 
		    DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);
		    last_search = label_seq;
		    label = label_seq;
		}
		else {
		    DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);
		    last_search.addChildSearch(label_seq);
		    last_search = label_seq;
		}
	}
	else {
	    System.err.println("Not recognized or supported search type \""+si.type()+"\"; compilation aborted");
	    System.exit(0);
	}
	return label;
    }
    DepthFirstSearch<Var> int_search(SearchItem si) {
        variable_selection = si.getIntSelect();
        return new DepthFirstSearch<Var>();
    }
    DepthFirstSearch<Var> set_search(SearchItem si) {
        variable_selection = si.getSetSelect();
        return new DepthFirstSearch<Var>();
    }
    void printSolution() {
	if (dictionary.outputVariables.size() > 0)
	    for (int i=0; i<dictionary.outputVariables.size(); i++) {
		Var v = dictionary.outputVariables.get(i);
 		if (v instanceof BooleanVar) {
		    String boolVar = v.id()+" = ";
		    if (v.singleton())
			switch ( ((BooleanVar)v).value()) {
			case 0: boolVar += "false";
			    break;
			case 1: boolVar += "true";
			    break;
			default: boolVar += v.dom();
			}
		    else
			boolVar += "false..true";
		    System.out.println(boolVar+";");
		}
		else if (v instanceof SetVar) {
		    String setVar = v.id() + " = ";
		    if (v.singleton()) {
			IntDomain glb = ((SetVar)v).dom().glb();
			setVar += "{";
			for (ValueEnumeration e = glb.valueEnumeration(); e.hasMoreElements();) {
			    int element = e.nextElement();
			    setVar += element;
			    if (e.hasMoreElements())
				setVar += ", ";
			}
			setVar += "}";
		    }
		    else
			setVar += v.dom().toString();
		    System.out.println(setVar+";");
		}
		else
		    System.out.println(v+";");
	    }
	for (int i=0; i<dictionary.outputArray.size(); i++) {
	    OutputArrayAnnotation a = dictionary.outputArray.get(i);
	    System.out.println(a);
	}
    }
    int getKind(String k) {
	if (k.equals("satisfy")) 
	    return 0;
	else if (k.equals("minimize")) 
	    return 1;
	else if (k.equals("maximize")) 
	    return 2;
	else {
	    System.err.println("Not supported search kind; compilation aborted");
	    System.exit(0);
	    return -1;
	}
    }
    IntVar getCost(ASTSolveExpr node) {
	if (node.getType() == 0) 
	    return dictionary.getVariable(node.getIdent());
	else if (node.getType() == 1) 
	    return dictionary.getVariableArray(node.getIdent())[node.getIndex()];
	else {
	    System.err.println("Wrong cost function specification " + node);
	    System.exit(0);
	    return new IntVar(store);
	}
    }
    void pose(Constraint c) {
	store.impose(c);
	if (debug)
	    System.out.println(c);
    }
    void lds_search(DepthFirstSearch<Var> label, int lds_value) {
	LDS<Var> lds = new LDS<Var>(lds_value); 
	if (label.getExitChildListener() == null)
	    label.setExitChildListener(lds);
	else
	    label.getExitChildListener().setChildrenListeners(lds);
    }
    void credit_search(DepthFirstSearch<Var> label, int creditValue, int bbsValue) {
	int maxDepth = 1000; 
	CreditCalculator<Var> credit = new CreditCalculator<Var>(creditValue, bbsValue, maxDepth);
	if (label.getConsistencyListener() == null)
	    label.setConsistencyListener(credit);
	else
	    label.getConsistencyListener().setChildrenListeners(credit);
	label.setExitChildListener(credit);
	label.setTimeOutListener(credit);
    }
    void setNumberBoolVariables(int n) {
	NumberBoolVariables = n;
    }
    void printSearch(Search label) {
	int N = 1;
	System.out.println (N++ + ". " + label);
	java.util.LinkedHashSet<Search<? extends Var>> l = 
	    new java.util.LinkedHashSet<Search<? extends Var>>();
	l.add(label);
	while (l.size() != 0) {
	    java.util.LinkedHashSet<Search<? extends Var>> ns = 
		new java.util.LinkedHashSet<Search<? extends Var>>();
	    for (Search s1 : l) {
		Search<? extends Var>[] child = ((DepthFirstSearch)s1).childSearches;
		if (child != null)
		    for (Search s : child) {
			System.out.println (N + ". " + s);
			ns.add(s);	
		    }
	    }
	    N++;
	    l = ns;
	}
    }
    int FinalNumberSolutions = 0;
    public class CostListener<T extends Var> extends SimpleSolutionListener<T> {
	public boolean executeAfterSolution(Search<T> search, SelectChoicePoint<T> select) {
	    boolean returnCode = super.executeAfterSolution(search, select);
	    if (costVariable != null)
		costValue = ((IntVar)costVariable).value();
	    FinalNumberSolutions++;
	    printSolution();
	    System.out.println("----------");
	    return returnCode;
	}
    }
    class DomainSizeComparator<T extends Var> implements Comparator<T> {
	DomainSizeComparator() { }
	public int compare(T o1, T o2) {
	    int v1 = o1.getSize();
	    int v2 = o2.getSize();
	    return v1 - v2;
	}
    }
}

    void run_sequence_search(int solveKind, SimpleNode kind, SearchItem si) {
	singleSearch = false;
	this.si = si;
	if (options.getVerbose()) {
	    String solve="notKnown";
	    switch (solveKind) {
	    case 0: solve = "%% satisfy"; break; 
	    case 1: 
		solve = "%% minimize("+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+") "; break; 
	    case 2: 
		solve = "%% maximize("+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+") "; break; 
	    }
	    System.out.println(solve + " : seq_search([" + si + "])");
	}
	DepthFirstSearch<Var> masterLabel = null;
	DepthFirstSearch<Var> last_search = null;
	SelectChoicePoint<Var> masterSelect = null;
	list_seq_searches = new ArrayList<Search<Var>>();
	for (int i=0; i<si.getSearchItems().size(); i++) {
	    if (i == 0) { 
		masterLabel = sub_search(si.getSearchItems().get(i), masterLabel, true);
		last_search = masterLabel;
		masterSelect = variable_selection;
		if (!print_search_info) masterLabel.setPrintInfo(false);
	    }
	    else {
		DepthFirstSearch<Var> label = sub_search(si.getSearchItems().get(i), last_search, false);
		last_search.addChildSearch(label);
		last_search = label;
		if (!print_search_info) last_search.setPrintInfo(false);
	    }
	}
 	DepthFirstSearch<Var>[] complementary_search = setSubSearchForAll(last_search, options);	
        for (DepthFirstSearch<Var> aComplementary_search : complementary_search) {
            if (aComplementary_search != null) {
                list_seq_searches.add(aComplementary_search);
                if (!print_search_info) aComplementary_search.setPrintInfo(false);
            }
        }
	Result = false;	
	IntVar cost;
	optimization = false;
	final_search_seq = list_seq_searches.get(list_seq_searches.size()-1);
	tread = java.lang.Thread.currentThread();
	java.lang.management.ThreadMXBean b = java.lang.management.ManagementFactory.getThreadMXBean();
	searchTimeMeter = b;
	startCPU = b.getThreadCpuTime(tread.getId());
	int to = options.getTimeOut();
	if (to > 0)
	    for (Search s : list_seq_searches)
		s.setTimeOut(to);
	int ns = options.getNumberSolutions();
	if (si.exploration() == null || si.exploration().equals("complete"))
	    switch (solveKind) {
	    case 0: 
 		if (options.getAll() ) { 
  		    for (int i=0; i<si.getSearchItems().size(); i++) {  
  			list_seq_searches.get(i).getSolutionListener().searchAll(true);
  			list_seq_searches.get(i).getSolutionListener().recordSolutions(false);
       			if ( ns>0 )
     			    list_seq_searches.get(i).getSolutionListener().setSolutionLimit(ns);
 		    }
 		}
		Result = masterLabel.labeling(store, masterSelect);
		break;
	    case 1: 
		optimization = true;
		cost = getCost((ASTSolveExpr)kind.jjtGetChild(0));
		for (Search<Var> list_seq_searche : list_seq_searches)
		    list_seq_searche.setOptimize(true);
		if (ns > 0) {
		    for (int i=0; i<list_seq_searches.size()-1; i++)
		     	((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice = true;
		    final_search_seq.getSolutionListener().setSolutionLimit(ns);
		    ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice = true;
		}
		Result = masterLabel.labeling(store, masterSelect, cost);
		break;
	    case 2: 
		optimization = true;
		cost = getCost((ASTSolveExpr)kind.jjtGetChild(0));
		IntVar max_cost = new IntVar(store, "-"+cost.id(), IntDomain.MinInt, 
		 						 IntDomain.MaxInt);
		pose(new XplusYeqC(max_cost, cost, 0));
            for (Search<Var> list_seq_searche : list_seq_searches)
                list_seq_searche.setOptimize(true);
		if (ns > 0) {
		    for (int i=0; i<list_seq_searches.size()-1; i++)
			((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice=true;
		    final_search_seq.getSolutionListener().setSolutionLimit(ns);
		    ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice=true;
		}
		Result = masterLabel.labeling(store, masterSelect, max_cost);
		break;
	    }
	else {
	    System.err.println("Not recognized or supported "+si.exploration()+
			       " search explorarion strategy ; compilation aborted");
	    System.exit(0);
	}
	printStatisticsForSeqSearch(false);
    }
    void printStatisticsForSeqSearch(boolean interrupted) {
	if (list_seq_searches == null) {
	    System.out.println ("%% =====INTERRUPTED=====\n%% Model not yet posed..");
	    return;
	}
	if (Result) {
	    if (!optimization && options.getAll()) {
		if (!heuristicSeqSearch)
		    if (! anyTimeOutOccured(list_seq_searches)) {
			if (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())
			    System.out.println("==========");
		    }
		    else
			System.out.println("%% =====TIME-OUT=====");
		else
		    if (anyTimeOutOccured(list_seq_searches)) 
			System.out.println("%% =====TIME-OUT=====");
	    }
	    else if (optimization) {
		if (!heuristicSeqSearch)
		    if (! anyTimeOutOccured(list_seq_searches)) {
			if (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())
			    System.out.println("==========");
		    }
		    else
			System.out.println("%% =====TIME-OUT=====");
		else
		    if (anyTimeOutOccured(list_seq_searches)) 
			System.out.println("%% =====TIME-OUT=====");
	    }
	}
	else
	    if (anyTimeOutOccured(list_seq_searches)) {
		System.out.println("=====UNKNOWN=====");
		System.out.println("%% =====TIME-OUT=====");
	    }
	    else
		if (interrupted)
		    System.out.println ("%% =====INTERRUPTED=====");
		else
		    System.out.println("=====UNSATISFIABLE=====");
	if (options.getStatistics()) {
	    int nodes=0, decisions=0, wrong=0, backtracks=0, depth=0,solutions=0;
        for (Search<Var> label : list_seq_searches) {
            nodes += label.getNodes();
            decisions += label.getDecisions();
            wrong += label.getWrongDecisions();
            backtracks += label.getBacktracks();
            depth += label.getMaximumDepth();
            solutions = label.getSolutionListener().solutionsNo();
        }
	System.out.println("\n%% Model variables : "+ (store.size()+ NumberBoolVariables) +
			   "\n%% Model constraints : "+initNumberConstraints+
			   "\n\n%% Search CPU time : " + (searchTimeMeter.getThreadCpuTime(tread.getId()) - startCPU)/(long)1e+6 + "ms"+
			   "\n%% Search nodes : "+nodes+
			   "\n%% Search decisions : "+decisions+
			   "\n%% Wrong search decisions : "+wrong+
			   "\n%% Search backtracks : "+backtracks+
			   "\n%% Max search depth : "+depth+
			   "\n%% Number solutions : "+ solutions 
			   );
	}
    }
    boolean anyTimeOutOccured(ArrayList<Search<Var>> list_seq_searches) {
        for (Search<Var> list_seq_searche : list_seq_searches)
            if (((DepthFirstSearch) list_seq_searche).timeOutOccured)
                return true;
	return false;
    }
    DepthFirstSearch<Var> sub_search(SearchItem si, DepthFirstSearch<Var> l, boolean master) {
	DepthFirstSearch<Var> last_search = l;
	DepthFirstSearch<Var> label = null;
	if (si.type().equals("int_search") || si.type().equals("bool_search")) {
	    label = int_search(si);
	    if (!master) label.setSelectChoicePoint(variable_selection);
	    if (si.exploration().equals("lds")) {
		lds_search(label, si.ldsValue);
		heuristicSeqSearch = true;
	    }
	    if (si.exploration().equals("credit")) {
		credit_search(label, si.creditValue, si.bbsValue);
		heuristicSeqSearch = true;
	    }
	    list_seq_searches.add(label);
	}
	else if (si.type().equals("set_search")) {
	    setSearch=true;
	    label = set_search(si);
	    if (!master) 
		label.setSelectChoicePoint(variable_selection);
	    if (si.exploration().equals("lds")) {
		lds_search(label, si.ldsValue);
		heuristicSeqSearch = true;
	    }
	    if (si.exploration().equals("credit")) {
		credit_search(label, si.creditValue, si.bbsValue);
		heuristicSeqSearch = true;
	    }
	    list_seq_searches.add(label);
	}
	else if (si.type().equals("seq_search")) {
	    for (int i=0; i<si.getSearchItems().size(); i++)
		if (i == 0) { 
		    DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);
		    last_search = label_seq;
		    label = label_seq;
		}
		else {
		    DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);
		    last_search.addChildSearch(label_seq);
		    last_search = label_seq;
		}
	}
	else {
	    System.err.println("Not recognized or supported search type \""+si.type()+"\"; compilation aborted");
	    System.exit(0);
	}
	return label;
    }
    DepthFirstSearch<Var> int_search(SearchItem si) {
        variable_selection = si.getIntSelect();
        return new DepthFirstSearch<Var>();
    }
    DepthFirstSearch<Var> set_search(SearchItem si) {
        variable_selection = si.getSetSelect();
        return new DepthFirstSearch<Var>();
    }
    void printSolution() {
	if (dictionary.outputVariables.size() > 0)
	    for (int i=0; i<dictionary.outputVariables.size(); i++) {
		Var v = dictionary.outputVariables.get(i);
 		if (v instanceof BooleanVar) {
		    String boolVar = v.id()+" = ";
		    if (v.singleton())
			switch ( ((BooleanVar)v).value()) {
			case 0: boolVar += "false";
			    break;
			case 1: boolVar += "true";
			    break;
			default: boolVar += v.dom();
			}
		    else
			boolVar += "false..true";
		    System.out.println(boolVar+";");
		}
		else if (v instanceof SetVar) {
		    String setVar = v.id() + " = ";
		    if (v.singleton()) {
			IntDomain glb = ((SetVar)v).dom().glb();
			setVar += "{";
			for (ValueEnumeration e = glb.valueEnumeration(); e.hasMoreElements();) {
			    int element = e.nextElement();
			    setVar += element;
			    if (e.hasMoreElements())
				setVar += ", ";
			}
			setVar += "}";
		    }
		    else
			setVar += v.dom().toString();
		    System.out.println(setVar+";");
		}
		else
		    System.out.println(v+";");
	    }
	for (int i=0; i<dictionary.outputArray.size(); i++) {
	    OutputArrayAnnotation a = dictionary.outputArray.get(i);
	    System.out.println(a);
	}
    }
    int getKind(String k) {
	if (k.equals("satisfy")) 
	    return 0;
	else if (k.equals("minimize")) 
	    return 1;
	else if (k.equals("maximize")) 
	    return 2;
	else {
	    System.err.println("Not supported search kind; compilation aborted");
	    System.exit(0);
	    return -1;
	}
    }
    IntVar getCost(ASTSolveExpr node) {
	if (node.getType() == 0) 
	    return dictionary.getVariable(node.getIdent());
	else if (node.getType() == 1) 
	    return dictionary.getVariableArray(node.getIdent())[node.getIndex()];
	else {
	    System.err.println("Wrong cost function specification " + node);
	    System.exit(0);
	    return new IntVar(store);
	}
    }
    void pose(Constraint c) {
	store.impose(c);
	if (debug)
	    System.out.println(c);
    }
    void lds_search(DepthFirstSearch<Var> label, int lds_value) {
	LDS<Var> lds = new LDS<Var>(lds_value); 
	if (label.getExitChildListener() == null)
	    label.setExitChildListener(lds);
	else
	    label.getExitChildListener().setChildrenListeners(lds);
    }
    void credit_search(DepthFirstSearch<Var> label, int creditValue, int bbsValue) {
	int maxDepth = 1000; 
	CreditCalculator<Var> credit = new CreditCalculator<Var>(creditValue, bbsValue, maxDepth);
	if (label.getConsistencyListener() == null)
	    label.setConsistencyListener(credit);
	else
	    label.getConsistencyListener().setChildrenListeners(credit);
	label.setExitChildListener(credit);
	label.setTimeOutListener(credit);
    }
    void setNumberBoolVariables(int n) {
	NumberBoolVariables = n;
    }
    void printSearch(Search label) {
	int N = 1;
	System.out.println (N++ + ". " + label);
	java.util.LinkedHashSet<Search<? extends Var>> l = 
	    new java.util.LinkedHashSet<Search<? extends Var>>();
	l.add(label);
	while (l.size() != 0) {
	    java.util.LinkedHashSet<Search<? extends Var>> ns = 
		new java.util.LinkedHashSet<Search<? extends Var>>();
	    for (Search s1 : l) {
		Search<? extends Var>[] child = ((DepthFirstSearch)s1).childSearches;
		if (child != null)
		    for (Search s : child) {
			System.out.println (N + ". " + s);
			ns.add(s);	
		    }
	    }
	    N++;
	    l = ns;
	}
    }
    int FinalNumberSolutions = 0;
    public class CostListener<T extends Var> extends SimpleSolutionListener<T> {
	public boolean executeAfterSolution(Search<T> search, SelectChoicePoint<T> select) {
	    boolean returnCode = super.executeAfterSolution(search, select);
	    if (costVariable != null)
		costValue = ((IntVar)costVariable).value();
	    FinalNumberSolutions++;
	    printSolution();
	    System.out.println("----------");
	    return returnCode;
	}
    }
    class DomainSizeComparator<T extends Var> implements Comparator<T> {
	DomainSizeComparator() { }
	public int compare(T o1, T o2) {
	    int v1 = o1.getSize();
	    int v2 = o2.getSize();
	    return v1 - v2;
	}
    }
}
