Kish Shen wrote:
> As I have mentioned in my previous posts, I have been rewriting the code for
> handling expressions for the ECLiPSe interface to Gecode. I am wondering if
> there are any performance advantages in different ways of handling certain
> special cases of expressions, like sum.
>
> I had some special code that handled summation of variables using linear:
>
> linear(*solver, vars, rel, sum)
>
> where vars in IntVarArgs, sum is int (although I guess it could be
> generalised to IntVar as well), and rel is IntRelType.
>
> This code does not seem to be used at the moment, I assumed I had it to
> handle some specific ECLiPSe code that I wanted to run quickly with the
> interface.
>
> Instead, such summed expressions are now handled through the general
> expression handling code, and passed to Gecode as a LinRel through minimodel.
> The sum is passed as a series of +, e.g. A+B+C rather than using sum of a
> IntVarArg, because the code was written for Gecode 3.0.2, which I don't think
> supported sum.
>
> Is it more efficient to use the more specialised linear to post such
> expressions, and is it more efficient to use sum in LinExpr rahter than a
> series of +?
The minimodel layer will combine such expressions automatically, and post the
same propagators as when you call linear directly. Of course, there's a small
overhead for the preprocessing of the LinExprs if you use a series of +, but
that should be hardly noticeable in practice.
Cheers,
Guido
--
Guido Tack, http://people.cs.kuleuven.be/~guido.tack/
_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users