I see.

Here's something that might be useful to you then: in the git master,
we there is an option to simplify() that let's you use a custom
measure function.  simplify() tries various types of simplifications,
and returns the expression that gives the smallest value according to
the measure function.  By default, this is count_ops(), which gives
the number of operations in the expression.  But you can easily create
a custom function that penalizes branch points (or anything).  See the
docstring of simplify() for an example. The feature was added fairly
recently, and is intended for experimentation, so let us know how it
works for you if you decide to use it.

By the way, if all you want to do is keep track of the fact that the
Symbol is binary, and never really symbolically use this fact, it
would probably be better to just use some naming convention.  As a
simple example, you could always make binary symbols start with the
letter b.  You can easily check this (b.name.startswith('b')).
Depending on what your names are, you might choose something more
complicated, and use re to programmatically parse it out.

Mod is OK too, but it might clutter things up more, especially if you
have very large expressions.  You also could just use Symbol('b',
binary=True).  It won't create .is_binary, but you can easily check
.assumptions0 for it.  Do note though that this last option is based
on internal APIs that might (will) change in the future.

Aaron Meurer

On Fri, Jan 6, 2012 at 11:07 AM, Kevin Hunter <hunt...@gmail.com> wrote:
> For this project, my end goal is to interface a series of Sympy equations
> that I've built to an optimization solver.  In the context of optimization,
> binary variables usually represent a decision, and in the context of
> solving, they represent a "branch" point.  Branch points make it expensive
> to find a solution because each branch is a basically a copy of the problem
> that must be individually solved, and most implementations keep /both/ sub
> problems in memory.  For large optimization problems (on the order of
> millions of variables and millions of equations), even a reduction of a
> single variable or equation can mean huge gains in solve-time.
>
> I'm but human, and the equations I have written may have more room for
> symbolic simplification before I pass them to the solver; this is where I'm
> hoping Sympy can help.  I'll take a look at using the Mod() operation,
> perhaps in it's own pass of the system for each equation that has a binary
> variable.
>
> If you're curious and don't already know about it, here's some "gentle
> reading" in regards to mathematical optimization.  Chapters 12 and
> specifically 13 would be of pertinence.
>
> Practical Optimization: A Gentle Introduction
>
> Thanks for the pointer to Mod().
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/WbtZDllULS0J.
>
> To post to this group, send email to sympy@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to