[Gecode] [Fwd: Re: PowerB]

Gabor Szokoli szokoli at ps.uni-sb.de
Wed Nov 5 10:43:24 CET 2003


Sorry, I just hit "reply" without checking...

-------- Original Message --------
Subject: 	Re: PowerB
Date: 	Wed, 05 Nov 2003 10:08:28 +0100
From: 	Gabor Szokoli <szokoli at ps.uni-sb.de>
To: 	Christian Schulte <schulte at imit.kth.se>
References: 	<003301c3a2fd$c40ba930$360fed82 at mushu>



Christian Schulte wrote:

>>Questions:
>>0,
>>I used the eclipse.org IDE, did it do anything nasty to the 
>>source that 
>>bothers you? (CR/LFs, tabs to spaces, etc)
>>I can try to configure it more, or just ditch it and learn 
>>Emacs :-)
>>    
>>
>
>As I am using Windows, the sources are mistreated anyway.
> 
>  
>
Anyone else see any kind of degradation of coding style they think I 
should address?

>>1, If a propagator wants to replace itself with a 
>>simpler one, do you use 
>>the post functions from the API or create the propagator 
>>instance directly? 2, (dual of 1,) Do you put the "first 
>>time" smartness into the post functions or the 
>>propagator constructors?
>>I mean I've seen it in a post function, but was that by design?
>>    
>>
>
>YOU CAN'T USE THE POST FUNCTIONS FROM THE API! The reason is that they
>actually work on different datastructures for passing arguments.
>
>  
>
Let me just say: Don't make a release in the next few hours until I do a 
checkin... :-))

>The right architecture should be as follows:
> 1. The API function does preprocessing on the arguments, creates the
>appropriate variable arrays to be passed to the propagators proper.
>    The last point happens automatically when implicitly casting a IntArgs
>to VarArray<IntVar>.
>    Then, a propagator-based (maybe a static method) post-method is invoked.
>
> 2. Then the propagator-based post-method decides what is the right
>propagtor (typically some appropriate variant) to create.
>  
>
Is there an existing propagator that has such a method?
If not, what should be its signature?
public static WhateverPropagator::post(VarArray<IntVar> vars) ?
You can still check for variable equality on this level, right?
So this layer 2. propagator-based post-function (PBPF :-) )  is 
responsible for instanciating a propagator if it is indeed a subvariant, 
or call the PBPF of a simpler propagator or one with less arguments if 
apropriate.
Right?

> 3. The propagator constructor does the real job of initializing a
>propagator.
>
>Unfortunately, quite often I have combined 2. and 3. This needs to be fixed
>eventually.
>  
>
I guess I could move all decision logic from plain post functions to 
PBPFs, and get a good overview of all the propagators?

>Now getting back to your real question: Typically, you will go for 3. when
>replacing a propgator. You never go for 1. as you don't want to create new
>variable arrays (they are just resued for the newly created propagator). So,
>in a fixed system you would also have the choice between 2. and 3.
>
>  
>
I'd go with 2 so I don't have to either duplicate its functionality, or 
loose propagatoin power due to undiscovered variable equalities. And 
using the most abstract type possible is so cool anyway :-)

>>3,
>>How would you "cast" an IntVar into a BoolVar?
>>My propagator wants to replace itself with a reified 
>>constraint: 0^b=c  <=>  c=(b==0) 
>>
Guido has told me since:
#define intvar2boolvar(intvar)  static_cast<BoolVar>(intvar.core())

>>5,
>>I know this is a stupid question, maybe I just did not sleep 
>>enough: I don't understand why doing ceil/floor on integer 
>>valued floats works.  
>>Looks like the 100dB amplification of Braun noise to me, but 
>>I'm just an 
>>engineer... ;-)
>>I mean it's pot luck whether floor(ln(4.0)/ln(2.0))  is 1 or 
>>2, right? 
>>
>Yes, might be. But maybe that means you have to resort to exact algorithms
>(integer-based) for log (ld). Why ln to start with?
>  
>
Dunno, it's probably an EE thing, we do everything theoretic in natural 
base. Either 'cause it's one letter less, expresses well "it's not the 
base you want", or easy to derivate :-)
For practical stuff we use base 10.


This one is still open:

> 6, Do you have any preference in unit testing 
> frameworks? Anything against CppUnit?


Gabor








More information about the gecode-users mailing list