Yup, it seems like quite a simple spec really, doesn't it?

If the first "choice" succeeds (and it could succeed more than once since "Corresp" has its own choice points), then _don't_ try the second choice.

Otherwise succeed using the second choice (which, btw, is unique - no backtracking "choice" points here) _unless_ the previous parse level also used the second choice. (That's the PrevIsNum variable).

A doddle imperatively, but declaratively...? in clp?

Hm...

Hm, I see. If you only need that some solutions imply that some other should be discarded, think of using a "choice penalty" and SearchBest instead of SearchAll.

%% Global counter
ChoicePenaltyCounter=0x4000000
ChoicePenalty={NewCell 0}
ChoicePenaltyVar={FD.decl}
fun {Choose2}
   ChoicePenaltyInc = @ChoicePenaltyCounter
in
   ChoicePenaltyCounter := ChoicePenaltyInc div 2
   choice
      true
   []
      ChoicePenalty := @ChoicePenalty + ChoicePenaltyInc
      ChoicePenaltyVar >=: @ChoicePenalty
      false
   end
end

then turn some of "choice A [] B end" into "if {Choose2} then A else B end" and add ChoicePenalty, ChoicePenaltyVar and ChoicePenaltyCounter to your search Root. Finally add
   {FD.assign min [ChoicePenaltyVar]}
to your search Script and require that each new solution has a lower ChoicePenalty:

proc {Better S1 S2}
   S1.choicePenaltyVar >=: S2.choicePenaltyVar
end

{SearchBest Script Better}

See what I mean?
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to