Submodels

<< Click to Display Table of Contents >>

Navigation:  Using SMILE Wrappers >

Submodels

For user interface purposes and to make complex network structures easier to understand and navigate, nodes can be organized into a hierarchy of submodels. Every network contains at least one main submodel, which cannot be deleted and serves as the default container for new nodes. Additional submodels can be added or deleted as needed. Each submodel (except the main submodel) has exactly one parent submodel and may have multiple child submodels, allowing for flexible hierarchical organization of nodes. Assigning a node to a submodel does not affect its behavior in inference calculations.

Each submodel in a network has both a numeric handle and a textual identifier. The submodel handle is a non-negative integer that uniquely identifies the submodel within the network, similar to node handles. However, submodel handles and node handles exist in separate namespaces—this means that a submodel and a node can share the same numeric value without conflict. The textual identifier of a submodel is unique within the network and persistent across network I/O operations. It can be specified when the submodel is created and can be modified later using the corresponding API methods. You can convert between a submodel’s identifier and its handle using the appropriate Network.get_submodel method.

All methods that operate on submodels accept either the numeric handle or the textual identifier. Methods using identifiers may involve a string lookup, while methods using handles perform direct access.

When a submodel is deleted, its nodes and child submodels are transferred to the parent submodel, preserving the structure of the network.

Use the following methods to manage submodels:

Python

get_submodel(id: str) -> int

get_main_submodel() -> int

get_main_submodel_id() -> str

get_submodel_count() -> int

get_first_submodel() -> int

get_next_submodel(handle: int) -> int

add_submodel(parent: int | str, id: str) -> int

delete_submodel(submodel: int | str) -> None

set_submodel_id(submodel: int | str, id: str) -> None

get_submodel_id(submodel: int | str) -> str

set_submodel_name(submodel: int | str, name: str) -> None

get_submodel_name(submodel: int | str) -> str

set_submodel_description(submodel: int | str, description: str) -> None

get_submodel_description(submodel: int | str) -> str

set_submodel_of_node(submodel: int | str, node: int | str) -> None

set_submodel_of_submodel(parent: int | str, child: int | str) -> None

get_submodel_of_node(node: int | str) -> int

get_submodel_of_submodel(submodel: int | str) -> int

get_submodel_position(submodel: int | str) -> List[int]

set_submodel_position(submodel: int | str, x: int, y: int, width: int, height: int) -> None

set_submodel_position(submodel: int | str, rect: List[int]) -> None

Java

int getSubmodel(String id); 

int getMainSubmodel(); 

String getMainSubmodelId(); 

int getSubmodelCount(); 

int getFirstSubmodel();

int getNextSubmodel(int handle);  

int addSubmodel(int parentHandle, String id); 

int addSubmodel(String parentId, String id); 

void deleteSubmodel(int handle); 

void deleteSubmodel(String id); 

void setSubmodelId(int handle, String id); 

String getSubmodelId(int handle); 

void setSubmodelName(int handle, String name); 

void setSubmodelName(String id, String name); 

String getSubmodelName(int handle); 

String getSubmodelName(String id); 

void setSubmodelDescription(int handle, String descrption); 

void setSubmodelDescription(String id, String descrption); 

String getSubmodelDescription(int handle); 

String getSubmodelDescription(String id); 

void setSubmodelOfNode(int submodelHandle, int nodeHandle); 

void setSubmodelOfNode(String submodelId, String nodeId); 

void setSubmodelOfSubmodel(int parentHandle, int childHandle); 

void setSubmodelOfSubmodel(String parentId, String childId); 

int getSubmodelOfNode(int nodeHandle); 

int getSubmodelOfNode(String nodeId); 

int getSubmodelOfSubmodel(int submodelHandle); 

int getSubmodelOfSubmodel(String submodelId); 

java.awt.Rectangle getSubmodelPosition(int submodelHandle);

java.awt.Rectangle getSubmodelPosition(String submodelID);

void setSubmodelPosition(int submodelHandle, int x, int y, int width, int height);

void setSubmodelPosition(String submodelId, int x, int y, int width, int height);

void setSubmodelPosition(int submodelHandle, java.awt.Rectangle rect);

void setSubmodelPosition(String submodelId, java.awt.Rectangle rect);

C#

int GetSubmodel(string id);

int GetMainSubmodel();

string GetMainSubmodelId();

int GetSubmodelCount();

int GetFirstSubmodel();

int GetNextSubmodel(int handle);

int AddSubmodel(int parentHandle, string id);

int AddSubmodel(string parentId, string id);

void DeleteSubmodel(int handle);

void DeleteSubmodel(string id);

void SetSubmodelId(int handle, string id);

string GetSubmodelId(int handle);

void SetSubmodelName(int handle, string name);

void SetSubmodelName(string id, string name);

string GetSubmodelName(int handle);

string GetSubmodelName(string id);

void SetSubmodelDescription(int handle, string description);

void SetSubmodelDescription(string id, string description);

string GetSubmodelDescription(int handle);

string GetSubmodelDescription(string id);

void SetSubmodelOfNode(int submodelHandle, int nodeHandle);

void SetSubmodelOfNode(string submodelId, string nodeId);

void SetSubmodelOfSubmodel(int parentHandle, int childHandle);

void SetSubmodelOfSubmodel(string parentId, string childId);

int GetSubmodelOfNode(int nodeHandle);

int GetSubmodelOfNode(string nodeId);

int GetSubmodelOfSubmodel(int submodelHandle);

int GetSubmodelOfSubmodel(string submodelId);

System.Drawing.Rectangle GetSubmodelPosition(int submodelHandle);

System.Drawing.Rectangle GetSubmodelPosition(string submodelId);

void SetSubmodelPosition(int submodelHandle, int x, int y, int width, int height);

void SetSubmodelPosition(string submodelId, int x, int y, int width, int height);

void SetSubmodelPosition(int submodelHandle, System.Drawing.Rectangle rect);

void SetSubmodelPosition(string submodelId, System.Drawing.Rectangle rect);

R

submodelHandle <- getSubmodel(id)

mainSubmodelHandle <- getMainSubmodel()

mainSubmodelId <- getMainSubmodelId()

submodelCount <- getSubmodelCount()

firstSubmodelHandle <- getFirstSubmodel()

nextSubmodelHandle <- getNextSubmodel(handle)

submodelHandle <- addSubmodel(parentIdOrHandle, id)

deleteSubmodel(submodelIdOrHandle)

setSubmodelId(submodelIdOrHandle, id)

submodelId <- getSubmodelId(submodelIdOrHandle)

setSubmodelName(submodelIdOrHandle, name)

submodelName <- getSubmodelName(submodelIdOrHandle)

setSubmodelDescription(submodelIdOrHandle, description)

submodelDescription <- getSubmodelDescription(submodelIdOrHandle)

setSubmodelOfNode(submodelIdOrHandle, nodeIdOrHandle)

setSubmodelOfSubmodel(parentIdOrHandle, childIdOrHandle)

submodelOfNode <- getSubmodelOfNode(nodeIdOrHandle)

submodelOfSubmodel <- getSubmodelOfSubmodel(submodelIdOrHandle)

submodelPosition <- getSubmodelPosition(submodelIdOrHandle)

setSubmodelPosition(submodelIdOrHandle, x, y, width, height)

setSubmodelPosition(submodelIdOrHandle, rect)