Re: [eclipse-clp-users] More Info Dynamically Imposing Constraints

From: Joachim Schimpf <joachim.schimpf_at_infotech.monash.edu.au>
Date: Thu, 05 Nov 2009 13:05:22 +1100
Igor Kondrasovas wrote:
> ...
> I decided also to go further and make the following test in a different
> constraint (now performing a multiplication after addition), but its
> seems to be something wrong in the last line when LHS is finally
> constrained. I’m getting a “number expected in set_up_ic_con…†at
> run-time (no messages at compilation).
> 
> (for(K,1,NPieces),fromto(0,LHS1,LHS2,LHS), param(M, PieceLengths) do
> 
>                   LHS2 = LHS1 + M[K,1] * PieceLengths[K]
> 
> ),
> 
> #Something not good here....
> 
> LHS #=< BarsLengths[1],

Yes, sorry, mistake in my example code earlier.  Because LHS is a
symbolic expression (rather than a simple number or numeric variable),
you have to wrap it in eval/1, i.e.

    eval(LHS) #=< BarsLengths[1]


Alternatively, use the list variant I mentioned previously:

    (for(K,1,NPieces), foreach(P,Products), param(M, PieceLengths) do
         P = M[K,1] * PieceLengths[K]
    ),
    sum(Products) #=< BarsLengths[1]


-- Joachim
Received on Thu Nov 05 2009 - 02:05:29 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET