Clp ECLiPSe Prolog Dynamic Constraint

200 Views Asked by At

I have this constraint:

B #> P1*V1 + P2*V2 + P3*V3+ P4*V4 + P5*V5 + P6*V6 +P7*V7 + P8*V8 + P9*V9 + P10*V10

with P=[1,2,3,4,5,6,7,8,9,10] and V=[V1,V2,V3,....], V::0..1

I want implement this constraint in dynamic way with N elements (cardinality of P and V will be N).

If I implement this with a cycle I have problem of instantiation because V is not yet labeled at this point of code.


Solved

I've resolved the question using scalar product B #> P*V implemented directly in CLP.

1

There are 1 best solutions below

1
On

that's an instance of 'scalar product', in ECLiPSe you can find it in Eplex Instances. But I don't understand your problem, V will be labelled when you instruct the system to do, isn't this true ? Then you can post your expressions as usual.