Navigation: Scripting Reference Manual > Data Structures > T_MZRVARIABLE

 

T_MZRVARIABLE

 

Contact Us: fredsupport@photonengr.com

 

Description

Structure corresponding to entries on the Optimization Variables Tab of the Optimization dialog.

 

Definition

Type T_MZRVARIABLE

currentvalue As Double
initialvalue As Double
upperlimit As Double
lowerlimit As Double
fracstep As Double

entity As Long
index As Long
subindex As Long
fractionvar As Long
description As String
type As String
script As String
active As Boolean

End Type

 

Members

currentvalue

Current value of variable.

 

initialvalue

Corresponds to the "Previous Value" column as displayed in the Define/Edit Optimization dialog in the GUI.  Indicates the variable value at the beginning of the previous optimization.  FRED retrieves and displays this value after an optimization cycle is completed.

 

upperlimit

Variable upper limit.

 

lowerlimit

Variable lower limit.

 

fracstep

Fraction of the variable's upper-to-lower limit distance applied to variables when setting the initial simplex at the beginning an optimization execution.

 

entity

Node number of entity related to variable.

 

index

Index of variable. See Optimization Variables.

 

subindex

Sub-Index of variable. See Optimization Variables.

 

fractionvar

Index of variable to which current variable is a fraction. Use -1 for "not fraction".

 

description

Text description of variable.

 

type

Specifies the variable type. Options are:

Position/Orientation parameter

Thickness of a lens element

SuperGaussian coefficient

Curvature

User-defined script

SuperGaussian position X

Conic constant (-1=parabola,0=sphere,etc.)

Max Z coordinate of trimming volume

SuperGaussian position Y

Aspheric even power coefficient

Min Z coordinate of trimming volume

SuperGaussian width X

X component of a NURB control point

Max Y coordinate of trimming volume

SuperGaussian width Y

Y component of a NURB control point

Min Y coordinate of trimming volume

SuperGaussian rotation angle

Z component of a NURB control point

Max X coordinate of trimming volume

User-defined script (extra parameters)

Weight of a NURB control point

Min X coordinate of trimming volume

 

Bending parameter of a lens element

Parameter value of an element primitive

 

Power of a lens element

Source power

 

 

script

String containing complete user-defined script, if the variable type requires it.

 

active

Flag to enable/disable variable.

 

 

Example

The following example loops over the optimization results list and writes out the data for each result to a text file using a custom subroutine.

 

Sub Main

 

 

    'File where optimization results are being written

    Dim outFile As String

    outFile = "C:\temp\optimizationResults.txt"

    Open outFile For Output As #1

 

    'Number of results in the current list

    Dim numResults As Long

    numResults = GetMzrResultCount()

 

    'Loop over results, write to file

    Dim res As T_MZRRESULT

    Dim curResult As Long

    For curResult = numResults-1 To 0 Step -1

        GetMzrResult( curResult, res )

        printResultToFile( res )

    Next curResult

 

    'Close output file

    Close #1

 

End Sub

 

Sub printResultToFile( ByVal res As Variant )

 

    'Print result generic info

    Print #1, "BEGIN RESULT INFO"

    Print #1, Chr(9) & "Comment: " & res.comment

    Print #1, Chr(9) & "Merit Function: " & res.meritfunc

    Print #1, ""

 

    'Print result variable information

    Dim curVar As Long

    For curVar = 0 To UBound( res.variables, 1 )

        Print #1, Chr(9) & "Variable " & curVar & ":"

        Print #1, Chr(9) & Chr(9) & "Active: " & res.variables(curVar).active

        Print #1, Chr(9) & Chr(9) & "Value: " & res.variables(curVar).currentvalue

        Print #1, Chr(9) & Chr(9) & "Description: " & res.variables(curVar).Description

        Print #1, Chr(9) & Chr(9) & "Entity: " & res.variables(curVar).entity

        Print #1, Chr(9) & Chr(9) & "Fraction Step: " & res.variables(curVar).fracstep

        Print #1, Chr(9) & Chr(9) & "Fraction Variable: " & res.variables(curVar).fractionvar

        Print #1, Chr(9) & Chr(9) & "Index: " & res.variables(curVar).index

        Print #1, Chr(9) & Chr(9) & "Previous Value: " & res.variables(curVar).initialvalue

        Print #1, Chr(9) & Chr(9) & "Lower Limit: " & res.variables(curVar).lowerlimit

        Print #1, Chr(9) & Chr(9) & "Script: " & res.variables(curVar).Script

        Print #1, Chr(9) & Chr(9) & "Sub-index: " & res.variables(curVar).subindex

        Print #1, Chr(9) & Chr(9) & "Type: " & res.variables(curVar).Type

        Print #1, Chr(9) & Chr(9) & "Upper Limit: " & res.variables(curVar).upperlimit

        Print #1, ""

    Next curVar

 

End Sub

 

 

See Also

Optimization Script Commands

T_MZRRESULT

 

 

 

 

 

 

Copyright © Photon Engineering, LLC