Main Content

move

R2026b

Move model to different parent model

Since R2026b

    Description

    move(smodel,newParent) moves smodel from its current parent to newParent. Quantities in smodel that belong to equivalence sets remain equivalent after the move. For details, see Move Behavior by Scenario.

    example

    move(smodel,newParent,mode) also specifies how to handle naming conflicts when smodel has the same name as newParent, any of its direct submodels, or any of the quantities or expressions it owns.

    smodel = move(___) returns the model on the new parent using any of the previous syntaxes.

    Examples

    collapse all

    Reorganize a PBPK model hierarchy by moving a submodel from one parent to another, and observe how equivalence sets update.

    Create a PBPK model with organ submodels, each containing a Venous Blood compartment.

    pbpkModel = sbiomodel("PBPK");
    gutModel = addmodel(pbpkModel,"Gut submodel");
    liverModel = addmodel(pbpkModel,"Liver submodel");
    addcompartment(gutModel,"Venous Blood");
    addcompartment(liverModel,"Venous Blood");

    Add a GI Tract submodel inside the Gut submodel with its own Venous Blood compartment.

    giTract = addmodel(gutModel,"GI Tract");
    addcompartment(giTract,"Venous Blood");

    Create an equivalence set grouping all Venous Blood compartments.

    venousComps = sbioselect(pbpkModel,"Type","compartment","Name","Venous Blood");
    eqVenous = addequivalence(pbpkModel,venousComps);
    eqVenous.Quantities
    ans = 
       SimBiology Compartment Array
    
       Index:    Name:           Value:    Units:    ParentModel:  
       1         Venous Blood    1                   Gut submodel  
       2         Venous Blood    1                   Liver submodel
       3         Venous Blood    1                   GI Tract      
    
    

    Inspect the equivalence set hierarchy. The GI Tract compartment is grouped with the Gut compartment in a subset.

    eqVenous.SubSets
    ans = 
      2×1 EquivalenceSet array with properties:
    
        ModelScope
        Quantities
        ResolvedQuantity
        SuperSet
        SubSets
        TopLevelSet
    
    

    Move the GI Tract submodel from the Gut submodel to the top-level PBPK model.

    move(giTract,pbpkModel);
    pbpkModel.Models
    ans = 
       SimBiology Model Array
    
       Index:    Name:             ParentModel:
       1         Gut submodel      PBPK        
       2         Liver submodel    PBPK        
       3         GI Tract          PBPK        
    
    

    Verify that quantities remain in the equivalence set after the move. The equivalence set hierarchy reorganizes to mirror the new model structure.

    eqVenous.Quantities
    ans = 
       SimBiology Compartment Array
    
       Index:    Name:           Value:    Units:    ParentModel:  
       1         Venous Blood    1                   Gut submodel  
       2         Venous Blood    1                   Liver submodel
       3         Venous Blood    1                   GI Tract      
    
    
    eqVenous.SubSets
    ans = 
      3×1 EquivalenceSet array with properties:
    
        ModelScope
        Quantities
        ResolvedQuantity
        SuperSet
        SubSets
        TopLevelSet
    
    

    Input Arguments

    collapse all

    Model to move, specified as a SimBiology.Model object. smodel can be a model within a model hierarchy or a top-level model on the SimBiology root.

    Destination parent, specified as a SimBiology.Model object or the SimBiology.Root object returned by sbioroot. newParent must not be smodel itself or a descendant of smodel.

    Specify sbioroot to move a model to the root. For the behavior differences between moving within the same hierarchy and across hierarchies, see Move Behavior by Scenario.

    Naming conflict resolution, specified as "strict" or "force".

    If smodel has the same name as newParent, any of the direct submodels of newParent, or any of the quantities or expressions owned by newParent:

    • "strict" — Throw an error.

    • "force" — Automatically rename smodel by appending a numeric suffix (for example, _1) to resolve the conflict.

    Data Types: char | string

    Output Arguments

    collapse all

    Moved model on the new parent, returned as a SimBiology.Model object.

    When smodel and newParent are in the same model hierarchy, the returned smodel is the same object as the input.

    When moving across model hierarchies or to sbioroot, the function creates a copy of smodel on the new parent and deletes the original. The original input object becomes invalid. Use the returned smodel object to continue working with the moved model.

    More About

    collapse all

    Version History

    Introduced in R2026b