Defining DesignXplorer Properties

An external sampling or optimization method can expose settings to allow the user to control algorithm options and view outputs.

For instance:

ACT provides support for the general definition of properties with attributes and callbacks. Each setting to expose to the DesignXplorer user must be declared and defined in the XML extension definition file as a <property> block under the <sampling> or <optimizer> block.

<property name="[property internal name (string)]"
        caption="[property display name (string)]"
        readonly="[true | false(default)]"
        default="[default value]"
        control="[text(default) | select | float | integer | ...]"
        visible="[true(default) | false]"
        visibleon="[values(separator '|')]"
        ...
        <attributes>mldr</attributes>
        <callbacks>
</property>

Optionally, settings can be placed together in groups. Each group must be declared and defined in the XML file as a <propertygroup> block under the <sampling> or <optimizer> block.

For a description of common attributes and callbacks, see "property" in the "XML Tags" section of the ANSYS ACT API Reference Guide for DesignXplorer. For more information on settings groups, see "propertygroup" in the ANSYS ACT XML Reference Guide.

Properties in the DesignXplorer Interface

An external method can be selected in DesignXplorer for Design of Experiments Type for a DOE or Method Name for an optimization. When an external method is selected, its properties are shown in the Properties view.

For example, the following figure shows the Properties view when the external sampling named Full Factorial is selected for Design of Experiments Type.

 

This next figure shows the Properties view when the external optimizer named Python Optimizer is selected for Method Name.

 

By default, properties are shown under the General category. If a propertygroup is specified, the corresponding category is created in the property view. The properties under the General and respective Status categories are specific to the external method and are defined in the XML file.

If the sampling supports the LogFile capability, the property LogFile is automatically defined under the Status category in the Properties view. Once the sampling is generated or the optimization has been run, the user can view the log file in a dialog box by clicking the available link.

Additional Attributes for DesignXplorer Extensions

In the context of sampling and optimization extensions, DesignXplorer also recognizes the additional attributes min, max, and advanced for each property. The attributes min and max are used to specify a minimum value, maximum value, or both values for a double or integer property.

In the following sampling example, the minimum value is 1 and the maximum value is 100.

<property name="NumberOfLevels" caption="Number of Levels" control="integer" default="3">
        <attributes min="1" max="100"/>
</property>

In the following optimization example, the minimum value is 2 and the maximum value is 200.

<property name="MyNumberOfSamples" caption="My Number of Samples" control="integer" default="50">
        <attributes min="2" max="200"/>
</property>

The attribute advanced is used to classify the property as an advanced option. Advanced options are visible only if activated. To activate them, in the Options dialog box, select the Show Advanced Options check box on the Design Exploration tab.

The following example is applicable to either type of DesignXplorer extension.

<property name="MyRandomNumber" caption="My Random Number provider" control="select" 
default="Python">
        <attributes options="Python,CLibrary" advanced="true"/>
</property>

Advanced Usage Examples

The following advanced examples illustrate the use of properties in DesignXplorer extensions.

Managing Dependencies between Properties

The following example demonstrates how to manage the dependency between properties:

  • Prop1 is visible when the value Group3 is equal to Option 1

  • Prop2 is visible when the value Group3 is equal to Option 1 or Option 2

  • Prop3 is visible when the value Group3 is equal to Option 3

<propertygroup name="Group3" caption="Group Select" display="property" control="select" 
default="Option 1">
        <attributes options="Option 1,Option 2,Option 3" />
        <property name="Prop1" caption="Prop For Option 1" visibleon="Option 1" control="text" />
        <property name="Prop2" caption="Prop For Option 1 and Option 2" visibleon="Option 1|Option 2"
            control="text" />
        <!-- Prop3 is applicable and visible only when Group3 == "Option 3" -->
        <property name="Prop3" caption="Prop For Option 3" visibleon="Option 3" control="text" />
</propertygroup>
Controlling Property Visibility with a Callback

Property attributes, such as visibility, can be modified dynamically by using a callback.

DOE Example

The following example shows how to control the visibility of the property PropForSingleInput with a callback coded in IronPython:

<property name="PropForSingleInput" caption="My Property for single input parameter" 
control="text">
        <callbacks>
          <isvisible>isVisibleForSingInput</isvisible>
        </callbacks>
</property>

Where the function isVisibleForSingInput is defined by the following IronPython code:

def isVisibleForSingInput(entity,property):
   if entity.NumberOfObjectivesDefined <= 1:
        return True
    return False

The function isVisibleForSinglnputfunction takes two arguments:

  • The first argument-named entity is of type DXUserSampling.

  • The second argument-named property is of type SimProperty.

This function returns True when only one input parameter is defined.

Optimization Example

The following example shows how to control the visibility of the property PropForSingleObjective with a callback coded in IronPython:

<property name="PropForSingleObjective" caption="My Property for single-objective optimization" 
control="text">
        <callbacks>
          <isvisible>isVisibleForSOO</isvisible>
        </callbacks>
</property>

Where the function isVisibleForSOO is defined by the following IronPython code:

def isVisibleForSOO(entity,property):
    if property.Name != PropForSingleObjective
      return True
    if entity.NumberOfObjectivesDefined <= 1:
        return True
    return False

The function isVisibleForSOO takes two arguments:

  • The first argument-named entity is of type DXUserOptimizer.

  • The second argument-named property is of type SimProperty.

This function returns True when only one objective is defined.

Modifying an Attribute with a Callback

The following examples show how you can modify the values property attributes when input parameters are edited by the user.

DOE Example

This example shows how you can modify the values of the attribute max for the property NumberOfLevels when input parameters are edited by the user.

Given the partial sampling definition:

<sampling …>
  <callbacks>
    <InputParametersEdited>InputParametersEdited</InputParametersEdited>
  </callbacks>
  <property name="NumberOfLevels" caption="Number of Levels" control="integer" default="3"/>
    <attributes min="1"> 
  </property> 
</sampling>

The function InputParametersEdited is defined by the following IronPython code:

def InputParametersEdited(entity):
    entity.Properties["NumberOfLevels"].Attributes["max"]=3*entity.NumberOfInputParametersDefined

The function InputParametersEdited is called when a user edits the input parameters. This function calculates the new minimum allowed value for the property NumberOfLevels from the current number of input parameters and then sets this value to the attribute max.

Optimization Example

This example shows how you can modify the values of the attribute min for the property MyNumberOfSamples when input parameters are edited by the user.

Given the partial optimizer definition:

<optimizer …>
  <callbacks>
    <InputParametersEdited>InputParametersEdited</InputParametersEdited>
  </callbacks>
  <property name="MyNumberOfSamples" caption="My Number of Samples" control="integer" default="50" />
</optimizer>

The function InputParametersEdited is defined by the following IronPython code:

def InputParametersEdited(entity):
    entity.Properties["MyNumberOfSamples"].Attributes["min"]=10*entity.NumberOfInputParametersDefined

The function InputParametersEdited is called when input parameters are edited by the user. It calculates the new minimum allowed value for the property MyNumberOfSamples from the current number of input parameters and then sets this value to the attribute min.


Release 18.2 - © ANSYS, Inc. All rights reserved.