Attached you find a little sample in which I have written a peace of code in 
which I am trying to subsume my advisors and it is crashing on de second 
subsume invocation... Am I doing something wrong or missing something?

thanks,

David


This message contains information that may be privileged or confidential and is 
the property of Quintiq. It is only intended for the person to whom it is 
addressed. If you are not the intended recipient, you are not authorized to 
read, print, retain, copy, disseminate, distribute or use this message or any 
part thereof. If you have received this message in error, please notify the 
sender immediately and delete all copies of this message. Please note that 
e-mails are susceptible to change, therefore they are not binding.
#include "gecode/kernel.hh"
#include "gecode/int.hh"

namespace Gecode
{
  class MySpace : public Space
  {
  public:
  
    MySpace()
    {
      MX.init(this,0,10);
      MY.init(this,0,1);
    }

    MySpace(bool share, MySpace &s):
      Space(share,s)
    {
       MX.update(this,share,s.MX);
       MY.update(this,share,s.MY);
    }

    MySpace* copy(bool share)
    {
      return new MySpace(share, *this);
    }

    IntVar MX;
    BoolVar MY;
  };

  class MyAdvisor : public Advisor
  {
  public:
    MyAdvisor (Space *home, Propagator *p, Council<MyAdvisor> &c, int index):
     Advisor(home,p,c),
     MIndex(index)
    {
    }
        
    MyAdvisor (Space *home, bool share, MyAdvisor &a):
      Advisor(home,share,a),
      MIndex(a.MIndex)
    {
    }


    int MIndex;
  };

  class MyPropagator : public Propagator
  {
  public:
    MyPropagator(Space *home, IntVar x, BoolVar y):
       Propagator(home),
       MX(x),
       MY(y)
    {
      MX.subscribe(home,new (home) MyAdvisor(home,this,MCouncil,0));
      MY.subscribe(home,new (home) MyAdvisor(home,this,MCouncil,1));
    }

    MyPropagator(Space *home, bool share, MyPropagator& p ):
      Propagator(home,share,p)
    {
      MCouncil.update(home,share,p.MCouncil);   
      MX.update(home,share,p.MX);
      MY.update(home,share,p.MY);
    }

    Gecode::Actor* copy(Gecode::Space* home, bool share)
    {
      return new (home) MyPropagator(home,share,*this);
    }

    ExecStatus propagate(Space *home, ModEventDelta med)
    {
      return ES_OK;
    }

    size_t dispose(Gecode::Space* home)
    {
      MCouncil.dispose(home);

      (void) Propagator::dispose(home);

      return sizeof(*this);
    }

    PropCost cost(ModEventDelta med) const
    {
      return Gecode::PC_BINARY_LO;
    }

    ExecStatus advise(Space *home, Advisor *a, const Delta *d)
    {
      MyAdvisor* padvisor = static_cast<MyAdvisor*>(a);

      if(padvisor->MIndex)
      {
        if( MY.one() )
        {
          return ES_SUBSUMED_FIX(padvisor,home,MCouncil);
        }
      }
      else
      {
        if( MY.one() )
        {
          return ES_SUBSUMED_FIX(padvisor,home,MCouncil);
        }
      }

    }

    Council<MyAdvisor> MCouncil;
    Int::IntView MX;
    Int::BoolView MY;
  };
}

int main()
{
  Gecode::MySpace space;

  new (&space) Gecode::MyPropagator(&space,space.MX,space.MY);

  Gecode::rel(&space,space.MY,Gecode::IRT_EQ,1);
  Gecode::rel(&space,space.MX,Gecode::IRT_EQ,1);
}
_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to