On Mon, Sep 16, 2013 at 5:56 AM, Moritz Beber <[email protected]> wrote:
> Dear all,
>
> My question basically has two parts:
>
> 1.) I have a number of (a few thousand) logical expressions each consisting
> of a handful of symbols (in total there are several thousand symbols as
> well). Currently, I generate a dictionary (let's call it 'big_dict') with
> the symbols and their truth values. Then I loop through each expression and
> evaluate it by calling expr.subs(big_dict). This is painfully slow. I looked
> through the source code for 'subs' a little and saw that it roughly
> translates the dict into an iterable of old, new pairs which it then loops
> through in order to apply replacements. Is there a more efficient way? I
> guess what I could code but actually expect an evaluation of a boolean
> expressions to do is: using the symbols in it, extract the values and solve.

You can try using xreplace, or (I belive) subs(simultaneous=True),
which should only walk the expression tree once.

>
> 2.) Since I have many such expressions, am I missing a way to solve the
> whole system?

I'm not clear what you mean by "solve", but look at simplify_logic()
and satisfiable().

Aaron Meurer

>
> Thank you for your insights,
> Moritz
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to