You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an interesting phenomenon about "zsolve()" in "4ti2" package in SageMath 9.1. Please see the sample codes, which prints the running time of a function zsolve().
from sage.interfaces.four_ti_2 import four_ti_2
import time
A = [[1,1,1],[1,2,3]]
rel = ['<', '<']
rhs = [2, 3]
sign = [1,1,1]
for i in range(1000):
start = time.time()
result=four_ti_2.zsolve(A, rel, rhs, sign)
print("Running time for zsolve in 4ti2:", time.time()-start," sec")
I expected that except for the first iteration, which needs time for loading the library at first time on the memory, all iterations should take statistically consistent time with some noise following a normal distribution. However, the below chart from the output of the above code shows result different than what I expected.
This graph counts from the second iteration to the last iteration. We can observe that the running time is increasing while the operation itself still the same. Since I'm not an expert in programming so unsure that it is an issue of 4ti2 or python, but I hope to know the reason why this phenomenon happens and how to prevent it to minimize its running time.
Try running the Python garbage collector after each iteration and see if this behavior persists.
Thank you for your suggestion. Here is the code using the Garbage collector.
from sage.interfaces.four_ti_2 import four_ti_2
import gc
gc.collect()
import time
A = [[1,1,1],[1,2,3]]
rel = ['<', '<']
rhs = [2, 3]
sign = [1,1,1]
for i in range(1000):
start = time.time()
result=four_ti_2.zsolve(A, rel, rhs, sign)
del result
gc.collect()
print("Time for 4ti2:", time.time()-start," sec")
And again I have a similar graph as below.
For your information, the slope of the linear regression of the above graph is 2.79184e-05, while the slope of the linear regression of the original chart is 2.34818e-05. So using the Garbage Collector make the slope worse than before. I also attached the raw data as CSV file.
Thank you very much for your rapid attention to this problem.
I found an interesting phenomenon about "zsolve()" in "4ti2" package in SageMath 9.1. Please see the sample codes, which prints the running time of a function zsolve().
I expected that except for the first iteration, which needs time for loading the library at first time on the memory, all iterations should take statistically consistent time with some noise following a normal distribution. However, the below chart from the output of the above code shows result different than what I expected.
This graph counts from the second iteration to the last iteration. We can observe that the running time is increasing while the operation itself still the same. Since I'm not an expert in programming so unsure that it is an issue of 4ti2 or python, but I hope to know the reason why this phenomenon happens and how to prevent it to minimize its running time.
Thank you very much for reading this issue.
Byeongsu Yu (byeongsu.yu@math.tamu.edu)
The text was updated successfully, but these errors were encountered: