Daniel Riera wrote: > Hello, > > I am working in a model where there is a special value, ND (Not > Determined) which > should be considered for every single operation. > I use finite domain constraints but it would be great if it was possible > to redefine every operation > to allow propagations like: > > Given: > > [X,Y,Z]::[0..100,ND], > X + Y #= Z > > Thus, if X or Y is ND, then Z is ND > > The point is that several operations should be redefined. What is the > best way to do this? Hi Daniel! If you have a general behaviour that constraints should have in presence of ND, you could use a variation of the following code: :- lib(fd). :- lib(propia). nd_constr(C):- term_variables(C,Vars), nd_constr(C,Vars) infers fd. nd_constr(_,Vars):- foreach(X,Vars) do X #= nd. nd_constr(C,Vars):- (foreach(X,Vars) do X #\= nd), call(C). I.e., you define the behaviour in case of ND, and use the usual propagation of the constraint when there are no NDs. [eclipse 30]: [X,Y,Z]::[0..100,nd], nd_constr(X+Y#=Z), nd_constr(X#>0). Y = Y{[0..99, nd]} Z = Z{[1..100, nd]} X = X{[1..100, nd]} But maybe this is not what you want, as from your description there seems to be a 'direction' in constraints. E.g., [eclipse 31]: [X,Y,Z]::[0..100,nd], nd_constr(X+Y#=Z), Z=nd. X = nd Y = nd Z = nd Is this what you need? Or do you want NDs to propagate only from X to Z and not vice-versa? Cheers, Marco -- Marco Gavanelli, Ph.D. Computer Science Division Dipartimento di Ingegneria University of Ferrara Via Saragat 1 - 44100 Ferrara (Italy) Tel +39-0532-97-4833 Fax +39-0532-97-4870 http://www.ing.unife.it/docenti/MarcoGavanelli/Received on Thu Apr 26 2007 - 14:54:11 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST