Closed ghost closed 11 years ago
It is not the network that is not cleaned up, it is the counter that is static for the nodes. to get the same IDs, we could let the user set id's or simply running clear mexfactorgraph
to unload the library
clear mexfactorgraph
will imply a rebuild of the toolbox, right? I think that's too much.
How about this?
ffg.clearNodes(); % clears all nodes from memory (and as result, resets node id)
not, it will not. it will just unload the library from memory
If I do a clear mexfactorgraph
and try to create a new node, then matlab crashes, see image. I'm not sure how you want to do it but as a user, I'd like to be able to delete a network completely and rest or control the id, eg
ffg.clearAllNodes()
or
a = ffg.AddNode('id',1);
ok I will check that on windows (on my machine it works). there can be several networks, so such a function won't help. however we could make the network capable of giving away ids. e.g. a = ffg.AddNode(nwk)
, every node's constructor takes the network as a parameter.
I'm not sure if I get it completely, but
a = ffg.AddNode(nwk)
looks like as if a node is assigned to a network (which is probably a good thing).
Why not this:
nwk = ffg.Network();
a = nwk.AddNode();
and
nwk.delete()
clears the network. Iow, you can only create nodes as part of a network.
Anyway, maybe this is too big a deviation from the issue. I was also thinking of this (but again, probably a large change so let's not do this now; just a thought):
nwk = ffg.createNetwork(); % renamed fft.Network()
a = nwk.createNode('add', <optional name-value pairs>); % rather then a=ffg.AddNode()
b = nwk.createNode('equality');
nwk.createEdge(a,b, <optional name-value pairs>);
and then
nwk.draw();
nwk.delete();
nwk.step();
I really don't like this:
nwk = ffg.Network();
a = nwk.AddNode();
there might be a lot of node types. in general, all the things that you proposed can be done, but they are not OOP-ish
OK, then let's not do them
Before one calls clear mexfactorgraph
, it is absolutely necessary to clear all the variables that were used with it (otherwise when the object is deleted it tries to clear memory that was cleared manually by clear
command).
However, currently I am implementing unique ids among the network, so we should not need to call clear
on a regular basis.
When I run kalmanScheduleExample, I get the graph as shown below. When I run the file again, the id numbers have increased. Apparently, the network is not cleaned up after the example is done. How do I delete a set of nodes or a network. Iow, How do I run
kalmanExample
twice and get teh same id numbers in both cases?