Finding or Replacing Data

This chapter covers the following topics:

Find and Replace Overview

If you want to determine which nodes or arcs in a model have certain characteristics and data values, you can perform a find on the nodes and arcs that meet specific criteria. Nodes that are found can also be selected. The system can highlight selected nodes to enable you to see which nodes or arcs have the specified characteristics. For example, you can perform a find on all machine nodes with 100 percent utilization and these nodes can then be selected.

You set up searches by using combinations of numeric or character values, expressions, and wildcard characters. When the system completes a search, it displays a message that indicates the number of results found. A User set that is named -Found is also created. You can locate nodes or arcs in an entire model. You can select nodes or arcs in a model and determine which of the selected nodes or arcs have particular characteristics. You can select nodes or arcs in one time period of a model and determine which of the selected nodes or arcs meet specified criteria in all time periods of the model. You can also restrict a search to nodes or arcs in a set.

Your ability to find numeric values correctly is partly determined by the number of decimal places displayed in properties windows. For example, if the Display Precision is set to zero, you do not see decimal points in the Properties window; the system truncates the values. With Display Precision equal to zero, a Storage value of 1300.7 appears as 1300 in the Properties window. However, if you set up a search and indicate that Storage equals 1300, the system does not select the node.

You can also use comparison symbols, such as =, <, >, AND, OR, and XOR. In addition, in Find windows, you can begin an expression with a comparison symbol. The left-hand side is the implied field name.

Examples

Assume that you have spherical tanks modeled as Storage nodes and you want to find the nodes in which the value in the maximum volume field is greater than or equal to your 10-m radius tanks. To find the nodes, you would enter the following expression in the Max field of a Storage Find window:

x>=4/3*PI()*POWER(10,3)

This formula finds a Storage node only when the value in the Max field is greater than or equal to the calculated value of the following equation:

UNRECOGNIZED STYLE ->class=CBLinkScreen>[INT: 483331] 

In the next example, assume that you want to find demand data points that are outside of the average demand values. You could use the following expression in the Demand field of a StorageDemand Find window:

x <= AVEPERIODS(#Demand)*.8 OR x >= AVEPERIODS(#Demand)*1.2

This expression finds results only when the value in the Demand field is 20 percent above or 20 percent below the average value for demand across all periods.

Exporting Results from a Find

You can also find nodes and arcs in a model that have certain qualities and export the data to a file. For example, you can find all Machine nodes with a utilization of 100 percent and then export their names to a file.

When a find is completed, a message window displays the total number of nodes and arcs found, and they are then selected. The system also creates a User set named -Found. The data is exported to the file specified in the File name field.

The Export tab in the Find and Export window allows you to specify which fields are exported, as shown here below:

You can find and export all nodes or arcs in a model, selected nodes or arcs, or nodes or arcs in a set.

Find and Replace Pattern Overrides

You can use overrides in any unused field of the Find and Replace window. The syntax is as follows:

override=expression

The possible values for override are:

where n is the block level.

The expression can be any regular find expression, and can include wildcard characters.

Example: Using Find Pattern Overrides

The following table displays examples for using find pattern overrides:

Override Finds
commodityfamily=Fam1|Fam2|Fam3 Arcs that carry a commodity with the family name Fam1, Fam2, or Fam3
location=Factory 1 Nodes of a certain kind in the block Factory 1
commoditydescription=*Export* Arcs that carry a commodity with a description that contains the word Export
blockname:1=Group 2 Nodes of a certain kind with an immediate parent block has the name Group 2

Expressions and Functions

You can use expressions and functions in Find windows to locate data. An expression can be made up of the following components:

Component Example Explanation
Number 400 Any number.
Variable x Represents the field name. Optional in Find windows and report queries.
Field name Demand The field name is the name of a field in a Find, Replace, or Report Properties window. If the field name contains spaces, enclose it in double quotation marks.
Some functions require a # before the field name.
Symbol + - * / () Addition, subtraction, multiplication, division; use round brackets to specify order of operations.
Function ABS(Demand) The functions you can use are largely the same as those available in the Data Editor.

You can use the comparison symbols in the following table.exp1and exp2 represent expressions.

Expression Meaning
exp1 = exp2 Returns true if the expressions are equal. Otherwise, returns false.
exp1 != exp2
exp1 <>
Returns true if the expressions are not equal. Otherwise, returns false
exp1 < exp2 Returns true if exp1 is less than exp2. Otherwise, returns false.
exp1 > exp2 Returns true if exp1 is greater than exp 2. Otherwise, returns false.
exp1 <= exp2 Returns true if exp1 is less than or equal to exp 2. Otherwise, returns false.
exp1 <= exp2 Returns true if exp1 is greater than or equal to exp 2. Otherwise, returns false.
exp1 AND exp2 Returns true if both expressions are non-zero or true. Otherwise, returns false.
exp1 OR exp2 Returns true if one or both expressions are non-zero or true. Otherwise, returns false.
exp1 XOR exp2 Returns true if exactly one expression is non-zero or true. Otherwise, returns false.

You can start an expression with a comparison symbol. The left side is the implied field name.

The following general syntax rules must be followed in all functions and expressions:

The following are examples of valid expressions:

Demand*100
IF(x>10000,x/10,x)
COS(Value)

Performing a Find

Performing a Find on Selected Nodes or Arcs

You can perform a find on all nodes and arcs in a model or on selected nodes or arcs in a model. The find can be performed on the current period or on all the periods in the model.

To perform a find:

  1. Do one of the following:

    • Select the nodes and arcs on which you want to perform the find. From the Edit menu, select Find, then Nodes or Arcs.

    • Right-click a node or arc and select Find. The Find and Replace window appears.

  2. In the Scope area, for Period(s) select either All or Current. For Search, choose Selected.

  3. Enter the expressions or data that you want to find in the appropriate fields.

  4. Optionally, you can click the Add To Favorites button to save the find criteria as a favorite in the Model Workspace.

  5. Click the Find button.

The Results tab lists the found nodes or arcs.

To perform a find on all nodes or arcs in a model:

  1. From the Edit menu, select Find, then Nodes or Arcs.

  2. In the Scope area of the Find and Replace window, for Period(s) select either All or Current.

  3. For Search, choose Model.

  4. In the Find In drop-down list, select Arc to perform the find on all arcs in the model. Select Node (all types) to perform the find on all nodes in the model.

  5. Enter the expression or data that you want to find in the appropriate fields.

  6. Optionally, you can click the Add To Favorites button to save the find criteria as a favorite in the Model Workspace

  7. Click the Find button.

The Results tab lists the found nodes or arcs.

Find Results

When a Find is performed, the Results tab is automatically displayed in the Find and Replace window. The Results tab displays a list of all found nodes or arcs

To launch properties windows from the Results tab:

  1. Select a node or arc from the list.

  2. In the Properties drop-down list, select Single-Period, Multi-Period, or Bar Chart.

  3. Click the View button.

Click the Show button to unblock and display all found nodes or arcs in the model workspace.

Performing a Replace

Replace Results

After a find is performed, you can perform a replace in the found nodes or arcs. The scope of the replace is the same as the scope of the find. For example, if the find was performed on only the current period but for the entire model, the replace is only performed on the current period but for the entire model.

To perform a find and replace for selected nodes and arcs:

  1. From the Edit menu, select Find, then Nodes or Arcs.

  2. In the Find and Replace window, click the Replace tab.

  3. In the appropriate fields, enter the expressions or data that you want to replace.

  4. Click the Replace button.

When a replace is performed, the Replace Results window appears. In the Replace Results window, the From column displays data before the replace, and the To column displays the data after the replace. You can launch properties windows and undo a replace in the Replace Results window.

To launch properties windows from the Replace Results window:

  1. Select a node or arc from the list.

  2. In the Properties drop-down list, select Single-Period, Multi-Period, or Bar Chart.

  3. Click the View button.

To undo the changes made in a replace, click the Undo All button.

To export the results of a find:

  1. In the Export tab of the Find and Replace window, select the fields to export.

  2. Click the Export button.

  3. In the Export As window, specify a name and location for the export file and click the Save button.