Hi Kilian,

inserting a branching directly into a space is very easy and doesnt need the wrapper function "branch".

you can do it like that in the constructor of your space:

e.g. for the integer variables

// init the variable array with your vars to branch on
// e.g. (22 vars with vals 0..9):
ints = Gecode::IntVarArray(this, 22, 0, 9);

// create a viewarray of your variables
Gecode::ViewArray<Gecode::Int::IntView>
  iv(this,(Gecode::IntVarArgs)ints);

// create the branching
new (this) Gecode::ViewValBranching< 
              Gecode::Int::IntView,
              int,
              Gecode::Int::Branch::BySizeMin,
              Gecode::Int::Branch::ValMin
            >(this, iv);
// done :)

you only have to create a new branching object with the right template parameters (usually done by the branch-wrapper function). the branching constructure itself registers to your space and thats all.

about your first question: one possibility is to generate a serie of branching objects:

intBranching(i1,i2)
bBranching(b1)
intBranching(i3,i4,i5,i6)
bBrachning...
...

for each you ve got to generate a viewarray of your variable-subset to branch on and construct a branching. you can easily write your own minimal wrapper function that generates these viewarrays.

hope this helps and merry christmas,

Martin


Kilian Sprotte wrote:
Hi,

thinking about how to make gecol at least a little more flexible,
I have some general little questions. :)

As gecol does not allow for subclassing Space
(the SWIG CFFI wrapper creation is not really ready
yet for c++), I am using the following hard-wired problem
space:

class GecolSpace : public Space {
protected:
  IntVarArray  ints;
  BoolVarArray bools;
  SetVarArray  sets;
public:
[...]

I have seen that it is possible to call branch twice -
for example for the ints and then for the bools, in order
to have both of them distributed.

My first question:
If I wanted to consider ints and bools together for branching,
for example giving them a naive predefined, but not regular
ordering like:

i1 i2 b1 i3 i4 i5 i6 b2 b3 i7 b4 b5 b6

Can I put them into an IntVarArgs array and treat them together?

My second question:
If I wanted to add my own ViewSel class....

Do I actually need to change branch in branch.cc
http://www.gecode.org/gecode-doc-latest/int_2branch_8cc-source.html#l00029 ?

and add my own 'case'....

Probably I can just instantiate the ViewValBranching directly?

Sorry for asking this c++ questions, I would be very grateful about a few
words, what the necessary steps are....

Maybe it is more interesting for you what kind of custom
distribution strategy I have in mind.

Lets say my problem has only int vars. I would like to decide the order
of distribution according to the value (if it is already assigned) of another
var that each var points to.
In other words, I conceptually sort my vars according to a key and
then pick the first. There is a (fixed) mapping of each var to another
one that serves for the key. If it is not yet assigned, we could say the
key value was +inf.

This is actually very musically, as e.g. vars representing pitches can be chosen according to their time in the score, which is represented by the start time var of the chord they belong to. :)

I am keeping some good memories of the flexibility of {FD.distribute +Dist +Xv} in Oz.... For experimenting, I am hoping to provide at some point something similar in Lisp,
by using callbacks....

All of this is not so easy for a musician,
but I need to do it :-P

Merry Xmas,

  Kilian


_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to