Insight Maker API

download Insight Maker API

of 34

Transcript of Insight Maker API

  • 8/11/2019 Insight Maker API

    1/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html

    Insight Maker API

    Functions to manipulate Insight Maker models.

    Introduction

    The following is a set of API functions for Insight Maker. JavaScript is the language used for these interfaces. In

    addition to the Insight Maker specific functions listed here, standard JavaScript is also supported in buttons.There are three primary avenues for making use of this API.

    For the Act ion of Buttons embedded within models.For a parent page to manipulate an embedded IFRAME containing an Insight Maker model.

    Using the JavaSc ript console of the web browser to manipulate a model. To find the built-in JavaScript

    console for a web browser, see the relevant browsers documentation.

    Primitive Types

    A number of the API function refer to primitives by their type. The following are the valid types. Types are usuallyquoted when used and should always be capitalized (e.g. Stock).

    Stock

    VariableConverterFlowLink

    TextPictureFolder

    ButtonGhost

    Examples

    The following examples illustrate the usage of the API for certain scenarios.

    Using Dialogues

    Ask the user to specify a URL and opens a new web page at the location.

    showURL(showPrompt("What page should I open?"));

    Expanding and Collapsing Folders

    This example expands all the folders in the model.

    expandFolder(findType("Folder"));

    And this collapses them.

    collapseFolder(findType("Folder"));

    Notes

    Show the notes for all flow and link primitives in the model.

    varconnectors = findType(["Flow", "Link"]);

    showNote(connectors);

    Using Opacity

    Makes the currently selected primitives partially transparent.

    setOpacity(getSelected(), 50);

    Rabbit Birth Rate

    This example will work with the default Insight Maker model. It prompts the user to spec ify the birth rate for the

    rabbit population. It then sets the relevant primitive to that value and runs the model.

    varbirthRate = showPrompt("Enter the birth rate for the rabbits:", 0.1);

    varbirthPrimitive = findName("Rabbit Birth Rate");

    setValue(birthPrimitive, birthRate);

    runModel();

    This could also be written more compactly as

    setValue(findName("Rabbit Birth Rate"), showPrompt("Enter the birth rate for the rabbits:", 0.1)

    runModel();

    Building a Model

    This example creates a new model with two stocks connected by a flow.

    Insight Maker API

    INDEX

    Everything

    Classes

    Functions

    Search

    https://insightmaker.com/sites/default/files/API/index/Functions.htmlhttps://insightmaker.com/sites/default/files/API/index/Classes.htmlhttps://insightmaker.com/sites/default/files/API/index/General.htmlhttp://togglemenu%28%27mgroupcontent1%27%29/
  • 8/11/2019 Insight Maker API

    2/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 2

    clearModel();

    varsource = createPrimitive("Source", "Stock", [100, 50], [140, 50]);

    setValue(source, 100); //Give the source an initial value of 100

    varsink = createPrimitive("Sink", "Stock", [100, 300], [140, 50]);

    varmyFlow = createConnector("Leakage", "Flow", source, sink);

    setValue(myFlow, "0.1*[Source]"); //10% of the source's volume moves to the sink each time perio

    Manipulating a Model in an IFRAME

    To access the API of an embedded IFRAME, first give the IFRAME an id property. This is not added by default in

    Insight Maker. For instance change

  • 8/11/2019 Insight Maker API

    3/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 3

    getConstraints Gets the upper and lower bounds on the passed primitive to test againstduring s imulation.

    setConstraints Sets the upper and lower bounds on the passed primitive to test againstduring s imulation.

    getNote Gets the note of the passed primitive.setNote Sets the note of the passed primitive.showNote Shows the note for the passed primitive.hideNote Hides the no te for the pas sed primitive.showEditor Shows the value editor for the passed primitive.getValue Gets the value o f the passed primitive.setValue Sets the value o f the pass ed primitive.getSize Gets the size of the passed primitive.getPosition Gets the position of the passed primitive.setPosition Sets the position of the passed primitive.

    PRIMITIVESTYLINGFUNCTIONS

    getOpacity Gets the opacity of the passed primitive.

    setOpacity Sets the opacity of the passed primitive.getLineColor Gets the line color of the passed primitive.setLineColor Sets the line color of the passed primitive.getFontColor Gets the font color of the passed primitive.setFontColor Sets the font color of the passed primitive.getFillColor Gets the fill color of the passed primitive.setFillColor Sets the fill color of the passed primitive.getImage Gets the image of the passe d primitive.setImage Sets the image of the passe d primitive.

    STOCKS

    getNonNegative Gets the non-negative property of stocks (also applicable to flows).setNonNegative Sets the non-negative value of the passed stocks (also applicable to

    flows).getStockType Gets the type of the stock.setStockType Sets the type of the passe d stock.getDelay Gets the delay length of conveyor stocks.setDelay Sets the delay length of the passed conveyor stock.

    CONNECTORS See getNonNegativeand setNonNegative for setting the only-positiveproperty of flows.

    getEnds Gets the alpha and omega for the connectorsetEnds Sets the alpha and omega for a connector.connected Determines two primitives are connected by a link, flow, or transition.

    STATES

    getResidency Gets the residency property of a state primitive.setResidency Sets the res idency property of a state primitive.

    TRANSITIONSANDACTIONS

    getTriggerType Gets the trigger type of a transition or action.setTriggerType Sets the trigger type for a trans ition or action.getTriggerValue Gets the trigger value equation of a transition or action.setTriggerValue Sets the trigger value for a transition or action.getTriggerRepeat Gets the trigger Repeat p roperty of a transition or action.setTriggerRepeat Sets the trigger Repeat p roperty for a transition or action.getTriggerRecalculate Gets the trigger Recalculate prope rty of a transition or action.setTriggerRecalculate Sets the trigger Recalculate prope rty for a transition or action.

    CONVERTERS

    getData Gets the data of a converter.setData Sets the data of a converter.getConverterInput Gets the input source of a converter.setConverterInput Sets the input source of a converter.getInterpolation Gets the interpolation mode o f a converter.setInterpolation Sets the interpolation mode of a converter.

    BUTTONS

    pressButton Simulates a press o f the passed button(s) firing its action.

    AGENTS

    getPopulationSize Gets the size o f the agent population.

    setPopulationSize Sets the size of the agent population.getAgentBase Gets the base agent for the population.setAgentBase Sets the base agent for the population.getGeometryWrap Whether the geometry should wrap across edges .setGeometryWrap Sets the wrap property for the population area geometry.getGeometryUnits Gets the units for the population area geometry.setGeometryUnits Sets the units for the population area geometry.getGeometryWidth Gets the width for the population area geometry.setGeometryWidth Sets the width for the population area geometry.getGeometryHeight Gets the height for the population area geometry.setGeometryHeight Sets the height for the population area geometry.getAgentPlacement The placement method for the agent population.setAgentPlacement Sets the placement method for the agent population.

    getAgentPlacementFunction A custom placement function for the agent population.setAgentPlacementFunction Sets the custom placement function for the agent population.getAgentNetwork The network method for the agent population.setAgentNetwork Sets the network method for the agent population.getAgentNetworkFunction A custom network function for the agent population.setAgentNetworkFunction Sets the custom network function for the agent population.

    FOLDERS

    collapseFolder Collapses a folder or an array of folders.expandFolder Expands a folder or an array of folders.getCollapsed Returns whether or not a given folder is collapsed.getParent Gets the parent folder for a primitive.setParent Sets the parent folder for a primitive.getChildren Returns the children of a folder.getFolderType Gets the type of a folder.setFolderType Sets the type of a folder.getFolderAgentParent Gets the agent parent of a folder.setFolderAgentParent Sets the agent parent of a folder.getFolderSolversetFolderSolver Sets the solver object for a folder

    UTILITYFUNCTIONS

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    4/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 4

    excludeType Removes a specific type of primitive from an array of primitives.primitiveIndex Locates the index of a specific primitive in an array of primitives.uniquePrimitives Returns the passed array with duplicated primitives removedsetGlobal Sets the value o f a global variable.getGlobal Gets the value o f a global variable.

    INSIGHTMAKERINTERFACE

    topBarShown Determines whether or not the Insight Maker top toolbar (which containsthe Run Simulation button and othe r tools) is currently shown.

    toggleTopBar Toggles the visibility of the top too lbar.sideBarShown Determines whether or not the Insight Maker side panel (which contains

    parameter sliders and information a bout the selected primitive) iscurrently shown.

    toggleSideBar Toggles the visibility of the side panel.updateSideBar Refreshes the values in the side panel to reflect any changes in the

    model.

    DIALOGUESANDUSERINPUT

    showMessage

    functionshowMessage(message)

    Shows a message in a dialogue window.

    Parameters

    message The string to show as the message.

    See alsoshowPrompt, showChoice

    showPrompt

    functionshowPrompt(message,

    defaultValue)

    Shows a prompt in a dialogue window and provides a text input for the user to enter a value.

    Parameters

    message The string to show as the prompt.

    defaultValue The default value for the prompt. This parameter is optional.

    ReturnsThe value entered by the user.

    See also

    showMessage, showChoice

    showChoice

    functionshowChoice(message)

    Shows a prompt in a dialogue window and provides the user the option to c lick OK or Cancel. Returns the value

    the user clicked as a boolean.

    Parameters

    message The string to show as the prompt.

    Returns

    The value of the button clicked by the user as a boolean. OK is true, Cancel is false.

    See also

    showMessage, showPrompt

    showURL

    functionshowURL(url)

    Creates a new web browser window and sets the URL.

    Parameters

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    5/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 5

    url The URL to show.

    showData

    functionshowData(title,

    tabs,

    size )

    Creates a display to showcase data. Multiple tabs of data may be shown. This function is passed an array of

    objects each representing an individual tab.

    Parameters

    title The title for the data window

    tabs An array of tab objects

    size The dimensions of the window in the form [width, height] (optional)

    Tab Objects

    Each tab object contains several properties.

    name The name of the tab

    type The tab type. E.g. text, HTML, table or chart

    data The data for the tab

    The different types of tabs are as follows.

    Text Tab

    A text tab displays a large amount of text. For a text tab, the data property should be the text st ring that will bedisplayed.

    HTML Tab

    An HTML tab displays HTML content. For an HTML tab, t he data property should be the HTML content that will be

    displayed.

    Table Tab

    A table tab displays a grid of data. For a table tab, the data object should be an array of arrays. Each inner arrayrepresents a column in the resulting table. The following property is also supported for tables.

    header For a table, an array containing containing the titles of the columns (optional)

    Chart Tab

    A chart creates a graphical display of your data. In this case the data should be an array of series objects.The following property is also supported.

    xData The x coordinates for the series (each series must have the same number of points with

    the same x-c oordinates). In the form [x1, x2, ..., xn]

    xType The data type for the x-axis can be numeric or category (for use with categoricaldata such as column charts). By default, numeric data is assumed. (optional)

    xLabel A string for the x-Axis label (optional)

    yLabel A string for the y-Axis label (optional)

    legend A string controlling the position of the legend. Can be left, right, bott om, top, ornone (optional)

    verticalGrid True/false value whether or not to plot a vertical grid (optional)

    horizontalGird True/false value whether or not to plot a horizontal grid (optional)

    Each series object has the following the properties

    data An array containing the data for the series of the form [y1, y2, ..., yn]

    type The display type for the series. Can be line or bar

    name The series name as a st ring (for display in the legend)

    color The color of the series. A string such as green or #00ff00 (optional)

    hideLegend Prevents the series from being displayed in the legend (optional)

    fill If the series is a line series, creates a solid filled area between the line and the x-axis(optional)

    hideMarkers Hides the markers for individual data points (optional)

    Returns

    The window object that was created.

    Example

    showData("Sample Data",

    [

    {name: "A Chart",

    type: "chart",

    xLabel: "Chart x-Axis",

  • 8/11/2019 Insight Maker API

    6/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 6

    yLabel: "Chart y-Axis",

    legend: "top",

    horizontalGrid: true,

    verticalGrid: true,

    xType: "numeric",

    xData: [1,2,3,4,5],

    data: [{

    data: [1,4,9,16,25],

    type: "line",

    name: "Energy"

    },{

    data: [1,2,3,4,5],

    type: "line",

    name: "Cost"

    }] },

    {name: "I'm a Text Tab",

    type: "text",

    data: "This is a long data string..."

    },

    {name: "I'm an HTML Tab",

    type: "html",

    data: "

    This is HTML content.

    "

    },

    {name: "Here's a Grid",

    type: "table",

    data: [[1,2,3,4],[1,4,9,16]],

    header: ["Value", "Value^2"]

    }

    ]

    )

    frontWindow

    functionfrontWindow()

    Gets the frontmost window (if one exists).

    Returns

    A window object.

    closeAllWindows

    functioncloseAllWindows()

    Closes all open windows.

    openFile

    functionopenFile(config)

    Prompts t he user to selec t one or more files on their computer. Information about the select ed files are made

    available and the contents of the files are optionally read into memory.Note that this function needs to be called as a direct result of user actions (such as the user clicking on a button).

    Browser security rest rictions will prevent the function from operating if it is not called in response a user act ions. Note

    also that this function is not supported on Internet Explorer 9.

    Parameters

    config A configuraiton object with the following optional properties:

    multiple If false, only a single file may be selected; if true, one or more files may be selected at atime.

    accept A string containing a MIME file type to filter file select ion. If defined, only files matching the

    specified type may be selected. For example, image/* may be used to only accept imagefiles.

    read If defined the selected files will be opened and their contents loaded. Read may either be

    binary in which case the contents is loaded as a binary string, text in which case thecontents is loaded as a regular text string, or xlsx in which case an Excel file is loaded as anobject.

    onCompleted A function to handle results. The openFile funct ion is asynchronous. Once it completes, the

    callback function is called with the resulting data as a parameter.

    onError A function to handle the occurence of an error.

    onSelected A function fired once files have been selected but before data has been read.

    Returns

    The openFile funct ion is asynchronous and returns nothing directly. On the successful selection of files, the callback

    is called with the results.

  • 8/11/2019 Insight Maker API

    7/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 7

    If config.multiple is false, these results are a single file object. If config.multiple is true, then these results arean array of file objects. Each file object has the following properties

    file The orginal file object.

    name The name of the selected file.

    type The type of t he selected file.

    size The size of the selected file.

    contents If config.read is true, the contents in the file is loaded with the specified type.

    Examples

    // Select a single text file and display its contents

    openFile({ read: "text",

    multiple: false,

    onCompleted: function(result){

    alert(result.contents);

    }

    });

    GENERALMODELFUNCTIONS

    runModel

    functionrunModel(config)

    Runs a simulation and optionally returns the results.

    Parameters

    config A configuration object. For compatibility, if set to the Boolean value,equivalent to calling runModel with a configuration object with the silentproperty set to the boolean value.

    config.silent If false or undefined, behaves the same way as if the user clicked the runsimulation button. If true, no visible response is shown to running thesimulation and the results of the simulation are returned as an objec t.

    config.onSuccess(results) Callback called when the simulation completes successfully.

    config.onError(results) Callback called when an error occ urs during the simulation.

    Returns

    If silent is true, returns the simulation results as a results object. If callbacks are defined, the callbacks are calledwith a results object. This object contains the following properties.

    times The t imes for each period of the simulation as an array.

    value(primitive) A function that takes a primitive reference and returns an array of the values that

    primitive took on over the course of the simulation.

    lastValue(primitive) A function that takes a primitive reference and returns the last value of theprimitive during the simulation.

    window The results window object (if config.silent is false).

    error none if no simulation error occurred, otherwise an error message.

    errorPrimitive The primitive that caused the error.

    Examples

    # Runs a simulation, and displays the average value of the Stock named "Rabbits"

    runModel({

    onSuccess: function(results){

    varsum = 0;

    for(vari = 0; i < results.times.length; i++){ sum += results.value(findName("Rabbits"))[i];

    }

    showMessage("The average value is: "+ sum/results.times.length);

    }

    })

    saveModel

    functionsaveModel(dialogue)

    Saves t he model.

    Parameters

    dialogue Pass true to show the properties dialogues (e.g. name, description, tags). The dialogue is

  • 8/11/2019 Insight Maker API

    8/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 8

    always shown if this is the first save.

    clearModel

    functionclearModel()

    Removes all primitives from the model.

    layoutModel

    functionlayoutModel(algorithm)

    Reorganizes the primitives in the model according to an algorithm.

    Parameters

    algorithm The algorithm used to calculate the new positions of the primitive. Either organic or circular.

    setZoom

    functionsetZoom(scale)

    Sets the scale of the diagram display.

    Parameters

    scale The diagram scale. If this is a number, then it determine the scale level. 1 means 100%, 0.5 means50%, 2 means 200% and so on. You also pass one of the following strings: fit to fit the model to

    the diagram area, actual to reset the scale, in to zoom further in based on the current scale, andout to further out based on the current sc ale.

    SIMULATIONSETTINGS

    getTimeStep

    functiongetTimeStep()

    Gets the time step used in the simulation.

    Returns

    The time step for the simulation as a floating point number.

    See also

    setTimeStep

    setTimeStep

    functionsetTimeStep(timeStep)

    Sets the t ime step used in the simulation.

    Parameters

    timeStep The t ime step to be used in the simulation.

    See also

    getTimeStep

    getTimeStart

    functiongetTimeStart()

    Gets the start time for the simulation.

    Returns

    The start time for the simulation as a floating point number.

    See also

    setTimeStart

    http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    9/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 9

    setTimeStart

    functionsetTimeStart(timeStart)

    Sets the start time for the simulation.

    Parameters

    timeStart The start time for the simulation.

    See also

    getTimeStart

    getTimeLength

    functiongetTimeLength()

    Gets the length of the simulation.

    Returns

    The length of t he simulation as a floating point number.

    See also

    setTimeLength

    setTimeLength

    functionsetTimeLength(timeLength)

    Sets the length of the simulation.

    Parameters

    timeLength The length of t he simulation.

    See also

    getTimeLength

    getPauseInterval

    functiongetPauseInterval()

    Gets the intervals at which to pause the simulation.

    Returns

    The pause interval as a floating point number. Returns undefined if a pause interval has not been spec ified.

    See also

    setPauseInterval

    setPauseInterval

    functionsetPauseInterval(pauseInterval)

    Sets the intervals at which to pause the simulation.

    Parameters

    pauseInterval The pause interval for t he simulation.

    See also

    setPauseInterval

    getTimeUnits

    functiongetTimeUnits()

    Gets the time units of the simulation.

    Returns

    The time units of the simulation (e.g. Seconds, Minutes, Days, Years).

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    10/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 10

    See also

    setTimeUnits

    setTimeUnits

    functionsetTimeUnits(units)

    Sets the t ime units of the simulation.

    Parameters

    units The time units of the simulation (e.g. Seconds, Minutes, Days, Years).

    See also

    getTimeUnits

    getAlgorithm

    functiongetAlgorithm()

    Gets the algorithm for the simulation.

    Returns

    The algorithm for the simulation as a string. RK1 indicates Eulers method. RK4 indicates a 4th order Runge-Kutta

    method.

    See alsosetAlgorithm

    setAlgorithm

    functionsetAlgorithm(algorithm)

    Sets the algorithm of the simulation.

    Parameters

    algorithm The algorithm for the simulation. RK1 indicates Eulers method. RK4 indicates a 4th orderRunge-Kutta method.

    See also

    getAlgorithm

    getMacros

    functiongetMacros()

    Gets the macros for the insight.

    Returns

    The macros for the insight as a string.

    See also

    setMacros

    setMacros

    functionsetMacros(macros)

    Sets the macros of the insight.

    Parameters

    macros The macros for the insight.

    See also

    getMacros

    FINDINGANDACCESSINGSPECIFICPRIMITIVES

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    11/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 1

    findName

    functionfindName(name)

    Finds and returns a primitive by its name. If more than one primitive with the same name exists, returns an array ofprimitives.

    Parameters

    name The name of the primitive to return as a string. Also acc epts an array of strings in which case all the

    primitives named in the array will be returned.

    Return

    A primitive. If multiple primitives exist with the same name, an array of primitives will be returned. Returns null if noprimitives are found.

    See also

    findType, findAll, findID, findNote, findValue

    findAll

    functionfindAll()

    Finds and returns all primitives in the model.

    Return

    An array of primitives.

    See also

    findName, findType, findID, findNote, findValue

    findType

    functionfindType(type)

    Finds and returns all primitives of a specific type.

    Parameters

    type The type of primitives to return. For instance: Stock, Flow, Link, Text, Button, Picture,

    Converter or Variable. An array of type strings may also be passed.

    Return

    An array of primitives of the specified type.

    See also

    findName, findAll, findID, findNote, findValue

    findID

    functionfindID(id)

    Finds and returns a primitive using its ID.

    Parameters

    ID The ID of the primitive to find. May also be an array of IDs.

    Return

    A primitive. If an array of IDs was passed, returns an array of primitives.

    See also

    findName, findType, findAll, findValue, findNote, getID

    findValue

    functionfindValue(search)

    Finds and returns all primitives whose values match a regular expression.

    Parameters

    search The regular expression to search for. Can also be a st ring in which case the primitive values will be

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    12/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 12

    test ed for strict case-sensitive equality against the string. May also be an array of regularexpressions and strings in which case any primitive with a value that matches one element of thearray will be returned.

    Return

    An array of primitives whose values match the regular expression. Returns an empty array if no primitives match.

    Example

    // Returns all primitives that use the log function

    varcontainingLog = findValue(/log\(/i);

    // Returns all primitives whose value is strictly "1"

    varisOne = findValue("1");

    See also

    findName, findType, findAll, findNote, getID

    findNote

    functionfindNote(search)

    Finds and returns all primitives whose notes match a regular expression.

    Parameters

    search The regular expression to search for. Can also be a string in which case the primitive notes will betest ed for strict case-sensitive equality against the string. May also be an array of regular

    expressions and strings in which case any primitive with a note that matches one element of thearray will be returned.

    Return

    An array of primitives whose notes match the regular expression. Returns an empty array if no primitives match.

    See also

    findName, findType, findAll, findValue, getID

    CREATEANDDELETEPRIMITIVES

    createPrimitive

    functioncreatePrimitive(name,

    type,

    position,

    size )

    Creates a new primitive and adds it to the model. This funct ion is only for node-t ype primitives not connectors (e.g.flows or links).

    Parameters

    name The name of the primitive to add.

    type The type of the primitive to add. For example, Variable or Stock.

    position The location of the upper-left corner of the primitive in the form: [x, y].

    size The dimensions of the primitive in the form: [width, height].

    Return

    The newly c reated primitive.

    See also

    createConnector, removePrimitive

    createConnector

    functioncreateConnector(name,

    type,

    alpha,

    omega )

    Creates a new connector primitive and adds it to the model.

    Parameters

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    13/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 13

    name The name of the primitive to add.

    type The t ype of the primitive to add: Link or Flow.

    alpha The primitive that will be at the start of the connector.

    omega The primitive that will be at the end of the connector.

    Return

    The newly created connector primitive.

    See also

    createPrimitive, removePrimitive

    removePrimitive

    functionremovePrimitive(primitive)

    Removes a primitive from the model. You should not att empt to access or modify a primitive once it has been

    removed.

    Parameters

    primitive The primitive to delete, c an also be an array of primitives.

    See also

    createPrimitive, createConnector

    PRIMITIVESELECTIONS

    highlight

    functionhighlight(primitive)

    Highlights a single primitive. Selects the primitive, expands any c ollapsed folders the primitive is in, and sc rolls to theposition of the primitive.

    Parameters

    primitive The primitive to highlight.

    getSelected

    functiongetSelected()

    Finds and returns the currently selected primitives.

    Return

    An array of the selected primitives.

    See also

    setSelected, isSelected

    setSelected

    functionsetSelected(primitives)

    Sets the currently selected primitives.

    Parameters

    primitives An array of primitives to select. Can also be a single primitive.

    See also

    getSelected, isSelected

    isSelected

    functionisSelected(primitive)

    Indicates whether a primitive is selected.

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    14/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 14

    Parameters

    primitive A primitive to return the selection status for. May also be an array of primitives.

    Return

    Whether the primitive is selected or not as a boolean. If an array of primitives was passed t o the funct ion, an arrayof booleans is returned.

    See also

    getSelected, setSelected

    GENERALPRIMITIVEFUNCTIONS

    getID

    functiongetID(primitive)

    Gets the ID of the passed primitive. The ID remains constant even if the name of a primitive changes. The ID is astring.

    Parameters

    primitive The primitive for which the ID is requested. May also be an array of primitives.

    Return

    The ID of the primitive as a string. If an array of primitives was passed, returns an array of IDs.

    See also

    findID

    getType

    functiongetType(primitive)

    Gets the type of the passed primitive.

    Parameters

    primitive The primitive for which the type is requested. May also be an array of primitives.

    Return

    The type of the primitive as a string. If an array of primitives was passed, returns an array of IDs.

    getName

    functiongetName(primitive)

    Gets the name of the passed primitive.

    Parameters

    primitive The primitive for which the name is requested. May also be an array of primitives.

    Return

    The name of the primitive as a string. If an array of primitives was passed, returns an array of names.

    See also

    setName

    setName

    functionsetName(primitive,

    name )

    Sets the name of the passed primitive.

    Parameters

    primitive The primitive for which the name will be set. May also be an array of primitives in which case

    they will all be set to the same name.

    name The new name for the primitive.

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    15/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 15

    See also

    getName

    getUnits

    functiongetUnits(primitive)

    Gets the units of the passed primitive.

    Parameters

    primitive The primitive for which the units are requested. May also be an array of primitives.

    Return

    The units of the primitive as a string. If an array of primitives was passed, returns an array of units.

    See also

    setUnits

    setUnits

    functionsetUnits(primitive,

    units )

    Sets the units of the passed primitive.

    Parametersprimitive The primitive for which the units will be set. May also be an array of primitives in which case

    they will all be set to the same units.

    units The new units for the primitive.

    See also

    getUnits

    getConstraints

    functiongetConstraints(primitive)

    Gets the upper and lower bounds on the passed primitive to test against during simulation.

    Parametersprimitive The primitive for which the constraints are requested. May also be an array of primitives.

    Return

    The constraints of the primitive as an array. The format is [MinimumConstraint, MinimumConstraintMode,MaximumConstraint, MaximumConstraintMode]. Constraint mode is false to disable the constraint and true to enable it.

    See also

    setConstraints

    setConstraints

    functionsetConstraints(primitive,

    constraints)

    Sets the upper and lower bounds on the passed primitive to test against during simulation.

    Parameters

    primitive The primitive for which the units will be set. May also be an array of primitives in which case

    they will all be set to the same constraints.

    constraints The constraints of the primitive as an array. The format is [MinimumConstraint,MinimumConstraintMode, MaximumConstraint, MaximumConstraintMode]. Constraint mode isfalse to disable the constraint and true to enable it.

    See also

    getConstraints

    getNote

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    16/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 16

    functiongetNote(primitive)

    Gets the note of the passed primitive.

    Parameters

    primitive The primitive for which the note is requested. May also be an array of primitives.

    Return

    The note of t he primitive as a string. If an array of primitives was passed, returns an array of notes.

    See also

    setNote

    setNote

    functionsetNote(primitive,

    note )

    Sets the note of the passed primitive.

    Parameters

    primitive The primitive for which the note will be set. May also be an array of primitives in which casethey will all be set to the same note.

    note The new note for the primitive.

    See also

    getNote

    showNote

    functionshowNote(primitive)

    Shows the note for the passed primitive. The note is shown as a closable tooltip next to the primitive. If the note isempty, the note will not be shown.

    Parameters

    primitive The primitive for which the note will be shown. May also be an array of primitives in which casethey will all have their notes shown.

    See also

    hideNote

    hideNote

    functionhideNote(primitive)

    Hides the note for the passed primitive. The note is shown as a c losable tooltip next to the primitive.

    Parameters

    primitive The primitive for which the note will be hidden. May also be an array of primitives in which casethey will all have their notes hidden.

    See also

    showNote

    showEditor

    functionshowEditor(primitive)

    Shows the value editor for the passed primitive.

    Parameters

    primitive The primitive for which t he editor will be shown.

    getValue

    functiongetValue(primitive)

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    17/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 17

    Gets the value of the passed primitive. The value depends on the type of the primitive. For instance, the value ofstock is its initial value while the value of a flow is its rate.

    Parameters

    primitive The primitive for which the value is requested. May also be an array of primitives.

    Return

    The value of the primitive as a string. If an array of primitives was passed, returns an array of values.

    See also

    setValue

    setValue

    functionsetValue(primitive,

    value )

    Sets the value of the passed primitive. The value depends on the type of the primitive. For instance, the value of

    stock is its initial value while the value of a flow is its rate.

    Parameters

    primitive The primitive for which the value will be set. May also be an array of primitives in which case

    they will all be set to the same value.

    value The new value for the primitive. Can be a number or a string.

    See also

    getValue

    getSize

    functiongetSize(primitive)

    Gets the size of the passed primitive.

    Parameters

    primitive The primitive for which the posit ion is requested. May also be an array of primitives.

    Return

    The size as an array of the form: [width, height].

    getPosition

    functiongetPosition(primitive)

    Gets the position of the passed primitive.

    Parameters

    primitive The primitive for which the posit ion is requested. May also be an array of primitives.

    Return

    The position as an array of the form [x, y]. The position is measured from the top- left corner of the graph.

    See also

    setPosition

    setPosition

    functionsetPosition(primitive,

    position )

    Sets the position of the passed primitive.

    Parameters

    primitive The primitive for which the position will be set. May also be an array of primitives in which casethey will all be set to the same position.

    position The new position for the primitive in the form [x, y]. The position is measured from the top-leftcorner of the graph.

    See also

    http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    18/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 18

    getPosition

    PRIMITIVESTYLINGFUNCTIONS

    getOpacity

    functiongetOpacity(primitive)

    Gets the opac ity of the passed primitive. Opacity is a value between 0 (invisible) to 100 (fully opaque).

    Parameters

    primitive The primitive for which the opac ity will be returned. May also be an array of primitives.

    Return

    The opacity of the primitive

    setOpacity

    functionsetOpacity(primitive,

    opacity )

    Sets t he opacity of the passed primitive. Opacity is a value between 0 (invisible) to 100 (fully opaque).

    Parameters

    primitive The primitive for which the opacity will be set. May also be an array of primitives in which casethey will all be set to the same opacity.

    opacity The new opacity for the primitive.

    getLineColor

    functiongetLineColor(primitive)

    Gets the line color of the passed primitive.

    Parameters

    primitive The primitive for which the line color will be returned. May also be an array of primitives.

    Return

    The line color of the primitive

    setLineColor

    functionsetLineColor(primitive,

    lineColor )

    Sets the line color of the passed primitive.

    Parameters

    primitive The primitive for which the line color will be set. May also be an array of primitives in which

    case they will all be set to the same color.

    lineColor The new line color for the primitive.

    getFontColor

    functiongetFontColor(primitive)

    Gets the font color of the passed primitive.

    Parameters

    primitive The primitive for which the font color will be returned. May also be an array of primitives.

    Return

    The font color of the primitive

    setFontColor

    http://-/?-
  • 8/11/2019 Insight Maker API

    19/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 19

    functionsetFontColor(primitive,

    fontColor )

    Sets the font color of the passed primitive.

    Parameters

    primitive The primitive for which the font color will be set. May also be an array of primitives in which

    case they will all be set to the same color.

    fontColor The new font color for the primitive.

    getFillColorfunctiongetFillColor(primitive)

    Gets the fill color of the passed primitive.

    Parameters

    primitive The primitive for which the f ill color will be returned. May also be an array of primitives.

    Return

    The fill color of the primitive

    setFillColor

    functionsetFillColor(primitive,

    fillColor )

    Sets the fill color of the passed primitive.

    Parameters

    primitive The primitive for which the f ill color will be set. May also be an array of primitives in which casethey will all be set to the same color.

    fillColor The new fill color for t he primitive.

    getImage

    functiongetImage(primitive)

    Gets the image of the passed primitive.

    Parameters

    primitive The primitive for which the image will be returned. May also be an array of primitives.

    Return

    The image of the primitive as a string

    setImage

    functionsetImage(primitive,

    image )

    Sets the image of the passed primitive.

    Parametersprimitive The primitive for which the image will be set. May also be an array of primitives in which case

    they will all be set to t he same image.

    image The image url or alias as a string.

    STOCKS

    getNonNegative

    functiongetNonNegative(primitive)

    Gets the non-negative property of stocks (also applicable to flows). A non-negative stoc k will never becomenegative.

  • 8/11/2019 Insight Maker API

    20/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 20

    Parameters

    primitive The stoc k for which the value is requested. May also be an array of stock.

    Return

    The non-negative value of the stoc k. If an array of primitives was passed, returns an array of values.

    See also

    setNonNegative

    setNonNegative

    functionsetNonNegative(primitive,

    nonNegative)

    Sets the non-negative value of the passed stocks (also applicable to flows).

    Parameters

    primitive The stoc k for which the non-negative value will be set. May also be an array of stoc ks inwhich case they will all be set to the same value.

    nonNegative The new non-negat ive status for the stock. Either true or false.

    See also

    getNonNegative

    getStockType

    functiongetStockType(primitive)

    Gets the type of the stock. The type affect s the behavior of the stock and may either be Store (the default) or

    Conveyor.

    Parameters

    primitive The stoc k for which the type is requested. May also be an array of stocks.

    Return

    The type of the stock as a string. If an array of stocks was passed, returns an array of strings.

    See also

    setStockType

    setStockType

    functionsetStockType(primitive,

    type )

    Sets the type of the passed stock.

    Parameters

    primitive The stoc k for which the type will be set. May also be an array of stocks in which case they willall be set to the same type.

    type The type of the stock as a string. Either Store (the default) or Conveyor.

    See also

    getStockType

    getDelay

    functiongetDelay(primitive)

    Gets the delay length of conveyor stocks.

    Parameters

    primitive The stoc k for which the value is requested. May also be an array of stocks.

    Return

    The delay length of the stock. If an array of stocks was passed, returns an array of lengths.

    See also

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    21/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 2

    setDelay

    setDelay

    functionsetDelay(primitive,

    delay )

    Sets the delay length of the passed conveyor stock.

    Parameters

    primitive The stock for which the delay length will be set. May also be an array of stocks in which casethey will all be set to the same value.

    delay The delay length for the stock.

    See also

    getDelay

    CONNECTORS

    See getNonNegativeand setNonNegativefor setting the only-positive property of flows.

    getEnds

    functiongetEnds(connector)

    Gets the alpha and omega for the connector

    Parameters

    connector The connector for which the ends are requested. Can also be an array of connectors.

    Return

    The alpha and omega as an array: [alpha, omega]. Array elements are returned as null if no connect ion exists.

    See also

    setEnds

    setEnds

    functionsetEnds(connector,

    ends )

    Sets the alpha and omega for a connector.

    Parameters

    connector The connector for which the alpha and omega will be set. May also be an array of connec tors.

    ends The new alpha and omega for the connector as an array: [alpha, omega]. Use null for either

    alpha or omega to disconnect an end.

    See also

    getEnds

    connected

    functionconnected(primitive1,primitive2 )

    Determines two primitives are connected by a link, flow, or transition. Alternatively if one of the primitives is aconnector, checks if it connects directly to the other primitive.

    Parameters

    primitive1 A primitive.

    primitive2 A primitive to test whether it is connected to primitive1.

    Return

    A boolean. True if the primitives are connected, false otherwise.

    STATES

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    22/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 22

    getResidency

    functiongetResidency(state)

    Gets the residency property of a state primitive.

    Parameters

    state The stat e for which the residency property is requested. May also be an array of states.

    Return

    The residency property as a string.

    See also

    setResidency

    setResidency

    functionsetResidency(state,

    residency)

    Sets the residency property of a state primitive.

    Parameters

    state The state primitive for which the residency property will be set. May also be an array of states.

    residency The new value for the residency property.

    See also

    getResidency

    TRANSITIONSANDACTIONS

    getTriggerType

    functiongetTriggerType(primitive)

    Gets the trigger type of a transition or action.

    Parameters

    primitive The transition or action for which the trigger is requested. May also be an array of transitionsor actions.

    Return

    The trigger mode as a string. May be T imeout, Probability or Condition.

    See also

    setTriggerType

    setTriggerType

    functionsetTriggerType(primitive,

    trigger )

    Sets the trigger type for a transition or action.

    Parameters

    primitive The transition or action for which the trigger will be set. May also be an array of transitions or

    actions.

    trigger The new t rigger for the transition or action. May be Timeout Probability or Condition.

    See also

    getTriggerType

    getTriggerValue

    functiongetTriggerValue(primitive)

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    23/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 23

    Gets the trigger value equation of a transition or action.

    Parameters

    primitive The transition or action for which the trigger value equation is requested. May also be an arrayof transitions or actions.

    Return

    The trigger value equation as a string.

    See also

    setTriggerValue

    setTriggerValue

    functionsetTriggerValue(primitive,

    value )

    Sets the trigger value for a transition or action.

    Parameters

    primitive The transition or action for which the trigger will be set. May also be an array of transitions oractions.

    value The new trigger value equation as a string.

    See also

    getTriggerValue

    getTriggerRepeat

    functiongetTriggerRepeat(primitive)

    Gets the trigger Repeat property of a transition or action.

    Parameters

    primitive The transition or action for which the property is requested. May also be an array of transitions

    or actions.

    Return

    The trigger Repeat property as a boolean.

    See alsosetTriggerRepeat

    setTriggerRepeat

    functionsetTriggerRepeat(primitive,

    repeat )

    Sets the trigger Repeat property for a transition or action.

    Parameters

    primitive The transition or action for which the Repeat property will be set. May also be an array oftransitions or actions.

    repeat A boolean determining whether to repeat the t rigger

    See also

    getTriggerRepeat

    getTriggerRecalculate

    functiongetTriggerRecalculate(primitive)

    Gets the trigger Recalculate property of a transition or action.

    Parameters

    primitive The transition or action for which the property is requested. May also be an array of transitionsor actions.

    Return

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    24/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 24

    The trigger Recalculate property as a boolean.

    See also

    setTriggerRecalculate

    setTriggerRecalculate

    functionsetTriggerRecalculate(primitive,

    recalculate)

    Sets the trigger Recalculate property for a transition or action.

    Parameters

    primitive The transition or action for which the Recalculate property will be set. May also be an arrayof transitions or actions.

    recalculate A boolean determining whether to recalculate each time step

    See also

    getTriggerRecalculate

    CONVERTERS

    getData

    functiongetData(converter)

    Gets t he data of a converter.

    Parameters

    converter The converter for which the data is requested. May also be an array of Converters.

    Return

    The Converter data as a st ring. A set of input/output pairs separated by semicolons. Example data form:1,1;2,4;3,9

    See also

    setData

    setData

    functionsetData(converter,

    data )

    Sets the data of a converter.

    Parameters

    converter The converter for which the data will be set. May also be an array of Converters in which casethey will all be set to the same value.

    data The data for the converter as a string. A set of input/output pairs separated by semicolons.Example data form: 1,1;2,4;3,9

    See also

    getData

    getConverterInput

    functiongetConverterInput(converter)

    Gets the input source of a converter.

    Parameters

    converter The converter for which the input source is requested. May also be an array of Converters.

    Return

    The input source. If the input source is a primitive, returns the primitive. Otherwise returns null (indicating the useof time as the input source).

    See also

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    25/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 25

    setConverterInput

    functionsetConverterInput(converter,

    input )

    Sets the input source of a converter.

    Parameters

    converter The converter for which the input source will be set. May also be an array of Converters inwhich case they will all be set to the same value.

    input The input source. Pass either a primitive or use null to indicat e the usage of t ime as the input.

    See also

    getConverterInput

    getInterpolation

    functiongetInterpolation(converter)

    Gets the interpolation mode of a converter.

    Parameters

    converter The converter for which the interpolation is requested. May also be an array of Converters.

    Return

    The interpolation mode as a string. May be Linear or Discrete.

    See also

    setInterpolation

    setInterpolation

    functionsetInterpolation(converter,

    interpolation)

    Sets the interpolation mode of a converter.

    Parameters

    converter The converter for which the interpolation will be set. May also be an array of Converters inwhich case they will all be set to the same value.

    interpolation The interpolation mode for the converter as a string. May either be Linear or Discrete.

    See also

    getInterpolation

    BUTTONS

    pressButton

    functionpressButton(button)

    Simulates a press of the passed button(s) firing its action. Can be useful for chaining together methods.

    Parameter

    button The button to be pressed. Can also be an array of buttons.

    AGENTS

    getPopulationSize

    functiongetPopulationSize(agents)

    Gets the size of the agent population.

    http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    26/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 26

    Parameters

    agents The agent population for which the size will be returned. May also be an array of agentpopulations.

    Return

    The population size.

    See also

    setPopulationSize

    setPopulationSize

    functionsetPopulationSize(agents,

    size )

    Sets the size of the agent population.

    Parameters

    agents The agent population for which the size will be set. May also be an array of agent populations.

    size The new population size.

    See also

    getPopulationSize

    getAgentBase

    functiongetAgentBase(agents)

    Gets the base agent for the population.

    Parameters

    agents The agent population for which the base agent will be returned. May also be an array of agentpopulations.

    Return

    The base agent folder.

    See also

    setAgentBase

    setAgentBase

    functionsetAgentBase(agents,

    folder )

    Sets the base agent for the population.

    Parameters

    agents The agent population for which the base agent will be set. May also be an array of agent

    populations.

    folder The base agent folder. The type for this folder should be set to Agent.

    See also

    getAgentBase

    getGeometryWrap

    functiongetGeometryWrap(agents)

    Whether the geometry should wrap across edges.

    Parameters

    agents The agent population for which the geometry wrap property will be returned. May also be an arrayof agent populations.

    Return

    The wrap property as a boolean

    See also

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    27/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 27

    setGeometryWrap

    setGeometryWrap

    functionsetGeometryWrap(agents,

    wrap )

    Sets the wrap property for the population area geometry.

    Parameters

    agents The agent population for which geometry wrap property will be set. May also be an array of agentpopulations.

    wrap The wrap property for the geometry.

    See also

    getGeometryWrap

    getGeometryUnits

    functiongetGeometryUnits(agents)

    Gets the units for the population area geometry.

    Parameters

    agents The agent population for which the units will be returned. May also be an array of agentpopulations.

    Return

    The units as a string

    See also

    setGeometryUnits

    setGeometryUnits

    functionsetGeometryUnits(agents,

    units )

    Sets the units for the population area geometry.

    Parameters

    agents The agent population for which geometry units will be set. May also be an array of agentpopulations.

    units The units as a string.

    See also

    getGeometryUnits

    getGeometryWidth

    functiongetGeometryWidth(agents)

    Gets the width for the population area geometry.

    Parameters

    agents The agent population for which the width will be returned. May also be an array of agentpopulations.

    Return

    The width of the geometry

    See also

    setGeometryWidth

    setGeometryWidth

    functionsetGeometryWidth(agents,

    width )

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    28/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 28

    Sets the width for the population area geometry.

    Parameters

    agents The agent population for which geometry width will be set. May also be an array of agentpopulations.

    width The desired width.

    See also

    getGeometryWidth

    getGeometryHeight

    functiongetGeometryHeight(agents)

    Gets the height for the population area geometry.

    Parameters

    agents The agent population for which the height will be returned. May also be an array of agentpopulations.

    Return

    The height of the geometry

    See also

    setGeometryHeight

    setGeometryHeight

    functionsetGeometryHeight(agents,

    height )

    Sets the height for the population area geometry.

    Parameters

    agents The agent population for which geometry height will be set. May also be an array of agent

    populations.

    height The desired height.

    See also

    getGeometryHeight

    getAgentPlacement

    functiongetAgentPlacement(agents)

    The placement method for the agent population.

    Parameters

    agents The agent population for which the placement method will be returned. May also be an array ofagent populations.

    Return

    The placement method for the agent population. One of Random, Network, Grid or Custom Function.

    See alsosetAgentPlacement

    setAgentPlacement

    functionsetAgentPlacement(agents,

    method )

    Sets the placement method for the agent population.

    Parameters

    agents The agent population for which placement method will be set. May also be an array of agentpopulations.

    method The desired placemennt method. One of Random, Network, Grid or Custom Function.

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    29/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 29

    See also

    getAgentPlacement

    getAgentPlacementFunction

    functiongetAgentPlacementFunction(agents)

    A custom placement function for the agent population.

    Parameters

    agents The agent population for which the custom placement function will be returned. May also be an

    array of agent populations.

    Return

    The custom placement function for the agent population.

    See also

    setAgentPlacementFunction

    setAgentPlacementFunction

    functionsetAgentPlacementFunction(agents,

    func )

    Sets the custom placement funct ion for the agent population. The placement method should be set to CustomFunction in order for this function to be used.

    Parameters

    agents The agent population for which the custom placement function will be set. May also be an array ofagent populations.

    func The desired custom placement function.

    See also

    getAgentPlacementFunction

    getAgentNetwork

    functiongetAgentNetwork(agents)

    The network method for the agent population.

    Parameters

    agents The agent population for which the network method will be returned. May also be an array of

    agent populations.

    Return

    The network method for the agent population. One of None or Custom Funct ion.

    See also

    setAgentNetwork

    setAgentNetwork

    functionsetAgentNetwork(agents,

    method )

    Sets the network method for the agent population.

    Parameters

    agents The agent population for which network method will be set. May also be an array of agentpopulations.

    method The desired placemennt method. One of None or Custom Funct ion.

    See also

    getAgentNetwork

    getAgentNetworkFunction

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    30/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 30

    functiongetAgentNetworkFunction(agents)

    A custom network function for the agent population.

    Parameters

    agents The agent population for which the custom network funct ion will be returned. May also be an arrayof agent populations.

    Return

    The custom network function for the agent population.

    See also

    setAgentNetworkFunction

    setAgentNetworkFunction

    functionsetAgentNetworkFunction(agents,

    func )

    Sets the custom network funct ion for the agent population. The network method should be set to CustomFunction in order for this function to be used.

    Parameters

    agents The agent population for which the custom network function will be set. May also be an array of

    agent populations.

    func The desired custom network function.

    See also

    getAgentNetworkFunction

    FOLDERS

    collapseFolder

    functioncollapseFolder(folder)

    Collapses a folder or an array of folders.

    Parameter

    folder Either a single folder primitive or an array of folder primitives.

    See also

    expandFolder, getCollapsed

    expandFolder

    functionexpandFolder(folder)

    Expands a folder or an array of folders.

    Parameter

    folder Either a single folder primitive or an array of folder primitives.

    See also

    collapseFolder, getCollapsed

    getCollapsed

    functiongetCollapsed(folder)

    Returns whether or not a given folder is collapsed.

    Parameter

    folder The folder for which the collapsed state is requested.

    Return

    True is the folder is collapsed, false if it is expanded.

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    31/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 3

    See also

    collapseFolder, expandFolder

    getParent

    functiongetParent(primitive)

    Gets the parent folder for a primitive.

    Parameters

    primitive The primitive for which the parent folder will be returned. May also be an array of primitives.

    Return

    The parent folder. Returns null if the primitive is not in a folder.

    See also

    setParent

    setParent

    functionsetParent(primitive,

    parent,

    perserveLoc)

    Sets the parent folder for a primitive.

    Parameters

    primitive The primitive for which the parent folder will be set. May also be an array of primitives in whichcase they will all be set to the same parent.

    parent The parent folder primitive. Use null to remove the primitive from all folders.

    See also

    getParent

    getChildren

    functiongetChildren(folder,

    recursive)

    Returns the children of a folder.

    Parameters

    folder The folder for which the children will be returned.

    recursive Optional. Whether the children of inner folders will be returned. Defaults to t rue.

    Return

    The children primitves of the folder.

    getFolderType

    functiongetFolderType(folder)

    Gets the type of a folder.

    Parameters

    folder The folder for which the type is requested. May also be an array of folders.

    Return

    The type mode as a string. May be None or Agent.

    See also

    setFolderType

    setFolderType

    functionsetFolderType(folder,

    type )

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    32/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 32

    Sets the type of a folder.

    Parameters

    folder The folder for which the type will be set. May also be an array of folders.

    type The type mode as a string. May be None or Agent.

    See also

    getFolderType

    getFolderAgentParent

    functiongetFolderAgentParent(folder)

    Gets the agent parent of a folder.

    Parameters

    folder The folder for which the agent parent is requested. May also be an array of folders.

    Return

    The agent parent as a string.

    See also

    setFolderAgentParent

    setFolderAgentParentfunctionsetFolderAgentParent(folder,

    agentParent)

    Sets the agent parent of a folder.

    Parameters

    folder The folder for which the type will be set. May also be an array of folders.

    agentParent The agent parent as a string.

    See also

    getFolderAgentParent

    getFolderSolver

    functiongetFolderSolver(folder)

    Gets the solver configuation for a folder. The configuration is an object with the properties

    enabled true is the folder should have its own solver

    algorithm the solution algorithm. Current allowed values are RK1 for Eulers method and RK4 for afourth order Runge-Kutta method

    timeStep the time step for the folders solver

    Parameters

    folder The folder for which the solver is requested. May also be an array of folders.

    Return

    The solver object

    See also

    setFolderSolver

    setFolderSolver

    functionsetFolderSolver(folder,

    solver )

    Sets the solver object for a folder

    Parameters

    folder The folder for which the solver will be set. May also be an array of folders.

    solver The solver object

    http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    33/34

    4/9/2014 Insight Maker API

    https://insightmaker.com/sites/default/files/API/files/API-js.html 33

    See also

    getFolderSolver

    UTILITYFUNCTIONS

    excludeType

    functionexcludeType(array,

    type )

    Removes a specific type of primitive from an array of primitives.

    Parameter

    array An array of primitives.

    type The t ype of primitives to remove.

    Return

    A duplicate of the input array without any primitives of the specified type.

    primitiveIndex

    functionprimitiveIndex(array,

    primitive)

    Locates the index of a spec ific primitive in an array of primitives.

    Parameter

    array An array of primitives.

    primitive The specific primitive to find.

    Return

    The index of the primitive in the array. Returns -1 if the primitive is not found.

    uniquePrimitives

    functionuniquePrimitives(primitives)

    Returns the passed array with duplicated primitives removed

    Parameter

    primitives An array of primitives.

    Return

    An array of primitives with any duplicated elements removed.

    setGlobal

    Sets t he value of a global variable. This can allow communication between butt ons or the storing of some state.

    Parameter

    name The name of the global variable.

    value The value of the global variable.

    See also

    getGlobal

    getGlobal

    functiongetGlobal(name)

    Gets the value of a global variable. This can allow communication between butt ons or the storing of some state.

    Parameter

    name The name of the global variable for which to get the value.

    Return

    http://-/?-http://-/?-
  • 8/11/2019 Insight Maker API

    34/34

    4/9/2014 Insight Maker API

    The value of the global variable specified by name.

    Example

    setGlobal("Example Var 1", 42);

    setGlobal("Example Var 2", "test");

    varz = getGlobal("Example Var 1"); // z is now set to 42

    vary = getGlobal("Example Var 2"); // y is now set to "test"

    See also

    setGlobal

    INSIGHTMAKERINTERFACE

    topBarShown

    functiontopBarShown()

    Determines whether or not the Insight Maker top t oolbar (which contains the Run Simulation button and other tools)is currently shown.

    Return

    True if the top toolbar is shown, false otherwise.

    See also

    toggleTopBar

    toggleTopBar

    functiontoggleTopBar()

    Toggles the visibility of the top toolbar. If it is currently shown, it is hidden. If it is currently hidden, it is shown.

    See also

    topBarShown

    sideBarShown

    functionsideBarShown()

    Determines whether or not the Insight Maker side panel (which contains parameter sliders and information about theselected primitive) is currently shown.

    Return

    True if the side panel is shown, false otherwise.

    See also

    toggleSideBar

    toggleSideBar

    functiontoggleSideBar()

    Toggles the visibility of t he side panel. If it is currently shown, it is hidden. If it is currently hidden, it is shown.

    See also

    sideBarShown

    updateSideBar

    functionupdateSideBar()

    Refreshes the values in the side panel to reflect any changes in the model.

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-