ariadne-cps / ariadne

C++ framework for rigorous computation on cyber-physical systems
http://www.ariadne-cps.org
GNU General Public License v3.0
28 stars 9 forks source link

Undefined variables in examples #781

Open akaph2p opened 1 month ago

akaph2p commented 1 month ago

Hi,

trying to run the differential_equation_tutorial.py example on WSL (Ubuntu 20.04). I run into this error:

f: [-x0+sin(x0)]
Traceback (most recent call last):

  File "<ipython-input-19-db1b5dee6fb7>", line 1, in <module>
    runfile('/mnt/c/Users/user/OneDrive - University of Pittsburgh/Research/PhD/Software/Ariadne/tutorial.py', wdir='/mnt/c/Users/user/OneDrive - University of Pittsburgh/Research/PhD/Software/Ariadne')

  File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/mnt/c/Users/user/OneDrive - University of Pittsburgh/Research/PhD/Software/Ariadne/tutorial.py", line 53, in <module>
    flow()

  File "/mnt/c/Users/user/OneDrive - University of Pittsburgh/Research/PhD/Software/Ariadne/tutorial.py", line 34, in flow
    domain=BoxDomainType([ (x_(0,x_(2))) ])

NameError: name 'x_' is not defined

Could you provide some guidance? I tried running a different example but a similar issue comes up. Is the python script not importing pyariadne properly?

akaph2p commented 1 month ago

Script

from pyariadne import *

def flow():
    #! Make a function f and compute the flow of the differential equation dx/dt=f(x)
    x=RealVariable("x")
    f=make_function([x],[-x+sin(x)])
    print("f:",f)

    domain=BoxDomainType([ (x_(0,x_(2))) ])
        #!< Specify that the bounds as written are exact double-precision numbers
    step=Dyadic(x_(1.5))
        #!< Specify that the bounds as written are exact double-precision numbers

    #! Solve to a tolerace of 10^-9; time-out after 32 steps
    tolerance=1e-9
    order=12

    integrator = TaylorSeriesIntegrator(tolerance, order)

    #! Solve for the root of g in the given region using the interval Newton method
    phi=integrator.flow_step(f,domain,step)
    print("phi=flow(f):",phi)
    print()

if __name__=='__main__':
    flow()