Matlab revisited: Work with large model
-
- Member
- Posts: 36
- Joined: Fri Aug 20, 2010 11:03 am
Matlab revisited: Work with large model
I opened a new thread since the other one meanwhile covers different subjects.
(For those who read my questions according Win7: I'm working with the WinXP-Computer again right now.)
Loading models into matlab, setting and getting variables does work in general. However, when I try to work with a certain very large an complex model, I face problems:
Loading the model works. Getting variables sometimes works as well, but other times it takes minutes to display the value. The same with setting values.
Trying to start a simulation produces the error: "Model has errors and cannot be simulated", although it does not have errors and can easily be simulated from within Vensim.
That's the main problem, because I cannot run my matlab programs without starting a simulation.
Can you offer any help here?
[Edited on 9-9-2010 by arraywanted]
(For those who read my questions according Win7: I'm working with the WinXP-Computer again right now.)
Loading models into matlab, setting and getting variables does work in general. However, when I try to work with a certain very large an complex model, I face problems:
Loading the model works. Getting variables sometimes works as well, but other times it takes minutes to display the value. The same with setting values.
Trying to start a simulation produces the error: "Model has errors and cannot be simulated", although it does not have errors and can easily be simulated from within Vensim.
That's the main problem, because I cannot run my matlab programs without starting a simulation.
Can you offer any help here?
[Edited on 9-9-2010 by arraywanted]
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Member
- Posts: 36
- Joined: Fri Aug 20, 2010 11:03 am
Yes, I am sure. It is the right model and all needed excel files are in the same directory.
I should add that once or twice I was actually able to run a simulation. Other times I get the mentioned error. And sometimes (quite often) matlab simply freezes and does nothing, in which case I have to manually close matlab using the task manager.
Of course I didn't change the model in between.
I should add that once or twice I was actually able to run a simulation. Other times I get the mentioned error. And sometimes (quite often) matlab simply freezes and does nothing, in which case I have to manually close matlab using the task manager.
Of course I didn't change the model in between.
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
The message you are getting occurs when a flag indicating that the model can be simulated has not been set. I can think of only two reasons you would get it.
1. Somehow the model was not checked when it was published. This should not happen, but you can test this by doing first a Model>Check Model and then File>Publish to see if it makes a difference.
2. Somehow the model is being corrupted when it is read. If, as suggested above, you can test the model using, for example, the Excel example, it should give some indication of what is happening.
1. Somehow the model was not checked when it was published. This should not happen, but you can test this by doing first a Model>Check Model and then File>Publish to see if it makes a difference.
2. Somehow the model is being corrupted when it is read. If, as suggested above, you can test the model using, for example, the Excel example, it should give some indication of what is happening.
-
- Member
- Posts: 36
- Joined: Fri Aug 20, 2010 11:03 am
Meanwhile, I'm not getting the "model cannot be simulated"-error anymore. The situation is:
Directly after booting the computer calling vensim functions works just finde. But after a short time, everything slows down and it takes minutes just to retrieve one value. At some time matlab simply seems to freeze when starting a simulation - which worked at the beginning.
I really can't make sense of that behavior.
(By the way, I'm not responsible for the build-up of that model, so these warnings aren't my fault.)
Um, I didn't really understand what you meant by "get it working in VB or VBA, and then port it to Matlab".
[Edited on 9-13-2010 by arraywanted]
Directly after booting the computer calling vensim functions works just finde. But after a short time, everything slows down and it takes minutes just to retrieve one value. At some time matlab simply seems to freeze when starting a simulation - which worked at the beginning.
I really can't make sense of that behavior.
There are no errors in the model, but there are a lot of warnings of the kind "Variable X is not used in the model". I found out that the vensim.err file is full of these warnings. Could that have anything to do with my problem?Somehow the model was not checked when it was published. This should not happen, but you can test this by doing first a Model>Check Model and then File>Publish to see if it makes a difference.
(By the way, I'm not responsible for the build-up of that model, so these warnings aren't my fault.)
Um, I didn't really understand what you meant by "get it working in VB or VBA, and then port it to Matlab".
[Edited on 9-13-2010 by arraywanted]
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
-
- Member
- Posts: 36
- Joined: Fri Aug 20, 2010 11:03 am
The process consuming up to 99% of CPU is a process called "system idle process". (I don't know if that is the exact translation, in german it is "Leerlaufprozess".)If you open the windows task manager you may be able to track down what process is consuming the memory.
What does that mean? I don't know much about these things.
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Member
- Posts: 36
- Joined: Fri Aug 20, 2010 11:03 am
I discovered something new:
The model reads some data from excel files. I found out that I have to close all excel files before starting a new simulation from matlab, because otherwise the freezing happens.
That's why it worked right after booting the system, because then the excel files were closed.
What I still don't know is why it sometimes takes very long to retrieve variables.
The model reads some data from excel files. I found out that I have to close all excel files before starting a new simulation from matlab, because otherwise the freezing happens.
That's why it worked right after booting the system, because then the excel files were closed.
What I still don't know is why it sometimes takes very long to retrieve variables.
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
It sounds like Matlab may be interfering with interprocess communication. You can experiment with using DDE instead of OLE for this comunication (you will need to issue a SPECIAL>READINI command to do this). The setting in the .ini file is
XlsOptions=82,67,0,0,
for OLE
XlsOptions=82,67,0,1,
for DDE and
XlsOptions=82,67,0,2
for direct read (won't work with xlsx or named ranges). this assumes you are using 5.10 or higher.
XlsOptions=82,67,0,0,
for OLE
XlsOptions=82,67,0,1,
for DDE and
XlsOptions=82,67,0,2
for direct read (won't work with xlsx or named ranges). this assumes you are using 5.10 or higher.