Permalink
Browse files

Merge fzn.

Squashed commit of the following:

commit eb35524
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Oct 21 19:53:04 2013 +0100

    mzn_numberjack script by Simon de Givry.

commit a0e9f78
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Oct 21 19:52:20 2013 +0100

    typo.

commit 44720d1
Merge: 72715a3 ff75669
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Oct 21 19:45:44 2013 +0100

    Merge branch 'refs/heads/master' into fzn

    Conflicts:
    	available_interfaces/ExampleInterface/python/.gitignore
    	solvers/mistral2/mistral/src/lib/mistral_constraint.cpp
    	solvers/mistral2/mistral/src/lib/mistral_solver.cpp
    	solvers/sat/src/SatWrapper.cpp
    	src/Numberjack.py
    	tools/help.sh

commit 72715a3
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Oct 21 19:19:01 2013 +0100

    Patches from Simon de Givry.

commit ff75669
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Oct 21 15:03:26 2013 +0100

    Minor fixes to support compiling Mistral & MiniSat under latest clang and g++.

    Remove printXML as it is not used.
    DVONoOrder::select is not defined inline as it gave issues with all class method being given in the class definition.
    MiniSat Clause_new had to be defined in class definition and specified outside.

commit 9273e95
Merge: d6d8f45 6f0afac
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Oct 21 15:00:12 2013 +0100

    Merge branch 'master' of github.com:eomahony/Numberjack

commit 6f0afac
Merge: 6a215bf 7adb44f
Author: ehebrard <emmanuel.hebrard@gmail.com>
Date:   Thu Oct 17 09:41:32 2013 +0200

    Merge branch 'master' of github.com:eomahony/Numberjack

commit 6a215bf
Author: ehebrard <emmanuel.hebrard@gmail.com>
Date:   Thu Oct 17 09:41:24 2013 +0200

    bug lex-order: leqLex and LtLex were swapped

commit d6d8f45
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Sep 19 13:58:27 2013 +0200

    AllDiffExcept0 constraint.

    Currently not supported by any underlying solvers, so is decomposed.

commit 0235254
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Sep 19 13:57:24 2013 +0200

    Remove -1 from Mistral2 verbosity.

commit 7adb44f
Author: 9thbit <9thbit@gmail.com>
Date:   Wed Sep 18 15:01:27 2013 +0200

    Tidy up many of the examples and add some descriptions to them.

commit 9741fd2
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Sep 17 23:20:56 2013 +0200

    Re-enable support for string values in domains.

commit ef3fd1d
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Sep 17 23:19:59 2013 +0200

    Solver list.

commit c2962ca
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Sep 16 23:38:44 2013 +0200

    Remove unnecessary -I from Mistral2 Makefile.

commit 9da32bb
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Sep 16 12:01:04 2013 +0200

    Simplify the output of help.sh for local_install so that the two lines can be copied easily.

commit 365b1fd
Merge: 1cba99a a9a3297
Author: 9thbit <9thbit@gmail.com>
Date:   Sun Sep 15 23:47:27 2013 +0200

    Merge branch 'SATPigeonHoleAllDiff'

commit 1cba99a
Author: 9thbit <9thbit@gmail.com>
Date:   Sun Sep 15 23:47:04 2013 +0200

    Documentation for Task class.

commit 0d346e5
Author: 9thbit <9thbit@gmail.com>
Date:   Sat Sep 14 15:37:56 2013 +0200

    Updated introduction doc.

commit 530e608
Author: 9thbit <9thbit@gmail.com>
Date:   Sat Sep 14 15:36:58 2013 +0200

    Slightly cleaner XKCD knapsack example.

commit a9a3297
Author: 9thbit <9thbit@gmail.com>
Date:   Sat Sep 14 13:18:21 2013 +0200

    Add missing pigeon hole enum.

commit 8a5dee1
Author: 9thbit <9thbit@gmail.com>
Date:   Sat Sep 14 13:17:51 2013 +0200

    getTime for MiniSat and Walksat now returns the CPU time spent solving, excluding the time to create the CNF encoding.

    By recording start time in the constructor, it was including the encoding time.

commit c62acf9
Author: 9thbit <9thbit@gmail.com>
Date:   Sat Sep 14 13:15:45 2013 +0200

    SAT encoding can add additional pigeon hole constraints for an encoding of AllDiff.

commit bd8e7f0
Author: 9thbit <9thbit@gmail.com>
Date:   Wed Sep 4 11:04:07 2013 +0100

    Allow a MIP encoded Sum to take real valued offsets instead of just integer.

    Includes regression test.

commit c697115
Author: 9thbit <9thbit@gmail.com>
Date:   Wed Sep 4 11:03:38 2013 +0100

    Print some debug info if the solver does not support an expression.

commit d984ce8
Author: 9thbit <9thbit@gmail.com>
Date:   Wed Aug 28 15:09:12 2013 +0100

    Add CPLEX to the README.

commit c7ed2d3
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Aug 27 18:00:05 2013 +0100

    Remove unused var and debug output in Gurobi interface.

commit 00ec9fa
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Aug 27 17:59:20 2013 +0100

    available_interfaces/scip shouldn't have the generated interface files checked in.

commit 43b570b
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Aug 27 17:57:52 2013 +0100

    Variables coefficients in the objective was not being passed to SCIP.

commit 30f9792
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Aug 27 10:43:59 2013 +0100

    CPLEXDIR should contain /cplex

commit 11df07d
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Aug 27 10:20:12 2013 +0100

    Create the obj and python folders if they don't exist.

commit 5700bd3
Merge: c199a14 088d9b5
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Aug 27 10:15:13 2013 +0100

    Merge branch 'master' of github.com:eomahony/Numberjack

commit 088d9b5
Author: ehebrard <emmanuel.hebrard@gmail.com>
Date:   Tue Aug 27 09:47:47 2013 +0200

    added Mistral2.0

commit c199a14
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Aug 22 16:40:31 2013 +0100

    make debug for MipWrapper will keep the .o and wrapped .o file so that debug symbols are available.

commit ee75394
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Aug 22 16:39:49 2013 +0100

    is_opt() for MipWrapper.

commit a454e55
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Aug 22 16:00:30 2013 +0100

    Move CPLEX interface to available_interfaces.

commit 6585550
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Aug 22 15:58:03 2013 +0100

    CPLEX interface.

    Squashed commit of the following:
    commit 04886521ec4e479fc0d1a71c794a367e59e25030
    Author: 9thbit <9thbit@gmail.com>
    Date:   Thu Aug 22 15:11:08 2013 +0100

        Remove some debug output.

    commit f5bb15c3968c25dfa7e9fdf42fe7ee75280b6fcb
    Author: 9thbit <9thbit@gmail.com>
    Date:   Thu Aug 22 15:07:53 2013 +0100

        Ability to get and set CPLEX parameters.

        Changed the way expressions are added to the cplex model.

    commit 56647603fa0d05470da48149ebbb0fe67cfaed6b
    Author: 9thbit <9thbit@gmail.com>
    Date:   Thu Aug 22 11:13:29 2013 +0100

        Remove hardcoded paths in CPLEX Makefile in place of a python file that will try to figure it out.

    commit 7b0769267f4cffbe55e0111d7b3cf1e97b0a0380
    Author: 9thbit <9thbit@gmail.com>
    Date:   Thu Aug 22 10:23:46 2013 +0100

        Initial version of CPLEX interface.

        Paths hardcoded in makefile, working on that now.

commit 017018e
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Jul 30 10:11:18 2013 +0100

    -I is not needed before `python-config --cflags`

commit 603c1c1
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Jul 30 10:09:20 2013 +0100

    Change to wildcards in gitignore.

commit e94b9b9
Author: 9thbit <9thbit@gmail.com>
Date:   Tue Jul 30 10:06:39 2013 +0100

    Move ExampleInterface to available_interfaces directory.

commit ce2f1ba
Merge: 2e01ca3 3cd78d7
Author: Barry Hurley <9thbit@gmail.com>
Date:   Mon Jul 29 08:46:56 2013 -0700

    Merge pull request #10 from ten0s/master

    Make sure the local_lib folder is created

commit 3cd78d7
Author: Dmitry Klionsky <d.klionsky@dev.powermemobile.com>
Date:   Wed Jul 17 18:29:35 2013 +0300

    Make sure the local_lib folder is created

commit 2e01ca3
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Jul 4 16:38:44 2013 +0100

    Ability to set thread count for Gurobi.

commit 3fc5f3e
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Jul 4 16:38:26 2013 +0100

    Fix for Gurobi parameter changes not taking effect.

    GRBModel takes a copy of the environment we created, so to change parameters of the environment we need to use model->getEnv() and modify that.

commit 068a56d
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Jul 4 16:35:30 2013 +0100

    In the case of a variable not being created in the interface, return its lower bound.

commit 50343ed
Author: 9thbit <9thbit@gmail.com>
Date:   Wed Jul 3 18:05:37 2013 +0100

    Doc additions to clarify the behaviour of get_value() in cases where the variable is not passed to the solver.

commit 222c9da
Author: 9thbit <9thbit@gmail.com>
Date:   Wed Jul 3 17:54:11 2013 +0100

    Fix for seg fault when calling get_value on a MIP variable that did not need to be added to the model.

    The variable may not be passed to the solver if it is not involved in a non-trivial constraint. get_value() will return the variable's lower bound as the value in this case.

commit 1e9c448
Author: 9thbit <9thbit@gmail.com>
Date:   Wed Jul 3 17:51:30 2013 +0100

    Rename _var to _arg in MipWrapper_neg and abs to avoid name clash with MipWrapper_Expression.

commit 98ed42e
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Jul 1 15:02:52 2013 +0100

    Support for MIP encoding reification of disequality Z == (X != Y).

commit 787285b
Author: 9thbit <9thbit@gmail.com>
Date:   Mon Jul 1 15:01:43 2013 +0100

    Bug fix for MIP encoding of reified equality.

commit 3a20bfd
Author: 9thbit <9thbit@gmail.com>
Date:   Thu Jun 27 15:01:00 2013 +0100

    Add support for MIP encoding of modulus, absolute and negation.

    Squashed commit of the following:

    commit f14c51c9107e7397bba503a686c5721fdc087324
    Author: 9thbit <9thbit@gmail.com>
    Date:   Thu Jun 27 15:00:17 2013 +0100

        Add support for MIP encoding of modulus, absolute and negation.

    commit 3db04bf1235caa60d4ceb3c0cb6b1091976fc64f
    Author: 9thbit <9thbit@gmail.com>
    Date:   Thu Jun 27 14:57:08 2013 +0100

        Small fixes for some debug statements and error output.

commit 8a37c6a
Author: 9thbit <9thbit@gmail.com>
Date:   Fri Jun 21 23:20:36 2013 +0100

    Small bit of tidy in SatWrapper deleting old commented code.

commit b8d2c79
Author: 9thbit <9thbit@gmail.com>
Date:   Fri Jun 21 22:24:23 2013 +0100

    Add error message to get_index_n/p if called without a value list being set.

    This may happen if a LeqDomain domain is created, e.g. (x <= 5) == z, and equal() is called without the order encoding of 'x' being enabled.
    For now, in the unit tests, it will enable the order encoding where needed, but we should find a better solution for parameterized test-cases in future.

commit 464ab4b
Author: 9thbit <9thbit@gmail.com>
Date:   Fri Jun 21 19:38:14 2013 +0100

    Support for SAT encoding of modulus operator.
    Squashed commit of the following:

    commit 3f54a7fd2dca148223fe44b8e7e094e05882dc8a
    Author: 9thbit <9thbit@gmail.com>
    Date:   Fri Jun 21 19:30:41 2013 +0100

        Tests for modulus.

    commit 6943f6777e76557ae8bad835aa3664191bebb66d
    Author: 9thbit <9thbit@gmail.com>
    Date:   Fri Jun 21 19:15:17 2013 +0100

        Support for SAT encoding of modulus in order encoding.

    commit 9ed56caf71a1b75a16d012d74e8dc0ce71535eea
    Author: 9thbit <9thbit@gmail.com>
    Date:   Fri Jun 21 17:08:31 2013 +0100

        Expand mod support to two variables, X % Y == Z. Still just direct and support encoding.

    commit 0eefa7d654b214f2250bb115febb2ce73f5aa1ff
    Author: 9thbit <9thbit@gmail.com>
    Date:   Fri Jun 21 14:47:57 2013 +0100

        Support for SAT encoding (X % value == Z) in direct and support encoding.
  • Loading branch information...
1 parent ff36287 commit 4c746d8df178166499f4aabb47bb14c53bae76f4 @9thbit 9thbit committed Oct 22, 2013
View
@@ -30,13 +30,13 @@ def array_bool_xor(x):
def array_int_element(x, y, z):
# Buggy Workaround, produces invalid values in some optimization cases.
- # aux = Variable(x.lb-1, x.ub-1, "somevar_minus1")
- # return [(z == Element([Variable(e,e,str(e)) if type(e) is int else e for e in y], aux)), (x >= 1), (x <= len(y)), (aux == x - 1)]
-
+ #aux = Variable(x.lb-1, x.ub-1, "somevar_minus1")
+ #return [(z == Element([Variable(e,e,str(e)) if type(e) is int else e for e in y], aux)), (x >= 1), (x <= len(y)), (aux == x - 1)]
+ #return [(z == Element([Variable(e,e,str(e)) if type(e) is int else e for e in y], x - 1)), int_le(1,x), int_le(x,len(y))]
u = set()
for e in y:
u = u | set([e] if type(e) is int else range(e.lb, e.ub + 1))
- return [(x >= 1), (x <= len(y)), set_in(z, u)] + [((z == e) | (x != i+1)) for i, e in enumerate(y)]
+ return [int_le(1,x), int_le(x,len(y)), set_in(z, u)] + [((z == e) | (x != i+1)) for i, e in enumerate(y)]
def array_var_int_element(x,y,z):
return (array_int_element(x,y,z))
@@ -85,15 +85,15 @@ def bool_xor(x, y, z):
return (z == (x != y))
def int_eq(x,y):
- return (x == y)
-'''
+ '''
if (type(y) is int) and issubclass(type(x), Expression) and x.is_var() and y >= x.lb and y <= x.ub:
x.domain_ = None
x.lb = y
x.ub = y
return []
else:
-'''
+ '''
+ return (x == y)
def int_eq_reif(x,y,z):
return (z == (x == y))
@@ -105,13 +105,31 @@ def bool_eq_reif(x, y, z):
return (int_eq_reif(x, y, z))
def int_le(x,y):
- return (x <= y)
+ '''
+ if (type(y) is int) and issubclass(type(x), Expression) and x.is_var() and y >= x.lb: # and (x.domain_ is None)
+ x.ub = min(x.ub, y)
+ return []
+ elif (type(x) is int) and issubclass(type(y), Expression) and y.is_var() and x <= y.ub: # and (y.domain_ is None)
+ y.lb = max(y.lb, x)
+ return []
+ else:
+ '''
+ return (x <= y)
def int_le_reif(x,y,z):
return (z == (x <= y))
def int_lt(x,y):
- return (x < y)
+ '''
+ if (type(y) is int) and issubclass(type(x), Expression) and x.is_var() and y > x.lb: # and (x.domain_ is None)
+ x.ub = min(x.ub, y-1)
+ return []
+ elif (type(x) is int) and issubclass(type(y), Expression) and y.is_var() and x < y.ub: # and (y.domain_ is None)
+ y.lb = max(y.lb, x+1)
+ return []
+ else:
+ '''
+ return (x < y)
def int_lt_reif(x,y,z):
return (z == (x < y))
@@ -123,34 +141,58 @@ def int_ne_reif(x,y,z):
return (z == (x != y))
def int_lin_eq(coef,vars,res):
- return (res == Sum(vars,coef))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_eq(vars[0],res)
+ else:
+ return (res == Sum(vars,coef))
def bool_lin_eq(coef,vars,res):
return (int_lin_eq(coef,vars,res))
def int_lin_eq_reif(coef,vars,res,z):
- return (z == (res == Sum(vars, coef)))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_eq_reif(vars[0],res,z)
+ else:
+ return (z == (res == Sum(vars, coef)))
def int_lin_le(coef,vars,res):
- return (res >= Sum(vars,coef))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_le(vars[0],res)
+ else:
+ return (res >= Sum(vars,coef))
def bool_lin_le(coef,vars,res):
return (int_lin_le(coef,vars,res))
def int_lin_le_reif(coef,vars,res,z):
- return (z == (res >= Sum(vars,coef)))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_le_reif(vars[0],res,z)
+ else:
+ return (z == (res >= Sum(vars,coef)))
def int_lin_lt(coef,vars,res):
- return (res > Sum(vars,coef))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_lt(vars[0],res)
+ else:
+ return (res > Sum(vars,coef))
def int_lin_lt_reif(coef,vars,res,z):
- return (z == (res > Sum(vars,coef)))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_lt_reif(vars[0],res,z)
+ else:
+ return (z == (res > Sum(vars,coef)))
def int_lin_ne(coef,vars,res):
- return (res != Sum(vars,coef))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_ne(vars[0],res)
+ else:
+ return (res != Sum(vars,coef))
def int_lin_ne_reif(coef,vars,res,z):
- return (z == (res != Sum(vars,coef)))
+ if ((len(coef) == 1) and (coef[0] == 1)):
+ return int_ne_reif(vars[0],res,z)
+ else:
+ return (z == (res != Sum(vars,coef)))
def int_abs(x,y):
return (y == Abs(x))
@@ -178,6 +220,11 @@ def int_times(x,y,z):
return (z == (x * y))
def set_in(x,dom):
+ if (type(x) is int):
+ if (not(x in dom)):
+ return [Variable(x,x,str(x)) != x]
+ else:
+ return []
# return (Disjunction([(x == v) for v in dom]))
return [(x != v) for v in range(x.get_min(),1+x.get_max()) if (not(v in dom))]
'''
@@ -264,6 +311,10 @@ def run_solve(model, output_vars, param):
solver.setOption('deadEndElimination',param['dee'])
solver.setOption('btdMode',param['btd'])
solver.setOption('splitClusterMaxSize',param['rds'])
+## uncomment the following lines to save the problem in wcsp format
+# solver.setOption('nopre')
+# solver.setOption('lcLevel',0)
+# solver.setOption("dumpWCSP",2)
if param['solver'] == 'Mistral':
solver.solveAndRestart(param['restart'], param['base'], param['factor'])
else:
View
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+pushd . > /dev/null
+SCRIPT_PATH="${BASH_SOURCE[0]}";
+if ([ -h "${SCRIPT_PATH}" ]) then
+ while([ -h "${SCRIPT_PATH}" ]) do cd `dirname "$SCRIPT_PATH"`; SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done
+fi
+cd `dirname ${SCRIPT_PATH}` > /dev/null
+SCRIPT_PATH=`pwd`;
+popd > /dev/null
+
+MZNNJ_DIR=$SCRIPT_PATH
+
+SED='sed -r'
+if [[ "$(uname)" == "Darwin" ]]; then
+ # The version of sed on Mac has a different option to enable extended regular expressions
+ SED='sed -E'
+fi
+
+param1=${*##*.dzn}
+param=${param1##*.mzn}
+problem=`echo "$*" | $SED 's/ -.*//'`
+mzn2fzn -I ${MZNNJ_DIR}/mznlib --output-to-stdout $problem | ${MZNNJ_DIR}/fzn_numberjack - $param
@@ -1879,7 +1879,7 @@ namespace Mistral {
}
void print(std::ostream& o) const;
void printPython() const;
- void printXML(std::ostream& o) const;
+ // void printXML(std::ostream& o) const;
void printWeightProfile(std::ostream& o, int limit, int t) const;
double getGiniVarCoef() const;
double getGiniConCoef() const;
@@ -2147,6 +2147,13 @@ inline bool ConstraintLex::rule2backward()
bool ConstraintLex::propagate(const int changedIdx, const int e)
{
+
+ /*
+ std::cout << "\npropagate " ;
+ print(std::cout);
+ std::cout << " (change on " << scope[changedIdx]->id << ")\n";
+ */
+
bool consistent = true;
// prunes B[i+1]
@@ -2157,12 +2164,19 @@ bool ConstraintLex::propagate(const int changedIdx, const int e)
)
consistent = false;
+
+ // B[i] == B[i+1] == 0 => x[i] == y[i]
//if(consistent && !scope[2]->max() && !scope[3]->max()) {
if(consistent && !(domain_b1 >> 1) && !(domain_b2 >> 1)) {
consistent = (scope[0]->setDomain(scope[1]) &&
scope[1]->setDomain(scope[0]));
}
+ // // B[i] == 0 => x[i] <= y[i]
+ // if(consistent && !(domain_b1 >> 1)) {
+ // consistent = (scope[0]->setMax())
+ // }
+
// irrelevant part of the vectors
if( consistent && !scope[2]->min() /*&& scope[3]->min()*/ ) {
//if( consistent && !(domain_b1 & 1) /*&& scope[3]->min()*/ ) {
@@ -2219,6 +2233,9 @@ bool ConstraintLex::propagate(const int changedIdx, const int e)
}
}
+ // std::cout << "end propagate ";
+ // print(std::cout);
+
return consistent;
}
@@ -1483,7 +1483,7 @@ DVO::DVO(Solver *s, const int l)
PredicateDisjunctive** DVO::get_disjuncts(Solver *s) { return _garbage_disjuncts; }
PredicateGenDisjunctive** DVO::get_gen_disjuncts(Solver *s) { return _garbage_gen_disjuncts; }
-inline VariableInt* DVONoOrder::select()
+VariableInt* DVONoOrder::select()
{
return *first;
}
@@ -2976,7 +2976,7 @@ void Solver::print(std::ostream& o) const
o << endl;
}
-void Solver::printXML(std::ostream& o) const
+/*void Solver::printXML(std::ostream& o) const
{
int i,j;
@@ -3021,7 +3021,7 @@ void Solver::printXML(std::ostream& o) const
}
cout << "</domains>" << endl << endl;
-}
+}*/
@@ -685,7 +685,7 @@ Mistral_Expression* Mistral_LeqLex::add(MistralSolver *solver, bool top_level) {
scope[i] = _vars.get_item(i)->_self;
}
- _self = CSP::_LexOrder(scope, n, 1);
+ _self = CSP::_LexOrder(scope, n, 0);
if( top_level )
_solver->model->add( _self );
@@ -730,7 +730,7 @@ Mistral_Expression* Mistral_LessLex::add(MistralSolver *solver, bool top_level)
scope[i] = _vars.get_item(i)->_self;
}
- _self = CSP::_LexOrder(scope, n, 0);
+ _self = CSP::_LexOrder(scope, n, 1);
if( top_level )
_solver->model->add( _self );
@@ -1803,6 +1803,7 @@ Mistral::Outcome Mistral::Solver::restart_search(const int root, const bool _res
// std::cout << "[" << std::right << std::setw(33) << "]";
// std::cout.flush();
+
while(satisfiability == UNKNOWN) {
statistics.num_constraints = posted_constraints.size;
@@ -4952,8 +4953,14 @@ void Mistral::Solver::branch_left() {
save();
+ std::cout << sequence << std::endl;
+
+
Mistral::Decision decision = heuristic->branch();
+
+ std::cout << decision << " in " << decision.var.get_domain() << std::endl;
+
reason_for[decision.var.id()] = NULL;
decisions.add(decision);
@@ -122,11 +122,7 @@ class Clause {
// -- use this function instead:
template<class V>
- friend Clause* Clause_new(const V& ps, bool learnt = false) {
- assert(sizeof(Lit) == sizeof(uint32_t));
- assert(sizeof(float) == sizeof(uint32_t));
- void* mem = malloc(sizeof(Clause) + sizeof(uint32_t)*(ps.size()));
- return new (mem) Clause(ps, learnt); }
+ friend Clause* Clause_new(const V& ps, bool learnt = false);
int size () const { return size_etc >> 3; }
void shrink (int i) { assert(i <= size()); size_etc = (((size_etc >> 3) - i) << 3) | (size_etc & 7); }
@@ -149,6 +145,13 @@ class Clause {
void strengthen (Lit p);
};
+template<class V>
+Clause* Clause_new(const V& ps, bool learnt) {
+ assert(sizeof(Lit) == sizeof(uint32_t));
+ assert(sizeof(float) == sizeof(uint32_t));
+ void* mem = malloc(sizeof(Clause) + sizeof(uint32_t)*(ps.size()));
+ return new (mem) Clause(ps, learnt); }
+
/*_________________________________________________________________________________________________
|
@@ -1832,7 +1832,8 @@ class TupleComparitor {
skip one of the indices in the comparison.
*/
public:
- unsigned int skip_index = 0;
+ unsigned int skip_index;
+ TupleComparitor() : skip_index(0) {}
bool operator()(const std::vector<int> *a, const std::vector<int> *b) const {
for(unsigned int i=0; i<a->size() && i<b->size(); i++){
@@ -215,6 +215,7 @@ class WeightedGcc : public DecomposableGlobalCostFunction{
void setBounds(Value value, unsigned int lb, unsigned int ub);
Cost evaluate(int* tuple) { cerr << "Not yet implemented" << endl; return 0; }
+ void rec_sum_counters(WCSP *wcsp, int *scope, int arity, int totlb, int totub, int *counters, int *lb, int *ub, int nb, int rec);
void addToCostFunctionNetwork(WCSP* wcsp);
void display();
};
Oops, something went wrong.

0 comments on commit 4c746d8

Please sign in to comment.