-
Hi, I am trying to implement complex model with a lot of functions in modelx Now I built more than thousands complex functions and tried to open it by modelx. When I directly use terminal to read model, it is working but with GUI, it has error and failed to open. The error message is as follows.
Is there any way to solve the problem? Also, I want to ask if there is a way to read model fast? it takes around 1 minute to open model now, it roughly means it may take more than 10~20 minutes to open final model which is too long for user. I will be appreciate if I can get some help. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I think one possibility is that the model is taking so much time to load, so the MxConsole thinks Python is not responding. Using the Spyder that you're experincing th error, can you check if the model loads in a normal Console (such as >>> import modelx as mx
>>> m = mx.read_model("yourmodel") About the loading speed, is your model saving tables internally? If so, then loading the tables into pandas DataFrame or Series may be taking so much time. |
Beta Was this translation helpful? Give feedback.
-
I made a test model from import modelx as mx
model = mx.read_model("IntegratedLife")
for i in range(200):
model.ProductBase.copy(model, name=f"ProductBase_{i:03}")
model.write("IntegratedLife_200") Then checked how long it took to load: >>> import modelx as mx
>>> import timeit
>>> timeit.timeit("m = mx.read_model('IntegratedLife_200')", number=1, globals=globals())
56.238088199985214 It took less than a minute. So, thre's something specific about your model that's making it open so slow. One way to check it is to profile the loading using Python's standard libraries for profiling: >>> import modelx as mx
>>> import cProfile
>>> import pstats
>>> with cProfile.Profile() as profiler:
... m = mx.read_model("IntegratedLife_200")
>>> stats = pstats.Stats(profiler)
>>> stats.sort_stats(pstats.SortKey.TIME)
>>> stats.print_stats(30) This shows the 30 most time-consiming calls. This information may be helpful to understand what's taking so long in your model.
|
Beta Was this translation helpful? Give feedback.
-
Another approach would be to reduce the number of cells, by changing some of them to pure Python functions put in a Python module, and import the module by new_module. |
Beta Was this translation helpful? Give feedback.
I made a test model from
IntegratedLife
inlifelib.appliedlife
. The ProductBase space has more than 100 cells. I made 200 copies of it so the model has 20,000 cells.Then checked how long it took to load:
It took less than a minute. So, thre's something specific about your model that's making it open so slow.
One way to check it is to profile the loading us…