Re: [eclipse-clp-users] A constraint with exponentiation

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Wed, 16 Sep 2009 11:43:01 +1000
liu.yu.senior.china wrote:
> Dear All,
> I have a constraint with exponentiation as follows:
>  :- lib(ic).
> dv(Fs):-
> Fs::[18000,20000,22000,24000],
> Fmax is 24000,
> Fmin is 18000,
> Lamda0 is 1e-6,
> D is 4,
> Si is 1,
> Lamda = Lamda0*10^(D*(Fmax-Fs)/(Fmax-Fmin)),
> Rfmax = exp(-Lamda*1000000/Fmax/1e5),
> Q = (1-Rfmax)^(Si-1),
> eval(Q) $>= -1000.
> Since Rfmax is close to 1 (0.99..) and Si is 1, Q will be 1. So the
> constraint is actually redundent and does not have any effect on Fs.
> However, I get a No as a result. Anything wrong?

Yes, there seems to be a bug in the implementation of exponentiation
that causes failure when the exponent is 0.  I've recorded this at

> My second question is aobut eval/1. By using $>=/2, the goals are
> suspended  before all variables are instantiated. Then why do I have to
> use eval? I get errors without it.
> If I don't use Q to pass the expresson and use eval((1-Rfmax)^(Si-1))
> $>= -1000, I get the same error as I use Q and do not use eval. The
> error is "some constants are expected".

Eval is used to mark variables
- which occur as arguments of constraints in your source code, and
- which, at runtime, will not be numbers or variables, but symbolic expressions

So if you write your constraint as

(1-Rfmax)^(Si-1) $>= -1000

then you have to mark Rfmax, because its value is a symbolic expression.

(1-eval(Rfmax))^(Si-1) $>= -1000

Si on the other hand is just a number and doesn't need marking.

For efficiency, it is best however, to expand the constraint as much
as possible in your source code, because then the system can preprocess
it better at compile time, i.e. in your case

(1-exp(-(Lamda0*10^(D*(Fmax-Fs)/(Fmax-Fmin)))*1000000/Fmax/1e5))^(Si-1) $>= -1000.

-- Joachim
Received on Wed Sep 16 2009 - 02:43:20 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 20 2019 - 09:14:20 CEST