File Exchange

image thumbnail

Auto Layout Tool

version 1.6.1 (1.19 MB) by

The Auto Layout Tool is used to automatically improve the layout of Simulink models.

19 Downloads

Updated

View License

Modeling operations often perturb a model's layout. Layout readjustment is usually needed, and represents a tedious activity if performed manually. Although achieving a proper layout of a Simulink model is deemed very important, there does not exist a comprehensive commercial automatic layout tool for Simulink models. The Auto Layout Tool reuses a graph drawing algorithm as implemented in the open source tool Graphviz to achieve a proper layout of Simulink models. The tool resizes models' blocks based on number of inputs and outputs, and organizes the signal lines such that the number of crossings is minimized. The tool also supports a number of minor yet very practical transformations: transforming a From/Goto connection to a signal line connection (and back), as well as flattening of a model’s hierarchy.

For installation instructions and instructions on how to use the tool, see doc/AutoLayout/AutoLayout_UserGuide.pdf.

For more about the capabilities of the tool and how it can be used in model-based development with Simulink, see the two papers:
Vera Pantelic, Steven Postma, Mark Lawford, Alexandre Korobkine, Bennett Mackenzie, Jeff Ong, Marc Bender, "A Toolset for Simulink: Improving Software Engineering Practices in Development with Simulink," Proceedings of 3rd International Conference on Model-Driven Engineering and Software Development (MODELSWARD 2015), SCITEPRESS, 2015, 50-61. (Best Paper Award)

Vera Pantelic, Steven Postma, Mark Lawford, Monika Jaskolka, Bennett Mackenzie, Alexandre Korobkine, Marc Bender, Jeff Ong, Gordon Marks, Alan Wassyng, “Software engineering practices and Simulink: bridging the gap,” International Journal on Software Tools for Technology Transfer (STTT), 2017, 1-23.

Comments and Ratings (14)

McSCert

McSCert (view profile)

@Honigmelone: Thank you for the feedback. We are interested in looking at your model, if you can share it with us, so that we can work on addressing this issue. You can e-mail us at mcscert.tools@gmail.com

Honigmelone

Good idea, unfortunately it does not really perform well with flipped blocks for me (such as in feedback loops).

PINZHEN LIAO

McSCert

McSCert (view profile)

@Ganesh Hegade: The newest version of the tool (1.4) should address the issue you are encountering. Thanks again for your feedback.

McSCert

McSCert (view profile)

@Ganesh Hegade: We will look into ways of fixing this issue. Thank you for bringing it to our attention!

Hi,
This is a pretty nice tool to perform AutoLayout of Simulink system. Thanks a lot for providing this tool.
I am using this tool from sometime and i found below bug.

Problem:
In my work I created a Matlab GUI and added an option to create Simulink diagram from GUI. After the creation of Diagram i was trying to call AutoLayout to rearrange the blocks. But while rearranging blocks, Auto Layout Tool is closing the GUI itself and then throwing the error saying the model is not found.

Investigation / Possible reason :
I tried to debug the error and found that the error is inside the functions getTextHeight and getTextSize. Here you are using command "uicontrol", and then closing the parent of the figure using "close(get(x, 'parent'));". But if you have a Matlab GUI open, then by default Matlab GUI will become parent(as GUI is a figure) and the close command closes the GUI and all other things. Hence the error.

Work Around:
As a work around I am creating a new figure before assigning the "uicontrol" and making that as parent. This workaround looks as below:
function height = getTextHeight(string, block)
.....
.....
....
newFig = figure;
uicontrol(newFig);
x=uicontrol('Style', 'text', 'FontName', fontName, 'FontSize', fontSize);
set(x, 'String', string);
height=get(x, 'extent');
height=height(4);
close(get(x, 'parent'));
end
Same solution for getTextSize also.

Can you please check is there any better workaround or solution can be added for this in upcoming releases.

Regards,
Ganesh

McSCert

McSCert (view profile)

@Torsten Knodt: Thank you for checking out our tool. We are interested in looking at your model, if you are able to share it with us. You can e-mail us at marksgw@mcmaster.ca

Hello,
nice to see the submission of such a tool here.

I have tried your toolbox on a relatively small SimPowerSystems model with a relatively "chaotic" result. For the case you are interested, I can provide you the model or pre-post screenshot and dot file to e.g. an email address of your choice.

Regards
Torsten

McSCert

McSCert (view profile)

@Rami: Thanks for bringing this to our attention. This error seems fairly non-specific, so we are going to ask a couple questions to see if we can understand better what occurred.

1) What's size of the model in terms of number of blocks?

2) What are your naming conventions on blocks? Anything with spaces and/or newlines? We've had issues with that before.

3) Does the tool attempt to move any blocks or change the model in any way before the error occurs?

4) In the directory where you saved the Auto Layout Tool, is there a .dot file that was generated from the model?

This should give us a better idea of when the error was produced.

Thanks, Bennett and Gordon

Rami

Rami (view profile)

I get the following error when trying to apply on a complicated system with subsystems and feedback loops.

"Error using dotfile_creator (line 149)
Invalid Simulink object handle

Error in initLayout (line 40)
[filename, map]=dotfile_creator(address);

Error in AutoLayout (line 32)
initLayout(address);

Error in AutoLayoutGUI>pushbutton1_Callback (line 85)
AutoLayout(addressToLayout);

Error in gui_mainfcn (line 96)
feval(varargin{:});

Error in AutoLayoutGUI (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in
@(hObject,eventdata)AutoLayoutGUI('pushbutton1_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating uicontrol Callback"

I tried out the examples and they work. Please responed and help me out.

Guilherme

Great idea! I will test and give you feedback. Please continue supporting it

McSCert

McSCert (view profile)

@William Knox: Thank you for the feedback! From what we can tell based on your situation, you are working on a very large scale system. Presumably with the scale at which you're working at, when the Auto Layout Tool tried to space things out for legibility's sake it exceeded the hard limits of MATLAB's position coordinates, and threw an error when it tried to move a block past said point. This is something we can definitely consider, and we're glad it's been brought to our attention.

To best address this concern, would it be possible for you to give us the .dot file produced when the error was thrown? When the program completes its execution successfully, normally it gets rid of the file as part of cleanup. However, since yours cut out before it could finish, we would imagine the file was still there, in the directory where you saved the Auto Layout Tool toolbox (most likely, this is under MATLAB/Toolboxes/Auto Layout Tool). Thanks, Bennett and Gordon

William Knox

G'day developers,

I successfully installed and tested example model in Matlab 2014a (via System Generator 2014.3).

Tried to run on a subsystem with
-522 'Inport' blocks,
-522 Xilinx SYSGEN 'Up Sample' blocks,
-an 'm-code' block with 522 input ports and 52 output ports, lastly
- the 'm-code' block has terminated outputs i.e. all output ports are connected to 'Terminator' blocks (for testing).

The position of the 'm-code' block is [870 165 1165 21165].

An excerpt of the errors produced is provided below (between ---> and <---):
------->
Error: Edge length 286957.000000 larger than maximum 65535 allowed.
Check for overwide node(s).
...
many more of the type of errors shown above ... and below --->
...
Error: Edge length 175524.000000 larger than maximum 65535 allowed.
Check for overwide node(s).
Error using TplainParser/go_to_the_right_spot (line 105)
Input bounds are out of range

Error in TplainParser/plain_wrappers (line 45)
go_to_the_right_spot(object, object.RootSystemName,mapObj, graphinfo);

Error in AutoLayout (line 46)
g.plain_wrappers;

Error in AutoLayoutGUI>pushbutton2_Callback (line 95)
AutoLayout(gcs);

Error in gui_mainfcn (line 95)
feval(varargin{:});

Error in AutoLayoutGUI (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)AutoLayoutGUI('pushbutton2_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating uicontrol Callback
<-----------

I appreciate that this model/subsystem may not be a typical model/subsystem and that the 'Auto Layout Tool' was probably not designed for such models/subsystems.

This submission is not so much a request for help but more a feedback (for a possible bug fix).

Thank you for your time.

Kind regards,

Wil

Updates

1.6.1

Updated the "Other Requirements" text.

1.6

The tool uses Graphviz, which is a set of tools for drawing graphs (see the user guide for instructions on how to install/setup Graphviz). The Auto Layout Tool has been tested with R2011b, R2015a, R2015b, R2016a, and R2017a.

1.5.1

Updating formatting of description.

1.5.1

- Corrected the tool name

1.5

- Fixed issue with the Context Menu

1.4

- Addressed issue raised by Ganesh Hegade regarding closing of GUI windows.
- Updated the LineToGoto/From tool to the most recent version ("Line to Goto/From Tool" v1.0 on File Exchange)
- Removed unneeded command line output from Flatten Subsystem

1.3

Updating cover image. Removed a "Required Product" from the list.

1.3

Added transformations from a From/Goto connection to a signal line connection (and back), as well as a transformation that replaces a virtual subsystem with its content (subsystem flattening).

1.2.1

Added the function getAllLinePoints.m that was missing in the previous release to further improve upon the layout produced by the tool.

1.2

– Improved line routing, sizing of blocks, and spacing between blocks,
– Inputs and outputs are now moved to the left and right of a diagram, respectively, unless this increases the number of line crossings.

1.1

Now working on Linux and Mac OS X.

1.0.1

Added the cover figure for the tool.

MATLAB Release
MATLAB 9.2 (R2017a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

AutoLayout/src/

AutoLayout/src/GeneralPurpose/

AutoLayout/src/Graphviz_Portion/

AutoLayout/src/Utility/

AutoLayout/src/Utility/matlab-strsplit/

FlattenSubsystem/src/

FlattenSubsystem/src/Utility/

LineToGotoFrom/src/

LineToGotoFrom/src/Utility/

AutoLayout/example/

FlattenSubsystem/example/

LineToGotoFrom/example/