[sympy] Re: Linear Inequality Simplifier

2020-12-27 Thread samuel....@gmail.com

2020-12-27 10:46:27 UTC:
>
> As part of my final project in my computer science degree I would like
> to develop a class for linear inequalities simplifying. The class's main
> algorithm is that for given a set of linear inequalities in m variables,
> it returns a simplified set. "Simplified" may mean an equivalent set with
> a smallest number of inequalities. As an example, given the inequalities:
>
> x+y≥1
> x+y≤0
>
> the algorithm should return the empty set.

I guess in this case it should rather return the set containing
the single condition 0 > 1 (or 0 == 1) since there is no solution,
while an empty set of constraints allows all values of x and y.

> Given the inequalities:
>
> x+y≥1
> 2x+2y≥3
>
> the algorithm should return e.g.
>
> 2x+2y≥3
>
> The class will also implement operator overloading for +
> (adding one set to another) and – (removing a subset
> from original set) and more.

Note that the solutions to a set of linear inequalities form a polytope;
each inequality describes a half-space; taking the union of two sets
of constraints corresponds to taking the intersection of the polytopes
they describe.

> For this project to work I need to fully understand the implemented
> inequality classes in SymPy which are in sympy.core.relational,
> so I would know how to manipulate SymPy's inequalities.
>
> The problem is that when I am trying to go through the code of those
> classes I get lost. There are so many subclasses there and every
> subclass is inheriting from some other base class.
>
> Is there a way to see a class diagram of those classes so it would be
> more clear what the purpose of each class is?  Does anyone have
> another idea for understanding those classes?

-- 
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/80021f7c-d9c9-4c84-8f20-bb9d45e1103en%40googlegroups.com.


Re: [sympy] Linear Inequality Simplifier

2020-12-27 Thread Oscar Benjamin
‪On Sun, 27 Dec 2020 at 10:46, ‫אוריאל מליחי‬‎  wrote:‬
>
> Hello everyone!

Hi,

> As part of my final project in my computer science degree I would like to 
> develop a class for linear inequalities simplifying.

That sounds like an excellent project. To be clear, are you intending
for this to be incorporated as part of sympy?

Handling systems of inequalities is a feature that is currently
missing from sympy but the most useful way to add it would really be
as a function or several functions rather than a class (although the
function could use a class internally).

> The class's main algorithm is that for given a set of linear inequalities in 
> m variables, it returns a simplified set. "Simplified" may mean an equivalent 
> set with a smallest number of inequalities. As an example, given the 
> inequalities:
>
> x+y≥1
>
> x+y≤0
>
> the algorithm should return the empty set. Given the inequalities:
>
> x+y≥1
>
> 2x+2y≥3
>
> the algorithm should return e.g.
>
> 2x+2y≥3

Or perhaps:

x+y >= 3/2

It would be useful to have a function for making a subset of the
symbols in an inequality become the subject. There already is a
function for this but it doesn't work for systems of inequalities with
multiple unknowns:

In [1]: from sympy.solvers.inequalities import reduce_inequalities

In [2]: ineq = x + y > 2

In [3]: reduce_inequalities(ineq, [x])
Out[3]: x > 2 - y

In [4]: reduce_inequalities(ineq, [y])
Out[4]: y > 2 - x

In [5]: reduce_inequalities([x+y > 2, x < 1], [x, y])
---
NotImplementedError
inequality has more than one symbol of interest.

> The class will also implement operator overloading for + (adding one set to 
> another) and – (removing a subset from original set) and more.

This is already handled by Python's built in set class so it isn't
really necessary to make a class for this. We can just put the
inequalities in a set.

> For this project to work I need to fully understand the implemented 
> inequality classes in SymPy which are in sympy.core.relational, so I would 
> know how to manipulate SymPy's inequalities.
>
> The problem is that when I am trying to go through the code of those classes 
> I get lost. There are so many subclasses there and every subclass is 
> inheriting from some other base class.
>
> Is there a way to see a class diagram of those classes so it would be more 
> clear what the purpose of each class is?  Does anyone have another idea for 
> understanding those classes?

The codebase for sympy is large which means it takes time to
understand. You can see the inheritance scheme for these classes with
mro:

In [6]: LessThan.mro()
Out[6]:
[sympy.core.relational.LessThan,
 sympy.core.relational._Less,
 sympy.core.relational._Inequality,
 sympy.core.relational.Relational,
 sympy.logic.boolalg.Boolean,
 sympy.core.basic.Basic,
 sympy.printing.defaults.Printable,
 sympy.core.evalf.EvalfMixin,
 object]

Here Printable and EvalfMixin are mixins that provide printing support
and make it possible to use .evalf() e.g.:

In [7]: x < pi
Out[7]: x < π

In [8]: _.evalf()
Out[8]: x < 3.14159265358979

Basic is a fundamental class in sympy. Most sympy objects are
instances of Basic. Basic is used to represent mathematical objects as
trees and to implement operations like subs working over those trees.
You can see an explanation of that here:
https://docs.sympy.org/latest/tutorial/manipulation.html
(Surprisingly that page doesn't actually mention Basic!)

Boolean is a subclass of Basic for objects representing boolean
True/False. The Boolean class provides operations like `&` and `|`
representing "and" and "or" (as well as many other operations):

In [9]: (x < pi) & (y < 3)
Out[9]: x < π ∧ y < 3

Relational is a subclass of Boolean and is the common superclass for
LessThan, StrictLessThan, Equality, Unequality, GreaterThan and
StrictGreaterThan representing the 6 types of relation in sympy (`<=,
<, ==, !=, >=, >`).

The classes `_Inequality` and `_Less` are used for sharing/dividing
code between the different inequality classes.

--
Oscar

-- 
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxRZEBdprrsXHOZPndEgRyv2WAcgjmio6WN-i21hxaOAhg%40mail.gmail.com.


[sympy] Introduction to SymPy

2020-12-27 Thread Anoop Gupta
Respected reader,

I am Anoop Gupta, pursuing my B tech.  If anyone could please clarify some 
of my doubts, it would be highly appreciable. 
In any case, if you are willing to help, can you please contact me asap, 
I'd be highly obliged.

Thanking you in advance,
Anoop Gupta

-- 
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/71c43eae-0740-4216-ba54-9f378081570dn%40googlegroups.com.


[sympy] Introduction of Jigar Joshi

2020-12-27 Thread 'JIGAR JOSHI' via sympy
Hey,
   I am Jigar Joshi, a third-year computer science engineering
student from KJ Somaiya college of engineering, Mumbai, India. I will be
spending my upcoming months contributing to this project. I have worked as
a data scientist intern for 1 year and for the past 3 months I am working
as a back-end developer/ data analyst for Vesatogo Innovation.
   I am attaching my LinkedIn profile and GitHub profile (
https://www.linkedin.com/in/jigar-joshi-a520a4183/ ,
https://github.com/JigarJoshi04 ) do check them out. Feel free to connect
with me.

Level of familiarity with python: Advance (3+ yrs industry level experience)
mathematical education level: Engineering level experience
particular expertise: Data structure, analysis of algorithms, probability
particular algorithmic interests: Back-tracking, divide and conquer, greedy
algorithms
level of familiarity with symbolic math systems "computer algebra":
Engineering level algebra
your familiarity with SymPy (e.g. how have you used SymPy): Basic
documentation
other possibly relevant information -- I'm an Indian and apart from English
I speak 3 native languages.

-- 
Regards,

*Jigar Joshi,*

Back-end developer,

Vesatogo Innovations,

Mob:. 9579088663

email:. jigar...@somaiya.edu

-- 
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAPz8jL63FyVh1JyTuNUXSm1j8gQnpnNdkAHXYadHgd%3Du0PUjSQ%40mail.gmail.com.


[sympy] Linear Inequality Simplifier

2020-12-27 Thread אוריאל מליחי


Hello everyone!

As part of my final project in my computer science degree I would like to 
develop a class for linear inequalities simplifying. The class's main 
algorithm is that for given a set of linear inequalities in m variables, it 
returns a simplified set. "Simplified" may mean an equivalent set with a 
smallest number of inequalities. As an example, given the inequalities:

x+y≥1

x+y≤0

the algorithm should return the empty set. Given the inequalities:

x+y≥1

2x+2y≥3

the algorithm should return e.g.

2x+2y≥3

The class will also implement operator overloading for + (adding one set to 
another) and – (removing a subset from original set) and more.

For this project to work I need to fully understand the implemented 
inequality classes in SymPy which are in *sympy.core.relational*, so I 
would know how to manipulate SymPy's inequalities. 

The problem is that when I am trying to go through the code of those 
classes I get lost. There are so many subclasses there and every subclass 
is inheriting from some other base class.

Is there a way to see a class diagram of those classes so it would be more 
clear what the purpose of each class is?  Does anyone have another idea for 
understanding those classes?

-- 
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/26b88a29-785b-49fa-a86a-fb3fa968d428n%40googlegroups.com.