Well here is exactly what I want to do:

I have a class inheriting Space

class CSPSubset : Space{

        SetVar S;       
        IntVar C;

        CSPSubset(...) {
                
                post some constraints on S and C
        }
        
        CSPSubset(bool share, CSPSubset& csps) 
          : Space(share,csps)
        {
                S.update(this, share, csps.S);
                C.update(this, share, csps.C);
        }

        Actor* copy(..)...


        ...
};

The fact is that this CSP is only partial. I want to let an external
user to specify more constraints on S and C. Of course, I could ask the
user to extend CSPSubset, but I have several classes like CSPSubset
using SetVar S that I must constrain as the user wants. And I don't want
to ask the user to write one class extending each CSP I wrote. 

Thus what I would like, is that the user would write a class like

class SVconstrainer {

        //eventually some IntVar and SetVar
        SetVar S1, S2;

        IntVar Tmp;

        constrain( Space *home, SetVar S, IntVar C){

                // post of some propagators
                cardinality(home, S , 1 , 3);
                rel(home, S1, SRT_NEQ, S);

                weight(home, .., .., S, C);

                ...
        }

        SVConstrainer (Space *home, bool share, SVconstrainer& svc){
                S1.update(home, share, svc.S1);
                S2.update(home, share, svc.S2;
                Tmp.update(home, sharfe, svc.Tmp);
        }
};

And then CSPSubset would look like as


class CSPSubset : Space{

        SetVar S;       
        IntVar C;

        SVconstrainer sv;

        CSPSubset(SVconstrainer svc) {
                
                post some constraints on S and C
        
                svc.constrain(this, S, C);

                sv = svc;
                
        }
        
        CSPSubset(bool share, CSPSubset& csps) 
          : Space(share,csps), sv(this, share, csps.sv)
        {
                S.update(this, share, csps.S);
                C.update(this, share, csps.C);
        }

        Actor* copy(..)...


        ...
};      
        
Hope this is precise enough. Because I am designing a global constraint,
I need that in order to have a nice interface with the user that will
use it.

Thanks in advance.

Cheers,

sebastien


Le mercredi 16 mai 2007 à 10:28 +0200, Christian Schulte a écrit :
> Still, you need to be more detailled. What is clear, you need to follow a
> structure where your variables are updated, check the examples that tell you
> how to. So, whatever you do, you must inherit from a Space, maintain the
> variables you want to use in that space and update your variables through
> that space.
> 
> Christian
> 
> --
> Christian Schulte, http://www.imit.kth.se/~schulte/ 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Sébastien Mouthuy
> Sent: Wednesday, May 16, 2007 8:51 AM
> To: Guido Tack
> Cc: [EMAIL PROTECTED]
> Subject: Re: [gecode-users] (no subject)
> 
> 
> 
> 
> 
> 
> 
> Le mercredi 16 mai 2007 à 07:57 +0200, Guido Tack a écrit :
> > Hi.
> > 
> > Sébastien Mouthuy wrote:
> > 
> > > I want to create a class with a static function that could post 
> > > propagators on a SetVar. i.e. something like [...]
> > >
> > > I tried this but it seems not to work.
> > 
> > What exactly do you mean by "does not work"? Does it crash, or do you
> > simply not get the result you expect? 
> I don't get the result I expected, like variables not updated, somethong
> strange...
> 
> > What is the context, from where
> > do you call "constrainSetVar"?
> 
> I want to write a generic CSP with some SetVar (this is easy). But I want an
> external user to be able to post constraints on these SetVar (this is the
> problem). Thus my generic CSP should be able to call a function (given by
> template or parameter) that will post propagators on some SetVar.
> 
> I would also need a way to update SetVar when copying. I cannot simply
> extends the class defining the generic CSP, because I have several generic
> CSP that need to constraint SetVar in the same way (specified by the user).
> 
> Thanks in advance,
> 
> sebastien
> > 
> > Cheers,
> >     Guido
> > 
> 
> 
> _______________________________________________
> Gecode users mailing list
> [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users
> 


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

Reply via email to