Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 18 07:55

    cprudhom on master

    Conditional detection of redund… (compare)

  • Oct 18 07:55
    cprudhom closed #833
  • Oct 15 22:07
    fhermeni opened #833
  • Oct 14 12:53
    cprudhom closed #592
  • Oct 13 15:38

    cprudhom on master

    Update set_version.sh Set setCloneVariableArrayInProp… Remove warnings from Propagatio… and 1 more (compare)

  • Oct 12 07:51
    cprudhom closed #169
  • Oct 12 07:46
    cprudhom closed #238
  • Oct 12 07:46
    cprudhom commented #238
  • Oct 12 07:45
    cprudhom closed #244
  • Oct 12 07:45
    cprudhom closed #325
  • Oct 12 07:43
    cprudhom closed #330
  • Oct 12 07:41
    cprudhom closed #150
  • Oct 12 07:41
    cprudhom commented #150
  • Oct 12 07:39
    cprudhom closed #523
  • Oct 12 07:38
    cprudhom closed #383
  • Oct 12 07:38
    cprudhom commented #383
  • Oct 12 07:37
    cprudhom closed #509
  • Oct 12 07:36
    cprudhom milestoned #434
  • Oct 12 07:36
    cprudhom labeled #434
  • Oct 12 07:36
    cprudhom assigned #434
Charles Prud'homme
@cprudhom
but, your formulation is quite differente since you don’t want subsquence to be a subsequence of sequence (I should have chosen other names)
so I try something
9 4
@bios8086_gitlab
This formulation can give what I want
Is it possible to create a constraint using such code, instead of extending Propagator<IntVar>? If we can, we can directly using the not constraint.
Charles Prud'homme
@cprudhom
but that subsequence, right?
you can but if you look for performances, you will be disappointed
9 4
@bios8086_gitlab

I think so.

4,5,1, --- 3,2,4,5,1,
1,5,4, --- 3,2,1,5,4,
2,5,1, --- 3,4,2,5,1,
1,5,2, --- 3,4,1,5,2,
1,5,3, --- 4,2,1,5,3,
1,5,2, --- 4,3,1,5,2,
2,5,3, --- 4,1,2,5,3,
2,5,1, --- 4,3,2,5,1,
3,5,2, --- 4,1,3,5,2,
3,5,1, --- 4,2,3,5,1,

some solutions
Charles Prud'homme
@cprudhom
Here is my attempt (not tested):
// Collect all values
        IntIterableRangeSet set = new IntIterableRangeSet();
        for (int i = 0; i < sequence.length; i++) {
            set.addAll(sequence[i]);
            if (i < subsequence.length) {
                set.addAll(subsequence[i]);
            }
        }
        IntVar[] allValues = ArrayUtils.concat(sequence, Arrays.stream(set.toArray()).mapToObj(k -> ref().intVar(k)).toArray(IntVar[]::new));
        IntVar[] pos = ref().intVarArray(subsequence.length, 0, allValues.length);
        BoolVar[] lt = ref().boolVarArray(pos.length);
        for (int i = 0; i < subsequence.length; i++) {
            ref().element(subsequence[i], allValues, pos[i], 0).post();
            if (i > 0) {
                ref().reifyXgeY(pos[i - 1], pos[i], lt[i]);
            } else {
                ref().reifyXgtC(pos[0], sequence.length - 1, lt[i]);
            }
        }
        ref().addClausesBoolOrArrayEqualTrue(lt);
9 4
@bios8086_gitlab
I have never used ref() before.
Charles Prud'homme
@cprudhom
replaced it by model
there is a bug
9 4
@bios8086_gitlab
I have to leave, I will test your idea
Charles Prud'homme
@cprudhom
Well, the decomposition of notSubSequence is not straightforward. If I were you, I would rely on SetVar
9 4
@bios8086_gitlab
As far as I can imagine, SetVar cannot handle such a situation
1 2 3
3 2 1 4 5 7
If I use the intersection constraint, [1,2,3] and [3,2,1] will result in the same intersection
Charles Prud'homme
@cprudhom
You are right, the order is important (and I think we already talk about that)
9 4
@bios8086_gitlab
Yes, so SetVar is not useful in our case.
Charles Prud'homme
@cprudhom
// Collect all from sequence
        IntIterableRangeSet values = Arrays.stream(sequence)
                .map(IntIterableRangeSet::new)
                .collect(IntIterableRangeSet::new,
                        IntIterableRangeSet::addAll,
                        IntIterableRangeSet::addAll);
        IntVar[] copySsq = Arrays.stream(subsequence).map(v -> ref().intVar("C_" + v.getName(), values.toArray())).toArray(IntVar[]::new);
        IntVar[] pos = ref().intVarArray("P", subsequence.length, 0, copySsq.length);
        BoolVar[] nq = ref().boolVarArray("nq", subsequence.length);
        BoolVar[] np = ref().boolVarArray("np", subsequence.length-1);
        for (int i = 0; i < subsequence.length; i++) {
            ref().element(copySsq[i], sequence, pos[i], 0).post();
            ref().reifyXneY(subsequence[i], copySsq[i], nq[i]);
            if(i < subsequence.length - 1){
                ref().reifyXgtY(pos[i], pos[i+1], np[i]);
            }
        }
        ref().addClausesBoolOrArrayEqualTrue(ArrayUtils.concat(np, nq));
I think this one is correct
9 4
@bios8086_gitlab
OK. I will test it today
Thanks
By the way, do you think is it possible to apply count or among on SetVar without using auxiliary IntVar[] and Union?
Charles Prud'homme
@cprudhom
Could you be more precise?
Charles Prud'homme
@cprudhom
The last decomposition is not correct
9 4
@bios8086_gitlab
For a SetVar, how do I restrict the number of elements in the SetVar whose value are greater than x?
Charles Prud'homme
@cprudhom
I don’t know :)
9 4
@bios8086_gitlab
@cprudhom Thanks
9 4
@bios8086_gitlab
    Model model = new Model("Two");
    BoolVar g1 = model.boolVar("g1");
    BoolVar g2 = model.boolVar("g2");

    model.addClausesBoolOrArrayEqualTrue(new BoolVar[] {g1,g2});
    model.or(new BoolVar[] {g1,g2}).post();
What is the difference between addClausesBoolOrArrayEqualTrue and Or? I tested them and they give the same result. Could it be that addClausesBoolOrArrayEqualTrue is using SAT solver?
Charles Prud'homme
@cprudhom
That is exactly that
9 4
@bios8086_gitlab
@cprudhom So addClausesBoolOrArrayEqualTrue has better performance?
The implantation of Or uses the sum constraint
9 4
@bios8086_gitlab

What is the purpose of the constraint?

model.lexChainLess(intVars2Long).post();

The above constraint does not filter out any possible permutations. The solution set is not changed, compare to not posting this constraint.

9 4
@bios8086_gitlab
Does Choco have the weights constraints that is defined for SetVar? Gecode (see Page 90 of the user guide) has it.
It works like this way:
For example, the upper bound of the set = {1,3,4,5,7,9}, it's corresponding coefficients is {-1.4.1.1.3.3}
if the set variable is {3,7,9}, then the sum of the set is
4+3+3
9 4
@bios8086_gitlab
@cprudhom I cheeked the link before you gave me. It seems the choco implementation is different from the link. I will check it again.
Charles Prud'homme
@cprudhom
@bios8086_gitlab you are right, there is no weight for setvars (yet?)
@bios8086_gitlab watch out, there are 2 constraints with close names: lexChainLess and lexLess
Axel Kramer
@axkr
@cprudhom I'm trying to implement a converter to choco for "real variables" and found that I need the "ibex" lib for the "Power" operator.
Is it save to replace some Power operations for small integers?
See:
https://github.com/axkr/symja_android_library/blob/a8379420788a5173be19c68fbf9b6a2a8638b78f/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/convert/ChocoConvert.java#L288
Which operators are allowed for a pure Java usage?
1 reply
Saman A. Barakat
@SamanAlias_twitter
Hi, Is there a method in Choco that retrieves unsatisfied/inconsistent constraints in the Choco model?
Fabien Hermenier
@fhermeni
Hello @cprudhom . I discovered the possibility to iterates over the values outside the domain using nextValueOut() but I cannot find the right way to do it. There is an example ?
2 replies
Brecht Derwael
@bderwael_gitlab
@SamanAlias_twitter Yes; Solver#findMinimumConflictingSet
1 reply
thomas-bee
@thomas-bee
In particular circumstances the Choco solver for my scheduling problem has rather poor performance and doesn't find solutions to rather simple cases which can easily be solved by hand. I think I need to adapt the search strategy. Is there a structured approach whereby I can analyze the performance of the search strategy and derive suitable changes (as there is for Optaplanner)
1 reply
Andrés Sánchez
@Drisicus

Hello! We have found a situation where there is a "java.lang.ArrayIndexOutOfBoundsException" while performing a "model.unpost(constraint)" where the constraint has been reified and introduced in another constraint.
Example:
Constraint A = model.arithm(...);
Constraint B = model.arithm(...);
Constraint C = model.arithm(A.reify(), "<=", B.refiy());

model.post(C);
model.solve();

model.unpost(C);
model.unpost(A);
model.unpost(B);

We have created a Git Issue: chocoteam/choco-solver#823

As a workaround we have unpost the propagator constraint
Arrays.stream(A.getPropagators()).filter(Objects::nonNull).map(Propagator::getConstraint).forEach(model::unpost);
Arrays.stream(B.getPropagators()).filter(Objects::nonNull).map(Propagator::getConstraint).forEach(model::unpost);

We think that the "ArrayIndexOutOfBoundsException" is a bug, and maybe there is another way of unposting this constraints or we are missing something.
Thank you!

2 replies
thomas-bee
@thomas-bee
@cprudhom This is what I meant in Optaplanner https://docs.optaplanner.org/8.11.1.Final/optaplanner-docs/html_single/index.html#benchmarker We have a really ridiculously simple scheduling example that can be easily solved by a human being in 5 min, to which Choco sometimes finds a solution in less than a second, and sometimes does not find a solution in 5min, and sure we experiment with SearchStrategies but we don't have a good understanding how to do that in a structured fashion.
Charles Prud'homme
@cprudhom
Personnaly, I use iRace for that type of benchmarking.
https://github.com/cran/irace
Can you have a look and tell me if that could fit your need? If so, I can share some configurations (based on slurm and MiniZinc)
thomas-bee
@thomas-bee
@cprudhom Thanks a lot. Sure we could give irace a try, would be great if you could share configurations
1 reply
Charles Prud'homme
@cprudhom
Sure, I will add the file I override to github
Charles Prud'homme
@cprudhom
Hi, that seems to be related to maven, not choco