Ask Your Question

Mika007's profile - activity

2022-01-14 13:34:52 +0200 received badge  Famous Question (source)
2020-06-26 23:47:17 +0200 received badge  Notable Question (source)
2020-05-09 22:46:14 +0200 asked a question Problems with scipy's optimize

I have a random bug with scipy's optimize . I use it in the context of SageMath 9 (Python 3.7.3). I checked 3 algorithms : shgo, dual_annealing and full_optimize. All don't work well (at all !).

I optimise with a 3 parameters functions with given bounds. The algorithm randomly sends to my error function the "1e-8" value for any of the 3 parameters. I displayed the vector + error to understand it. AS you can see, in this case, the first parameter is 1e-8 whereas it is outside the bounds. Sometimes it happens for the second parameter, or the 3rd ....

[3.95049282e-19 3.03055607e-20 1.96212098e+29] 0.0030238733573031864
[3.95273920e-19 3.05821352e-20 1.90997635e+29] 0.002957956545311753
[3.95037412e-19 3.04080173e-20 1.93312145e+29] 0.0029572689364709224
sage.all_cmdline:33: IntegrationWarning: The occurrence of roundoff error is detected, which prevents 
  the requested tolerance from being achieved.  The error may be 
[1.00000000e-08 3.04080173e-20 1.93312145e+29] 1.0713560755245306
[3.95037412e-19 3.04080173e-20 1.93312145e+29] 0.0029572689364709224

The behaviour is the same for all of them. However the value inserted is not always the same, I noticed 3 : 1e-10, 1e-8 and 1.49011612e-08

Moreover, all do not send nice values. For example, the full_optimize always send values close to the highest bound. Perhaps are the value computed with a simple linear average and I guess it should not be the case.

my bounds are :

bounds = [(1*e,4*e),(0.1*e,0.5*e),(1e5,1e40)]

with e=1.6e-19

Is there an alternative for optimization in sagemath ?

regards, Mike

2020-04-03 20:13:52 +0200 asked a question Cython class : iterate over cdef'ed members

Dear all,

my question is in the title : for some reason it may be usefull to me to iterate over a cdef'ed class cdef'ed members. I inherit from sage.calculus.ode.ode_system for ODE computation.

   cdef class trapModelImporter(sage.calculus.ode.ode_system):
        cdef double ASi, NSi, AGe, NGe, AEr, NEr, BEr, C,BSi, PSi, BAl, PAl, g;

        def setParams(self,pdict):

All the members have default values and I want to customize some of them. The aim of this iteration through the members should be to associate a value from the "pdict" parameter of setParam. This parameter is intended to associate keys which names are Asi, NSi, etc, with their new value. I tried by generating a string and using "exec" but it did not work, i belive it coms from cython itself. I am not sure it is possible that way, but that seemed to be an efficient way to change only the wanted paremeters.

Is that possible ?

Regards, Mike

2020-04-03 20:05:31 +0200 commented answer Interactive plots

Thank you for your answer. I am sorry to answer so late, I wes not notified (for any reason ?) by the site.

2020-04-03 20:05:26 +0200 commented answer Interactive plots

Thank you for your answer. I am sorry to answer so late, I wes not notified (for any reason ?) by the site.

2020-04-03 20:04:25 +0200 received badge  Popular Question (source)
2019-12-10 19:35:46 +0200 received badge  Student (source)
2019-12-10 18:40:48 +0200 asked a question Interactive plots

Dear all,

I am new to Python and sagemath as well, I am however a skilled coder in other languages such as C/C++, Matlab, etc.

I work in a university and we think about switching from matlab to python, and I have found in sagemath a very intersting use of python for scientific computing. I explore the possibilities of python for that purpose. Something that misses in the tries I made is the mouse interactivity with plots (such as zoom for 2d plot or rotation for 3d plot). I used basic Matplotlib. I have read that it is possible with python itself and what limits mouse interactivity seems to come from the web-page orientation of jupyter. I have seen somewhere that in Jupyter, the following : %matplotlib notebook may enable the interactivity. However it does not seem to work in Sagemath.

So I have questions : I want to have interactivity. Is it possible with Matplotlib in Sagemath or is planed for a future version ? Else : may I use another library than Matplotlib, and which one may I use ? My typical needs are large amount of points plotting (experimental data), and 3d plotting.

Best regards, Mike