ModelRef_Scalabilit_Windows

advertisement
Microsoft Windows Platform limitation on number of distinct
models in a model reference hierarchy
Microsoft Windows platforms impose a limit on the number of distinct models that can
be referenced by a parent model. The limit is due to command prompt (cmd.exe)
command line string limitation. For details on cmd.exe limitation refer to Microsoft
support at
http://support.microsoft.com/kb/830473
On Windows platforms, simulating referenced models invokes cmd.exe. This is also true
when generating code from referenced models. This is because every model is dependant
on its referenced model’s code. While compiling the code for a model, each of its
dependant referenced model’s code path needs to be included (via –I option). Hence the
compile command is concatenated string of include paths. For large model hierarchies,
the number of dependent models could be large and hence the length of the compile
command string can become very large. When the string length exceeds the limit set by
Windows’ cmd.exe, simulation (or code generation) could error out.
The exact number of models, where the error could occur, varies from one model
hierarchy to another and is dependant on the following
1) The Windows platform version. On Windows XP, the limit is higher than
Windows NT.
2) The length of each referenced model name. For example, if the average model
name length is 25 characters, the limits are approximately 40 distinct models on
Microsoft Windows 2000 and 300 distinct models on Microsoft Windows XP.
3) Whether, the referenced model is configured as One-instance or Multiple-instance.
While the first two factors are easy to understand, the third factor needs a little more
explanation. The next section documents how the instance-setting on the model and
model partitioning contribute to the problem.
Note: The limit does not apply to multiple instances of the same model. For example,
suppose that your model references 50 instances of model A and 75 instances of model B.
In this case, models A and B count as only two against the referenced model limit,
despite the fact that your model references 125 instances of these two models.
Calculating the number of dependant models in a hierarchy
Using find_mdlrefs command in MATLAB one can determine the total number of
distinct referenced models in a model hierarchy. However, for compiling a model, not
every referenced model path needs to be included in the compile command string. For
avoiding the cmd.exe, it is necessary to keep the number of dependant models to a low
number.
A referenced model could either contribute to the list of dependant models or be
independent of the top model. The dependency is decided by
1. The position where it appears in the hierarchy. The referenced models at first
level of hierarchy are always counted as dependant models. You can use
find_mdlrefs to determine the models at first level. You can use the view_mdlrefs
to visualize the entire hierarchy.
2. For each referenced model at the first level, its configuration parameter ‘Total
number of instances allowed per top model’ value affects if the models at other
levels are counted as dependant models. If the setting is “Multiple”, itself and
every model referenced by it is counted as a dependent model for the top model.
If the setting is “One”, as stated earlier, only itself is counted as a dependant
model
3. The top model’s configuration parameter ‘Total number of instances allowed per
top model’ value. Note, this affects only if you are generating code from the top
model. This does not affect
Hence, the number of dependant distinct models is bounded. It can be expressed
mathematically as
FirstLevelModels  DependantModels  AllLevelModels
In the following example hierarchy, for mParent model, the number of referenced models
at first level is “2”: mTop and mTop_fixstep. There are 4 models at other levels. Using
Rules#1 through 3, the number of dependant models would be greater than or equal to 2,
but less than or equal to 6.
Per Rule#2, setting the parameter to "Multiple" forces the next level of models to be
counted as dependant models. In the following table, the effect of the setting is shown for
various settings of models mMid and mMid_fixstep. These models are at the level 2 of
the hierarchy
mMid
setting
mMid_fixstep
setting
Number of other
referenced models
Multiple
Multiple
One
One
Table 1
Multiple
One
Multiple
One
4
3
3
2
Number of
dependant
models
6 (2 + 4)
5 (2 + 3)
5 (2 + 3)
4 (2 + 2)
Models excluded from count of
dependant models
None
mBottom_fixstep,
mBottom
mBottom and mBottom_fixstep
Using the same logic, we can extend the table to the next level of models – mTop and
mTop_fixstep.
mTop setting
mTop_fixstep
setting
Multiple
Multiple
Multiple
One
(assume
mMid_fixstep is
also set to One)
Multiple
One
(assume
mMid is also
set to One)
One
(assume
mMid is also
set to One)
Table 2
One
(assume
mMid_fixstep is
also set to One)
Number of other
referenced
models
4
2
Number of
dependant
models
6 (2 +4)
4 (2 +2)
Models excluded from count of
dependant models
2
4 (2 + 2)
mMid,
mBottom
0
2 ( 2 + 0)
mMid, mMid_fixstep,
mBottom, mBottom_fixstep
None
mMid_fixstep,
mBottom_fixstep
Strategies for creating scalable model reference hierarchies
Given, Microsoft Windows limitation, users have to strategize while creating large model
hierarchies. For successful simulation and code generation, the best strategy is to keep the
number of dependant models to a lowest possible number. Here are some modeling
guidelines which can help
1) For referenced models at any level, exercise judgement when setting a referenced
model’s configuration parameter ‘Total number of instances allowed per top model’
value. If, and only if, it is being re-used elsewhere then set it to “Multiple”. Otherwise,
set it to “One”.
2) For models at first level of hierarchy, try to set the number of instances allowed to
“One”. For models at other levels, set “Multiple” instances only if reusable.
3) If the number of models at first level is very large, split the level into two or more
levels.
Top
Top
B0
B1
Bi
Bj
Ci
Cj
Less Scalable
Bn
Bi
Bj
Ci
Cj
Bz
Ni
Nj
Zi
Zj
More Scalable
Download