Error max search depth too small

I am getting this error while doing my model verification, compilation string is spin -a tesTdma.pml Max search depth too small, Depth = 9999 states I do not understand the reason behind

I am getting this error while doing my model verification, compilation string is

spin -a tesTdma.pml

Max search depth too small,
Depth = 9999 states

I do not understand the reason behind this error. Did someone came across this using ISPIN ver 1.1.4 and SPIN 6.4.7

asked Dec 12, 2017 at 21:30

Neha's user avatar

It appears that the search depth has been bounded, and you need to increase the bound by passing appropriate options to the generated verifier pan:

-b

bounded search mode, makes it an error to exceed the search depth, triggering and error trail

-mN

set max search depth to N steps (default N=10000)

See the man page of pan,
and also the man page of spin:

-run

Generate the verifier source code in pan.c (like -a does) and immediately compile and execute the verifier. Options that follow the -run argument are passed through to the compiler (options starting with -[ODUE] or to the verifier as runtime flags (all other options). Options to Spin itself should precede the -run argument.

The -run option is useful if you want to pass the options to pan via the call to spin, instead of separately.

Also, from slide 1 on page 27 in these slides:

SPIN displays “error: max search depth too small” to let you know that the depth bound prevented it from searching the complete statespace.

Community's user avatar

answered Dec 12, 2017 at 23:38

0 _'s user avatar

0 _0 _

9,95111 gold badges75 silver badges108 bronze badges

1

Я получаю эту ошибку при проверке моей модели, строка компиляции

spin -a tesTdma.pml

Максимальная глубина поиска слишком мала, Глубина = 9999 состояний

Я не понимаю причину этой ошибки. Кто-нибудь сталкивался с этим, используя ISPIN версии 1.1.4 и SPIN 6.4.7?

1 ответ

Похоже, что глубина поиска была ограничена, и вам нужно увеличить границу, передав соответствующие параметры сгенерированному верификатору pan:

-b

ограниченный режим поиска, делает ошибкой превышение глубины поиска, срабатывание и след ошибки

-mN

установить максимальную глубину поиска на N шагов (по умолчанию N=10000)

См. справочную страницу pan, а также справочная страница spin:

-run

Сгенерируйте исходный код верификатора в pan.c (как это делает -a) и немедленно скомпилируйте и выполните верификатор. Параметры, следующие за аргументом -run, передаются компилятору (параметры, начинающиеся с -[ODUE], или верификатору в качестве флагов времени выполнения (все остальные параметры). Параметры самого Spin должны предшествовать -run. аргумент.

Параметр -run полезен, если вы хотите передать параметры в pan через вызов spin, а не по отдельности.

Кроме того, со слайда 1 на странице 27 в этих слайдах:

SPIN отображает “error: max search depth too small”, чтобы вы знали, что граница глубины не позволяет выполнить поиск по всему пространству состояний.


3

Community
20 Июн 2020 в 12:12

Похоже, что глубина поиска ограничена, и вам нужно увеличить границу, передав соответствующие параметры в сгенерированную pan верификатора:

-b

ограниченный режим поиска, делает ошибку ошибкой превышать глубину поиска, запуск и ошибку

-mN

установите максимальную глубину поиска на N шагов (по умолчанию N = 10000)

См. Справочную страницу pan, а также справочную страницу spin:

-run

Создайте исходный код верификатора в pan.c (например, -a) и немедленно скомпилируйте и выполните верификатор. Параметры, которые следуют за аргументом -run, передаются компилятору (параметры, начинающиеся с -[ODUE] или верификатору в качестве флагов времени выполнения (все остальные параметры). Параметры для самого Spin должны предшествовать аргументу -run.

Опция -run полезна, если вы хотите передать параметры для pan по вызову для spin, а не отдельно.

Кроме того, из слайда 1 на стр. 27 в этих слайдах:

SPIN отображает "error: max search depth too small" чтобы вы знали, что граница глубины помешала ей найти полное пространство состояний.

The maximum recursion depth in Python is 1000.

You can verify this by calling sys.getrecursionlimit() function:

import sys

print(sys.getrecursionlimit()) # Prints 1000

You can change the limit by calling sys.setrecursionlimit() method.

For example:

import sys

print(sys.setrecursionlimit(2000))

Consider this a dangerous action!

If possible, instead of tweaking the recursion limit, try to implement your algorithm iteratively to avoid deep recursion.

Python Maximum Recursion Depth Exceded in Comparison

Whenever you exceed the recursion depth of 1000, you get an error in Python.

For example, if we try to compute a too large Fibonacci number, we get the recursion depth error.

# A function for computing Fibonacci numbers
def fibonacci(n):
   if n <= 1:
       return n
   else:
       return(fibonacci(n-1) + fibonacci(n-2))

# Let's call the 1000th Fibonacci number:
print(fibonacci(1000))

Output:

  File "example.py", line 2, in fibonacci
    if n <= 1:
RecursionError: maximum recursion depth exceeded in comparison

This error says it all—maximum recursion depth exceeded in comparison. This tells you that Python’s recursion depth limit of 1000 is reached.

But why is there such a limit? More importantly, how can you overcome it?

Let’s answer these questions next.

Why Is There a Recursion Depth Limit in Python

A recursive function could call itself indefinitely. In other words, you could end up with an endless loop.

Also, a stack overflow error can occur even if the recursion is not infinite. This can happen due to too big of a stack frame.

In Python, the recursion depth limit takes these risks out of the equation.

Python uses a maximum recursion depth of 1000 to ensure no stack overflow errors and infinite recursions are possible.

This recursion limit is somewhat conservative, but it is reasonable as stack frames can become big in Python.

What Is a Stack Overflow Error in Python

Stack overflow error is usually caused by too deep (or infinite) recursion.

This means a function calls itself so many times that the space needed to store the information related to each call is more than what fits on the stack.

How to Change the Recursion Depth Limit in Python—Danger Zone!

You can change the maximum recursion depth in Python. But consider it a dangerous action.

To do this, call the sys.setrecursionlimit() function.

For example, let’s set the maximum recursion depth to 2000:

import sys

print(sys.setrecursionlimit(2000))

Temporarily Change the Recursion Depth Limit in Python

Do you often need to tweak the recursion depth limit in your project?

If you do, consider using a context manager. This can improve the quality of your code.

For example, let’s implement a context manager that temporarily switches the recursion limit:

import sys

class recursion_depth:
    def __init__(self, limit):
        self.limit = limit
        self.default_limit = sys.getrecursionlimit()

    def __enter__(self):
        sys.setrecursionlimit(self.limit)

    def __exit__(self, type, value, traceback):
        sys.setrecursionlimit(self.default_limit)

Now you can temporarily change the recursion depth to perform a recursive task.

For instance:

with recursion_depth(2000):
    print(fibonacci(1000, 0))

When this operation completes, the context manager automatically switches the recursion depth limit back to the original value.

Learn more about the with statement and context managers in Python here.

Conclusion

The recursion depth limit in Python is by default 1000. You can change it using sys.setrecursionlimit() function.

Thanks for reading. I hope you enjoy it.

Happy coding!

Further Reading

Python Interview Questions and Answers

Useful Advanced Features of Python

Resources

StackOverflow

About the Author

I’m an entrepreneur and a blogger from Finland. My goal is to make coding and tech easier for you with comprehensive guides and reviews.

Recent Posts

Понравилась статья? Поделить с друзьями:
  • Error mass erase operation failed please verify flash protection
  • Error maskrom must choose loader for erasing перевод
  • Error marker find the markers
  • Error mapping types
  • Error manifest merger failed with multiple errors see logs