[gecode-users] Custom branching and Custom Propagator

Christian Schulte cschulte at kth.se
Sun Apr 6 21:57:56 CEST 2008


Did you execute status()? Propagation in Gecode is lazy, only if you execute
status() the propagators will actually run.

 

Christian

 

--

Christian Schulte, www.ict.kth.se/~cschulte/

 

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Debdeep Banerjee
Sent: Saturday, April 05, 2008 3:19 PM
To: Guido Tack
Cc: users at gecode.org
Subject: Re: [gecode-users] Custom branching and Custom Propagator

 

Guido Tack wrote: 

Debdeep Banerjee wrote: 




Hi, 
I am using my own propagator and branching. But when I am using my 
branching ( via post()  method) the propagator is not working. But if I 
use the gecode branching method ( branch() ) then the propagator works. 
I have checked the custom branching.....the methods ( status, 
description , commit ) are called from the DFS Search engine, but the 
propagator did not propagate. 

What would be the reason ? 


Perhaps your propagator does not respond to the modification events
generated by your custom branching, but to those from the standard
branchings.  E.g., the standard INT_VAL_MIN branching always assigns a
variable on the left branch, and that triggers propagators registered for
the PC_INT_VAL propagation condition.  If you registered for PC_INT_VAL, but
your branching does not assign variables (it might only partition the
domain, for instance), then your propagator won't be.  That's just a guess,
of course. 

Guido 

Hi,
  I still couldn't able to find out the problem. So I will give some details
of my code.


My propagator looks like the following

CSPPropagator::CSPPropagator(Gecode::Space* home, ViewIntArray& arr)
  : Gecode::NaryPropagator< Gecode::Int::IntView,
Gecode::Int::PC_INT_VAL>(home, arr)

Where  ==> typedef Gecode::ViewArray<Gecode::Int::IntView> ViewIntArray;

My Branching looks like

CSPBranch::CSPBranch(Gecode::Space* home, ViewIntArray& xv)
      : Gecode::Branching(home)
      , x(xv)
      , pos(-1)
      , val(-1)
    {  }

The commit method looks like

 Gecode::ExecStatus CSPBranch::commit(Gecode::Space* home, const
Gecode::BranchingDesc* b, unsigned int a)
  {
    
    const Gecode::PosValDesc<int,2>* desc = static_cast <const
Gecode::PosValDesc<int,2>* > (b);
    
      
    if (a)
      return Gecode::me_failed(x[desc->pos()].nq(home, desc->val())) ?
Gecode::ES_FAILED : Gecode::ES_OK;
    else
      return Gecode::me_failed(x[desc->pos()].eq(home, desc->val())) ?
Gecode::ES_FAILED : Gecode::ES_OK;
  }

I have a class called " CSPInstance" which extends the Gecode::Space class.
The code inside the constructor has the following line in the respective
order

 Gecode::IntVarArgs arg_array(transitions); [ transitions == >
Gecode::IntVarArray ]

 Gecode::ViewArray<Gecode::Int::IntView> trans_array(this, arg_array);
    
 CSPPropagator::post(this, trans_array);
       
 CSPBranch::post(this, trans_array);


After commit, the propagators are not propagating.

I have attached the three main files with this email. Any help will be
greatly appreciated.



-- 
Debdeep Banerjee
PhD Candidate
CSL/RSISE/NICTA
Australian National University
Email: debdeep.banerjee at rsise.anu.edu.au
Web:http://rsise.anu.edu.au/~banerjed
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20080406/a713d3af/attachment.htm>


More information about the gecode-users mailing list