sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.21k stars 417 forks source link

Proposal of a DifferentialAlgebra package, relying on the C BLAD libraries #13268

Open 2b5de62a-05ae-46d3-a99b-c6405c33a11e opened 11 years ago

2b5de62a-05ae-46d3-a99b-c6405c33a11e commented 11 years ago

This ticket proposes the inclusion in SAGE of a new package, dedicated to differential algebra.

Introduction

The DifferentialAlgebra Sage package is an analogue of the MAPLE 14 DifferentialAlgebra package. The underlying theory is the differential algebra of Ritt and Kolchin. Its main tool is a simplifier for systems of polynomial differential equations, ordinary or with partial derivatives, called RosenfeldGroebner. It is related to the differential elimination theory. This simplifier decomposes the radical differential ideal I generated by an input system, as an intersection of radical differential ideals presented by regular differential chains (a slight generalization of Ritt characteristic sets). The output permits to test membership in the differential ideal I.

Further developments

Software

The package is written in Cython. The computations are performed by the BLAD libraries (C libraries, 60000 lines, LGPL license). The interface between Sage and BLAD is handled by the BMI library (C library, 10000 lines, LGPL license).

Upstream: BLAD BMI

Installation

After building Sage, install the experimental packages blad and bmi, then run make or make build again, i.e:

make build
SAGE_ROOT=$(pwd) ./local/bin/sage -i blad
SAGE_ROOT=$(pwd) ./local/bin/sage -i bmi
make build

An example

Borrowed from DifferentialAlgebra.pyx, to motivate (hopefully) reviewers.

sage: from sage.libs.blad.DifferentialAlgebra import DifferentialRing, RegularDifferentialChain, BaseFieldExtension
sage: leader,order,rank = var ('leader,order,rank')
sage: derivative = function ('derivative')

This example shows how to build the Henri Michaelis Menten formula by differential elimination. One considers a chemical reaction system describing the enzymatic reaction:

                   k(1)
        E + S  -----------> ES
                   k(-1)
        ES     -----------> E + S
                   k(2)
        ES     -----------> E + P

A substrate S is transformed into a product P, in the presence of an enzyme E. An intermediate complex ES is formed.

sage: t = var('t')
sage: k,F_1,E,S,ES,P = function('k,F_1,E,S,ES,P')
sage: params = [k(-1),k(1),k(2)]
sage: params
[k(-1), k(1), k(2)]

The main assumption is that k(1), k(-1) >> k(2) i.e. that the revertible reaction is much faster than the last one. One performs a quasi-steady state approximation by considering the following differential-algebraic system (it comes from the mass-action law kinetics, replacing the contribution of the fast reactions by an unknown function F_1(t), on the algebraic variety where the fast reaction would equilibrate if they were alone).

sage: syst = [diff(E(t),t) == - F_1(t) + k(2)*ES(t), diff(S(t),t) == - F_1(t), diff (ES(t),t) == - k(2)*ES(t) + F_1(t), diff (P(t),t) == k(2)*ES(t), 0 == k(-1)*E(t)*S(t) - k(1)*ES(t) ]
sage: syst
[D[0](E)(t) == k(2)*ES(t) - F_1(t), D[0](S)(t) == -F_1(t), D[0](ES)(t) == -k(2)*ES(t) + F_1(t), D[0](P)(t) == k(2)*ES(t), 0 == k(-1)*E(t)*S(t) - k(1)*ES(t)]

Differential elimination permits to simplify this DAE. To avoid discussing the possible vanishing of params, one moves them to the base field of the equations.

sage: Field = BaseFieldExtension (generators = params)
sage: Field
differential_field

sage: R = DifferentialRing (derivations = [t], blocks = [F_1, [E,ES,P,S], params], parameters = params)
sage: R
differential_ring

The Rosenfeld-Groebner algorithm considers three cases. The two last ones are degenerate cases.

sage: ideal = R.RosenfeldGroebner (syst, basefield = Field)
sage: ideal
[regular_differential_chain, regular_differential_chain, regular_differential_chain]
sage: [ C.equations (solved = true) for C in ideal ]
[[E(t) == k(1)*ES(t)/(k(-1)*S(t)), D[0](S)(t) == -(k(-1)*k(2)*S(t)^2*ES(t) + k(1)*k(2)*S(t)*ES(t))/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t)), D[0](P)(t) == k(2)*ES(t), D[0](ES)(t) == -k(1)*k(2)*ES(t)^2/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t)), F_1(t) == (k(-1)*k(2)*S(t)^2*ES(t) + k(1)*k(2)*S(t)*ES(t))/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t))], [S(t) == -k(1)/k(-1), ES(t) == 0, E(t) == 0, D[0](P)(t) == 0, F_1(t) == 0], [S(t) == 0, ES(t) == 0, D[0](P)(t) == 0, D[0](E)(t) == 0, F_1(t) == 0]]

The sought equation, below, is not yet the Henri-Michaelis-Menten formula. This is expected, since some minor hypotheses have not yet been taken into account

sage: ideal [0].equations (solved = true, selection = leader == derivative (S(t)))
[D[0](S)(t) == -(k(-1)*k(2)*S(t)^2*ES(t) + k(1)*k(2)*S(t)*ES(t))/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t))]

Let us take them into account. First create two new constants. Put them among params, together with initial values.

sage: K,V_max = var ('K,V_max')
sage: params = [k(-1),k(1),k(2),E(0),ES(0),P(0),S(0),K,V_max]
sage: params
[k(-1), k(1), k(2), E(0), ES(0), P(0), S(0), K, V_max]

sage: R = DifferentialRing (blocks = [F_1, [ES,E,P,S], params], parameters = params, derivations = [t])
sage: R
differential_ring

There are relations among the parameters: initial values supposed to be zero, and equations meant to rename constants.

sage: relations_among_params = RegularDifferentialChain ([P(0) == 0, ES(0) == 0, K == k(1)/k(-1), V_max == k(2)*E(0)], R)
sage: relations_among_params
regular_differential_chain

Coming computations will be performed over a base field defined by generators and relations

sage: Field = BaseFieldExtension (generators = params, relations = relations_among_params)
sage: Field
differential_field

Extend the DAE with linear conservation laws. They could have been computed from the stoichimetry matrix of the chemical system.

sage: newsyst = syst
sage: newsyst.append (E(t) + ES(t) == E(0) + ES(0))
sage: newsyst.append (S(t) + ES(t) + P(t) == S(0) + ES(0) + P(0))
sage: newsyst
[D[0](E)(t) == k(2)*ES(t) - F_1(t), D[0](S)(t) == -F_1(t), D[0](ES)(t) == -k(2)*ES(t) + F_1(t), D[0](P)(t) == k(2)*ES(t), 0 == k(-1)*E(t)*S(t) - k(1)*ES(t), E(t) + ES(t) == E(0) + ES(0), S(t) + ES(t) + P(t) == S(0) + ES(0) + P(0)]

Simplify again. Only one case is left.

sage: ideal = R.RosenfeldGroebner (newsyst, basefield = Field)
sage: ideal
[regular_differential_chain]

To get the traditional Henri-Michaelis-Menten formula, one still needs to neglect the term K*E(0)

sage: ideal[0].equations (solved = true, selection = leader == derivative (S(t)))
[D[0](S)(t) == -(K*V_max*S(t) + V_max*S(t)^2)/(K^2 + K*E(0) + 2*K*S(t) + S(t)^2)]

One can also get it by computing the right hand side of the equation which gives the evolution of the product P

sage: ideal[0].normal_form (diff(P(t),t))
V_max*S(t)/(K + S(t))

CC: @sagetrac-sage-combinat @sagetrac-boulier @burcin @kcrisman @BrentBaccala

Component: packages: optional

Keywords: package, differential algebra, elimination theory

Author: Nicolas M. Thiéry, François Boulier, Charles Bouillaguet

Branch/Commit: public/optional_spkg/differential_algebra-13268 @ 81aef63

Reviewer: Charles Bouillaguet, Karl-Dieter Crisman

Issue created by migration from https://trac.sagemath.org/ticket/13268

2b5de62a-05ae-46d3-a99b-c6405c33a11e commented 11 years ago

Attachment: rebuild.gz

shell script to help building the package

kcrisman commented 11 years ago
comment:1

I assume that this is somewhere in the sage-combinat queue, but just for completeness, if you could put links to an spkg, the other Sage library files needed, etc., that would be great. I'm constantly amazed at what you guys come up with!

2b5de62a-05ae-46d3-a99b-c6405c33a11e commented 11 years ago
comment:2

Replying to @kcrisman:

I assume that this is somewhere in the sage-combinat queue, but just for completeness, if you could put links to an spkg, the other Sage library files needed, etc., that would be great. I'm constantly amazed at what you guys come up with!

The shell script (rebuild) builds two spkg. I thought it was simpler that way.

kcrisman commented 11 years ago
comment:3

I assume that this is somewhere in the sage-combinat queue, but just for completeness, if you could put links to an spkg, the other Sage library files needed, etc., that would be great. I'm constantly amazed at what you guys come up with!

The shell script (rebuild) builds two spkg. I thought it was simpler that way.

Fair enough for those testing, but in the end I think that the release manager is likely (?) to want an actual spkg. For instance, Sage should be buildable without the internet (that is, once it is downloaded or the tarball is otherwise acquired, the internet should not be a dependency).

Also, is this a proposal for an optional spkg?

Finally, you'll almost certainly need to provide the DifferentialAlgebra.pyx file and the changes to setup.py and the module list as a patch.

But you are right that this script would be very convenient for testing, which hopefully some experts in differential algebra will do!

5ef6121f-dfb0-4391-8d2e-bcc9d739ac28 commented 11 years ago
comment:4

Interesting! I'll take a careful look at this in the coming weeks as a possible base for a moving-frames/exterior differential geometry package.

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago
comment:5

I have tried to repackage F. Boulier's code in (what I understand is) the Right Way.

If you want to enjoy the power of the DifferentialAlgebra package, which is yet not-even-optionnal, you have to download the two spkg's, and apply the patch

Note to release manager:

The SPKGs are optional/experimental/whatever but the patch for the Sage library should be merged so that the packages can be used later on

kcrisman commented 11 years ago
comment:6

Pretty minor points, though worth thinking about:

Less minor, I think:

Good luck! Looks cool.

kcrisman commented 11 years ago

Reviewer: Charles Bouillaguet, Karl-Dieter Crisman

kcrisman commented 11 years ago

Author: Nicolas M. Thiéry, François Boulier

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago
comment:8

Patch and spkg's updated. The package was broken since 5.1, but is now fixed.

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,5 @@
+This ticket proposes the inclusion in SAGE of a new package, dedicated to differential algebra.
+
 **Introduction**

 The `DifferentialAlgebra` Sage package is an analogue of the MAPLE 14 `DifferentialAlgebra` package.
@@ -17,10 +19,11 @@
 The computations are performed by the BLAD libraries (C libraries, 60000 lines, LGPL license).
 The interface between Sage and BLAD is handled by the BMI library (C library, 10000 lines, LGPL license).

-**Getting started**

-The attached `rebuild` file is a shell command file which should help to build the whole stuff.
-This file was tested on Linux architectures.
+**Release manager : **
+
+* Make [http://www.lifl.fr/~bouillaguet/download/blad-3.9.spkg](http://www.lifl.fr/~bouillaguet/download/blad-3.9.spkg) an experimental/optional package
+* Apply [attachment: 13268_differential_algebra.patch](https://github.com/sagemath/sage-prod/files/10656030/13268_differential_algebra.patch.gz)

 **An example**

@@ -28,102 +31,126 @@

+``` k(1) E + S -----------> ES k(-1) ES -----------> E + S k(2) ES -----------> E + P

+A substrate S is transformed into a product P, in the presence of an enzyme E. An intermediate complex ES is formed.

+ +sage: t = var('t') +sage: k,F_1,E,S,ES,P = function('k,F_1,E,S,ES,P') +sage: params = [k(-1),k(1),k(2)] +sage: params +[k(-1), k(1), k(2)] + + +The main assumption is that k(1), k(-1) >> k(2) i.e. that the revertible reaction is much faster than the last one. One performs a quasi-steady state approximation by considering the following differential-algebraic system (it comes from the mass-action law kinetics, replacing the contribution of the fast reactions by an unknown function F_1(t), on the algebraic variety where the fast reaction would equilibrate if they were alone). + + +sage: syst = [diff(E(t),t) == - F_1(t) + k(2)*ES(t), diff(S(t),t) == - F_1(t), diff (ES(t),t) == - k(2)*ES(t) + F_1(t), diff (P(t),t) == k(2)*ES(t), 0 == k(-1)*E(t)*S(t) - k(1)*ES(t) ] +sage: syst +[D[0](E)(t) == k(2)*ES(t) - F_1(t), D[0](S)(t) == -F_1(t), D[0](ES)(t) == -k(2)*ES(t) + F_1(t), D[0](P)(t) == k(2)*ES(t), 0 == k(-1)*E(t)*S(t) - k(1)*ES(t)] + + +Differential elimination permits to simplify this DAE. To avoid discussing the possible vanishing of params, one moves them to the base field of the equations. + + +sage: Field = BaseFieldExtension (generators = params) +sage: Field +differential_field + +sage: R = DifferentialRing (derivations = [t], blocks = [F_1, [E,ES,P,S], params], parameters = params) +sage: R +differential_ring + + +The Rosenfeld-Groebner algorithm considers three cases. The two last ones are degenerate cases. + + +sage: ideal = R.RosenfeldGroebner (syst, basefield = Field) +sage: ideal +[regular_differential_chain, regular_differential_chain, regular_differential_chain] +sage: [ C.equations (solved = true) for C in ideal ] +[[E(t) == k(1)*ES(t)/(k(-1)*S(t)), D[0](S)(t) == -(k(-1)*k(2)*S(t)^2*ES(t) + k(1)*k(2)*S(t)*ES(t))/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t)), D[0](P)(t) == k(2)*ES(t), D[0](ES)(t) == -k(1)*k(2)*ES(t)^2/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t)), F_1(t) == (k(-1)*k(2)*S(t)^2*ES(t) + k(1)*k(2)*S(t)*ES(t))/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t))], [S(t) == -k(1)/k(-1), ES(t) == 0, E(t) == 0, D[0](P)(t) == 0, F_1(t) == 0], [S(t) == 0, ES(t) == 0, D[0](P)(t) == 0, D[0](E)(t) == 0, F_1(t) == 0]] + + +The sought equation, below, is not yet the Henri-Michaelis-Menten formula. This is expected, since some minor hypotheses have not yet been taken into account + + +sage: ideal [0].equations (solved = true, selection = leader == derivative (S(t))) +[D[0](S)(t) == -(k(-1)*k(2)*S(t)^2*ES(t) + k(1)*k(2)*S(t)*ES(t))/(k(-1)*S(t)^2 + k(1)*S(t) + k(1)*ES(t))] + + +Let us take them into account. First create two new constants. Put them among params, together with initial values. + + +sage: K,V_max = var ('K,V_max') +sage: params = [k(-1),k(1),k(2),E(0),ES(0),P(0),S(0),K,V_max] +sage: params +[k(-1), k(1), k(2), E(0), ES(0), P(0), S(0), K, V_max] + +sage: R = DifferentialRing (blocks = [F_1, [ES,E,P,S], params], parameters = params, derivations = [t]) +sage: R +differential_ring + + +There are relations among the parameters: initial values supposed to be zero, and equations meant to rename constants. + + +sage: relations_among_params = RegularDifferentialChain ([P(0) == 0, ES(0) == 0, K == k(1)/k(-1), V_max == k(2)*E(0)], R) +sage: relations_among_params +regular_differential_chain + + +Coming computations will be performed over a base field defined by generators and relations + + +sage: Field = BaseFieldExtension (generators = params, relations = relations_among_params) +sage: Field +differential_field +

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

Attachment: 13268_differential_algebra_support_files.patch.gz

Cython library headers for BLAD/BMI

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

Description changed:

--- 
+++ 
@@ -24,6 +24,9 @@

 * Make [http://www.lifl.fr/~bouillaguet/download/blad-3.9.spkg](http://www.lifl.fr/~bouillaguet/download/blad-3.9.spkg) an experimental/optional package
 * Apply [attachment: 13268_differential_algebra.patch](https://github.com/sagemath/sage-prod/files/10656030/13268_differential_algebra.patch.gz)
+* Apply [attachment: 13268_differential_algebra_support_files.patch](https://github.com/sagemath/sage-prod/files/10656027/13268_differential_algebra_support_files.patch.gz)
+* Apply [attachment: 13268_module_list.patch](https://github.com/sagemath/sage-prod/files/10656028/13268_module_list.patch.gz)
+

 **An example**
89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

tell SAGE about the optional package

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

Attachment: 13268_module_list.patch.gz

Attachment: 13268_differential_algebra_reference_manual_update.patch.gz

updates the reference manual

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

Description changed:

--- 
+++ 
@@ -26,6 +26,7 @@
 * Apply [attachment: 13268_differential_algebra.patch](https://github.com/sagemath/sage-prod/files/10656030/13268_differential_algebra.patch.gz)
 * Apply [attachment: 13268_differential_algebra_support_files.patch](https://github.com/sagemath/sage-prod/files/10656027/13268_differential_algebra_support_files.patch.gz)
 * Apply [attachment: 13268_module_list.patch](https://github.com/sagemath/sage-prod/files/10656028/13268_module_list.patch.gz)
+* Apply [attachment: 13268_differential_algebra_reference_manual_update.patch](https://github.com/sagemath/sage-prod/files/10656029/13268_differential_algebra_reference_manual_update.patch.gz)

 **An example**
89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

Changed author from Nicolas M. Thiéry, François Boulier to Nicolas M. Thiéry, François Boulier, Charles Bouillaguet

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 11 years ago

Attachment: 13268_differential_algebra.patch.gz

Actual DifferentialAlgebra Class

vbraun commented 10 years ago
comment:13

The ticket description doesn't have a link to the bmi spkg, is it still needed? Also, has anybody considered reviewing this ticket?

89f39f15-88e8-4e79-9bc0-0739a7fc497c commented 10 years ago
comment:14

Replying to @vbraun:

The ticket description doesn't have a link to the bmi spkg, is it still needed?

I don't think so. I think I updated the spkg to contain both, because it would not make much sense to have both separated.

Also, has anybody considered reviewing this ticket?

I did ask for this several times on the mailing list....

vbraun commented 10 years ago
comment:15

With the switch to git we are really aiming to distribute one upstream tarball for each "spkg" install script if possible. Since the two libraries are distributed separately they should be separate spkgs.

All patches need a commit message, only the first one has one right now.

vbraun commented 10 years ago
comment:16

I'm a bit confused by the code... the DifferentialRing isn't really a ring in the Sage sense (with elements that have ring operations). Am I missing something? The starting point should be a proper differential algebra ring, e.g.

sage: R = DifferentialRing(vars=['x'], functions=['f'])
sage: x = R.var(0)
sage: f = R.function(0)
sage: (2*x*f).parent() is R
True

and perhaps slightly extend the preparser to allow

sage: R.<f(x)> = DifferentialRing()
2b5de62a-05ae-46d3-a99b-c6405c33a11e commented 10 years ago
comment:17

Dear vbraun,

Thank you for your feedback. I really appreciate it.

There are two ways to "view" differential algebra. Either you view it as an algebraic theory and then, you are right, the starting point should be a differential ring (that's the way Ritt and Kolchin books are written). Or you take a more engineering point of view: the starting point is the system of equations to be solved and differential algebra is one tool among others (such as numerical integration, bifurcation theory, ...) to investigate them. It is the point of view which was chosen for the design. Indeed, I believe this point of view is likely to be the most appealing for many scientists.

The ideal scenario could look like this: A Sage user first enters the differential equations he/she wants to study. After many computations, he/she decides that differential algebra might be useful. He/she loads the package and applies its methods over the equations. He/she is very happy not to have convert all the time objects from one data type to another one.

I hope my explanations make sense :-)

All the best, François

vbraun commented 10 years ago
comment:18

OK, fair enough. I'm happy with thinking of it as a tool to simplify differential equations. But then you shouldn't introduce global names like DifferentialRing that are likely to be used at one point for the more abstract ring of differential operators.

In that spirit, it would be nice if the code were organized in the way you describe it verbally. The starting point should be an object that encapsulates the differential system, e.g.

sage: syst = DifferentialAlgebraicSystem(vars=[t], functions=[f,g], parameters=[phi])

And then everything is a method of that object. There you need to decide whether you want DifferentialAlgebraicSystem to be mutable or immutable; In the immutable case the user interface would be

sage: sys_extd = syst.extend_base_field(phi)
sage: sys_reln = sys_extd.add_relation(f(0) == 0)
sage: sys_reln
Differential algebraic system ... over base field RR(phi) with relation f(0) == 0
sage: ideal = sys_reln.Rosenfeld_Groebner()

and if it is mutable you'd have

sage: syst.extend_base_field(phi)
sage: syst.add_relation(f(0) == 0)
sage: syst
Differential algebraic system ... over base field RR(phi) with relation f(0) == 0

Mutable is slightly simpler but also means that you can't cache intermediate results.

In general, your objects should print something more informative than regular_differential_chain. It doesn't necessarily have to print all equations, but enough to see if its trivial or not would be nice.

tscrim commented 9 years ago

Description changed:

--- 
+++ 
@@ -19,14 +19,7 @@
 The computations are performed by the BLAD libraries (C libraries, 60000 lines, LGPL license).
 The interface between Sage and BLAD is handled by the BMI library (C library, 10000 lines, LGPL license).

-
-**Release manager : **
-
-* Make [http://www.lifl.fr/~bouillaguet/download/blad-3.9.spkg](http://www.lifl.fr/~bouillaguet/download/blad-3.9.spkg) an experimental/optional package
-* Apply [attachment: 13268_differential_algebra.patch](https://github.com/sagemath/sage-prod/files/10656030/13268_differential_algebra.patch.gz)
-* Apply [attachment: 13268_differential_algebra_support_files.patch](https://github.com/sagemath/sage-prod/files/10656027/13268_differential_algebra_support_files.patch.gz)
-* Apply [attachment: 13268_module_list.patch](https://github.com/sagemath/sage-prod/files/10656028/13268_module_list.patch.gz)
-* Apply [attachment: 13268_differential_algebra_reference_manual_update.patch](https://github.com/sagemath/sage-prod/files/10656029/13268_differential_algebra_reference_manual_update.patch.gz)
+Upstream: [BLAD](http://www.lifl.fr/~boulier/pmwiki/pmwiki.php?n=Main.BLAD) [BMI](http://www2.lifl.fr/~boulier/pmwiki/pmwiki.php?n=Main.BMI)

 **An example**
tscrim commented 9 years ago

Branch: public/optional_spkg/differential_algebra-13268

tscrim commented 9 years ago

Commit: 1355811

tscrim commented 9 years ago
comment:22

Here's my (first) attempt at a git version. I downloaded the BLAD and BMI tarballs from upstream, renamed them *.tgz -> *.tar.gz, and I was able to install them. However there was no $SAGE_LOCAL/include/bmi.h created, and so either my build or the module_list.py isn't correct. So that's where I'm stuck at right now and I don't know how to proceed.

I agree with Volker in that they should remain as separate patches as it makes our lives easier for inclusion in Sage as the upstream packages are updated. I also am against the global name DifferentialRing as this is ambiguous, so this will need a name change.

I'd love to see this get into Sage as this looks like some cool functionality.


New commits:

545837fTrac ticket 13268: includes the DifferentialAlgebra optional package
5d4f14a13268_differential_algebra_support_files
1355811Initial attempt at adding and linking the spkgs.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

ffb4a2bDifferentialAlgebra: basic changes to make blad/bmi packages build
6c0a9e1DifferentialAlgebra: make DifferentialAlgebra.pyx compile
8a610edMerge tag '8.2' into differential_algebra
cec9c0bDifferentialAlgebra: make DifferentialAlgebra.pyx run without exceptions
73c96aaDifferentialAlgebra: all doctests pass
a18e3c0DifferentialAlgebra: remove old include statements
05e8e5bDifferentialAlgebra: fix bmi's spkg-install
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Changed commit from 1355811 to 05e8e5b

BrentBaccala commented 6 years ago

Description changed:

--- 
+++ 
@@ -21,6 +21,16 @@

 Upstream: [BLAD](http://www.lifl.fr/~boulier/pmwiki/pmwiki.php?n=Main.BLAD) [BMI](http://www2.lifl.fr/~boulier/pmwiki/pmwiki.php?n=Main.BMI)

+**Installation**
+
+After building Sage, install the experimental packages `blad` and `bmi`, then run `make` or `make build` again, i.e:
+
+```
+make build
+SAGE_ROOT=$(pwd) ./local/bin/sage -i blad
+SAGE_ROOT=$(pwd) ./local/bin/sage -i bmi
+make build
+```

 **An example**
BrentBaccala commented 6 years ago
comment:25

Updated to Sage 8.2

I added an Installation section to the ticket description. I think it should be fairly simple now to work with this code, if not, let me know.

I'd also like to see this code in Sage. François Boulier has done a fantastic job with the blad library. I've tried to implement Rosenfeld-Gröbner from scratch, and believe me, François's library is the way to go.

With that said, I do think that this code belongs in sage.rings and not sage.calculus. Regarding the discussion between vbraun and boulier, I come at it from the opposite angle - I'm working in polynomial rings all the time, and find it annoying to have to constantly convert back and forth to the symbolic ring.

So I'm thinking that DifferentialRing should behave a lot like PolynomialRing - it should take a first argument to specify the coefficient field, and implement DifferentialRingElement and probably DifferentialIdeal. We should deal with the situation that François described (the user has created a bunch of equations in the symbolic ring and now wants to use differential algebra tools) by making it easier to move from the symbolic ring to polynomial / differential rings, not by basing DifferentialRing on the symbolic ring (like is done currently).

The code still needs a good bit of work before we mainline it, so I'll try to keep some patches coming on this ticket...

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

5d4f14a13268_differential_algebra_support_files
1355811Initial attempt at adding and linking the spkgs.
ffb4a2bDifferentialAlgebra: basic changes to make blad/bmi packages build
6c0a9e1DifferentialAlgebra: make DifferentialAlgebra.pyx compile
8a610edMerge tag '8.2' into differential_algebra
cec9c0bDifferentialAlgebra: make DifferentialAlgebra.pyx run without exceptions
73c96aaDifferentialAlgebra: all doctests pass
a18e3c0DifferentialAlgebra: remove old include statements
05e8e5bDifferentialAlgebra: fix bmi's spkg-install
b65be15Trac #13268: clean up docstrings
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Changed commit from 05e8e5b to b65be15

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Changed commit from b65be15 to 5cf3d5f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

569f60bTrac #13268: improve printed descriptions of DifferentialRing objects
016abbdTrac #13268: use local name dictionary for parsing BMI expressions
5cf3d5fTrac #13268: improve printed descriptions of RegularDifferentialChain objects
BrentBaccala commented 6 years ago
comment:28

I disowned this ticket, since François Boulier indicated to me via email that he's not working on the Sage package anymore.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

dcb261fTrac #13268: fix docstrings
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Changed commit from 5cf3d5f to dcb261f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

b1b8412Trac #13268: move translate_str inside DifferentialRing
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from dcb261f to b1b8412

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

f8c7f21Merge tag '8.7.rc0' into public/optional_spkg/differential_algebra-13268
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from b1b8412 to f8c7f21

jdemeyer commented 5 years ago
comment:33

Some quick comments about technicalities:

  1. Why do you want these to be experimental packages, as opposed to optional?

  2. To avoid confusion, there should be a direct link to the upstream tarballs easily visible in the ticket description.

  3. You mention dependencies in SPKG.txt while the dependencies files have # no dependencies

  4. The spkg-install files should use the more modern sdh helpers. Look at some other spkg-install files if you don't know what I mean.

  5. Compiling with -Werror is a bad idea: it's likely to break stuff for no good reason.

  6. # This file is automatically generated from the blad header files: if that's true, include the script to autogenerate those files instead of the output of that script.

  7. In a lot of places, you use bytes or char* where you really mean a string. That will break badly on Python 3.

  8. Don't overdo Cython typing: for example, I would write

def __init__(self, derivations=[], blocks=[], parameters=[], notation="D")

instead of

def __init__ (
                self,
                list derivations = [],
                list blocks = [],
                list parameters = [],
                char* notation = BMI_IX_D)
  1. Remove pointless comments or docstrings like # __init__ and """ The destructor """

  2. Use is None instead of == None.

  3. Try to follow PEP 8 style, I find the extra spaces quite annoying: DifferentialRing (derivations = [t], blocks = [u,v]) should be DifferentialRing(derivations=[t], blocks=[u, v]).

  4. raise Exception, message should be raise Exception(message).

  5. What's up with bmi_strings.pyx? Why do you write BMI_IX_undefined instead of just "undefined"?

  6. There shouldn't be indentation here:

EXAMPLES:

    This example shows how to build the Henri Michaelis Menten formula
    by differential elimination. One considers a chemical reaction
    system describing the enzymatic reaction::

Same problem here:

EXAMPLE:

    This example shows how to compute an input/output relation, having
    a nice form, for a compartmental model...

and here:

    The class DifferentialRing implements differential polynomial rings

        Differential rings can be endowed with zero, one or many different
        derivations.
  1. Please use the standard copyright notice.

  2. It's preferred to use # distutils: libraries declarations in Cython files instead of libraries = ["blad", "bmi"] in module_list.py. And the language and depends in module_list.py are not needed as far as I can tell.

  3. from cpython cimport bool is probably not what you want: it refers to the Python bool class. What you probably want to use is bint, which is more like a C boolean (using the C int type).

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

3871c6aMerge tag '8.7' into public/optional_spkg/differential_algebra-13268
81aef63Merge tag '9.0.beta4' into public/optional_spkg/differential_algebra-13268
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from f8c7f21 to 81aef63

9d1e8f33-9c5a-487d-bc38-8944bef1a4ae commented 4 years ago
comment:35

Do we have a TODO list here? I'm debating working on this.

Replying to @BrentBaccala:

Updated to Sage 8.2

I added an Installation section to the ticket description. I think it should be fairly simple now to work with this code, if not, let me know.

I'd also like to see this code in Sage. François Boulier has done a fantastic job with the blad library. I've tried to implement Rosenfeld-Gröbner from scratch, and believe me, François's library is the way to go.

With that said, I do think that this code belongs in sage.rings and not sage.calculus. Regarding the discussion between vbraun and boulier, I come at it from the opposite angle - I'm working in polynomial rings all the time, and find it annoying to have to constantly convert back and forth to the symbolic ring.

So I'm thinking that DifferentialRing should behave a lot like PolynomialRing - it should take a first argument to specify the coefficient field, and implement DifferentialRingElement and probably DifferentialIdeal. We should deal with the situation that François described (the user has created a bunch of equations in the symbolic ring and now wants to use differential algebra tools) by making it easier to move from the symbolic ring to polynomial / differential rings, not by basing DifferentialRing on the symbolic ring (like is done currently).

The code still needs a good bit of work before we mainline it, so I'll try to keep some patches coming on this ticket...

BrentBaccala commented 4 years ago
comment:36

Replying to @tdupu:

Do we have a TODO list here? I'm debating working on this.

I'd think, first, get it running on the newest Sage release, then hit the issues jdemeyer listed a year ago, then look at implementing a DifferentialRing class.

We're both on the U.S. East Coast (I'm in the Washington, DC area), so maybe I'll give you a call at your office and we can talk more about it.

mkoeppe commented 4 years ago
comment:37

Setting spkg proposals that have not seen recent activity to "sage-wishlist".

mkoeppe commented 3 years ago
comment:38

Are BLAD/BMI still maintained upstream?