Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCDDS-core
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPC
SCDDS
SCDDS-core
Commits
20999856
Commit
20999856
authored
3 years ago
by
Federico Felici
Browse files
Options
Downloads
Patches
Plain Diff
Add algorithm topological sorting and change property name
parent
6d731478
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/classes/SCDclass_expcode.m
+49
-20
49 additions, 20 deletions
code/classes/SCDclass_expcode.m
with
49 additions
and
20 deletions
code/classes/SCDclass_expcode.m
+
49
−
20
View file @
20999856
...
...
@@ -26,7 +26,7 @@ classdef SCDclass_expcode
properties
(
SetAccess
=
private
)
name
% Expcode main name
init
objlist
% list of loaded algorithm objects with configured inits
algo
objlist
% list of loaded algorithm objects with configured inits
algonamelist
% List of loaded algorithm names
algoddlist
% list of data dictionaries at algorithm level
mdscontainer
% container class for MDS+ interface objects
...
...
@@ -219,17 +219,22 @@ classdef SCDclass_expcode
% Set configuration settings sldd
SCDconf_setConf
(
'SIM'
)
% carry out any init tasks of algorithms
if
~
isempty
(
obj
.
initobjlist
)
for
ii
=
1
:
numel
(
obj
.
initobjlist
)
obj
.
initobjlist
{
ii
}
.
init
();
opendds
=
Simulink
.
data
.
dictionary
.
getOpenDictionaryPaths
;
% check that tcv.sldd is not opened by some algorithm init
assert
(
~
any
(
contains
(
opendds
,
obj
.
ddname
)),
...
'init for %s leaves %s open - this should be avoided'
,
...
obj
.
initobjlist
{
ii
}
.
getname
,
obj
.
ddname
)
end
if
isempty
(
obj
.
algoobjlist
)
fprintf
(
' no SCD inits to run, done ***\n'
);
return
;
end
% sort initobj list to respect dependencies in refdd parents
obj
=
obj
.
sortalgoobjlist
;
% Carry out any init tasks of algorithms
for
ii
=
1
:
numel
(
obj
.
algoobjlist
)
obj
.
algoobjlist
{
ii
}
.
init
();
opendds
=
Simulink
.
data
.
dictionary
.
getOpenDictionaryPaths
;
% check that tcv.sldd is not opened by some algorithm init
assert
(
~
any
(
contains
(
opendds
,
obj
.
ddname
)),
...
'init for %s leaves %s open - this should be avoided'
,
...
obj
.
algoobjlist
{
ii
}
.
getname
,
obj
.
ddname
)
end
fprintf
(
'\n** DONE WITH ALL SCDINITS **\n'
);
end
...
...
@@ -375,7 +380,7 @@ classdef SCDclass_expcode
fprintf
(
'* Configured MDS tunparams objects: %d (use printparameters method for details)\n'
,
obj
.
mdscontainer
.
numparams
);
fprintf
(
'* Configured MDS wavegens objects: %d (use printwavegens method for details)\n'
,
obj
.
mdscontainer
.
numwavegens
);
fprintf
(
'* Configured general purpose tasks: %d (use printtasks method for details)\n'
,
obj
.
taskcontainer
.
numtasks
);
fprintf
(
'* Configured init scripts: %d (use printinits method for details)\n'
,
numel
(
obj
.
init
objlist
));
fprintf
(
'* Configured init scripts: %d (use printinits method for details)\n'
,
numel
(
obj
.
algo
objlist
));
end
function
printtasks
(
obj
)
...
...
@@ -387,9 +392,9 @@ classdef SCDclass_expcode
% but only if fpinits will stay ...
fprintf
(
'* Configured std init scripts:\n'
);
if
(
~
isempty
(
obj
.
init
objlist
))
for
ii
=
1
:
numel
(
obj
.
init
objlist
)
[
stdinitstmp
,
~
]
=
obj
.
init
objlist
{
ii
}
.
getinits
;
if
(
~
isempty
(
obj
.
algo
objlist
))
for
ii
=
1
:
numel
(
obj
.
algo
objlist
)
[
stdinitstmp
,
~
]
=
obj
.
algo
objlist
{
ii
}
.
getinits
;
if
~
isempty
(
stdinitstmp
)
for
jj
=
1
:
numel
(
stdinitstmp
)
fprintf
(
' %s\n'
,
char
(
stdinitstmp
{
jj
}));
...
...
@@ -520,10 +525,10 @@ classdef SCDclass_expcode
% Importing inits
[
stdinitstmp
,
fpinitstmp
]
=
algoObj
.
getinits
;
if
(
numel
(
fpinitstmp
)
>
0
)
if
numel
(
fpinitstmp
)
>
0
toadd
=
ones
(
numel
(
fpinitstmp
),
1
);
for
ii
=
1
:
numel
(
fpinitstmp
)
if
(
~
isempty
(
obj
.
fpinits
)
)
if
~
isempty
(
obj
.
fpinits
)
for
jj
=
1
:
numel
(
obj
.
fpinits
)
for
kk
=
1
:
numel
(
obj
.
fpinits
{
jj
}{
2
})
if
(
strcmp
(
char
(
obj
.
fpinits
{
jj
}{
2
}{
kk
}),
fpinitstmp
{
ii
}{
2
}))
...
...
@@ -541,11 +546,35 @@ classdef SCDclass_expcode
end
end
if
any
(
toadd
)
% if any inits from this algoobj were taken
obj
.
init
objlist
{
end
+
1
}
=
algoObj
;
%% Add the full algorithm object here, to see if it is fine
obj
.
algo
objlist
{
end
+
1
}
=
algoObj
;
%% Add the full algorithm object here, to see if it is fine
end
elseif
(
numel
(
stdinitstmp
)
>
0
)
obj
.
initobjlist
{
end
+
1
}
=
algoObj
;
obj
.
algoobjlist
{
end
+
1
}
=
algoObj
;
end
end
function
obj
=
sortalgoobjlist
(
obj
)
% sort algoobj list such that ones without dependency on others
% (through parents of referenced data dictionaries) come first.
A
=
zeros
(
numel
(
obj
.
algoobjlist
));
% init adiadency matrix
for
ii
=
1
:
numel
(
obj
.
algoobjlist
)
myalgoobj
=
obj
.
algoobjlist
{
ii
};
[
~
,
refddparent
]
=
myalgoobj
.
getrefdd
;
if
isempty
(
refddparent
)
||
all
(
cellfun
(
@
isempty
,
refddparent
))
A
(:,
ii
)
=
0
;
% no dependency
else
% populate dependencies
% indices of dependent algos
for
iref
=
1
:
numel
(
refddparent
)
% index of this referenced parent algo in algoobjlist
jj
=
contains
(
obj
.
algonamelist
,
refddparent
{
iref
}
.
getname
);
A
(
jj
,
ii
)
=
1
;
end
end
end
D
=
digraph
(
A
);
% directed graph
isort
=
toposort
(
D
);
% topological sorting
obj
.
algoobjlist
=
obj
.
algoobjlist
(
isort
);
% sort the init obj list
end
function
out
=
getexportedtps
(
obj
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment