Response#

Library of response objects and base classes to create your own objectives and constraints.

class DeviationSquared(**kwds)#
Computes the difference between a function’s current value and a desired value.

The math formula used by DeviationSquared is defined as follows:

\[Response = \frac{1}{2} \left( 1 - \frac{f_{c}}{f_{d}} \right) ^2\]

where:

  • \(f_{c}\) is the current value of a function,

  • \(f_{d}\) is its desired value,

  • \(s\) is the error in the function.

Usage Example:

Compute the deviation of VX(22,11)@T=1 from a desired value of: 3.14159.#
val = DeviationSquared (label        = "VX(22,11)@T=1",
                        signal       =  vx2211At1,
                        desiredValue = 3.14159,
                        )

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

id

Int

Auto

label

Str

measuredValue

Reference - ValueAtTime

\(\checkmark\)

name

Str

plot

Bool

False

scale

Double

1.0

sensitivity

Bool

True

targetValue

Double

0.0

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

id#

The id of the object.

Type=Int

label#

Label string for the Response.

Type=Str

measuredValue#

Value of the RV associated with DeviationSquared.

Type=Reference (ValueAtTime), Required

name#

Defines a nametag for the object.

Type=Str

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

targetValue#

Desired value of the RV associated with DeviationSquared.

Type=Double, Default=0.0

class GenericResponse(**kwds)#
Creates a generic response.

This response is a layer over the Rv element that links it to the plotting and optimization functionalities.

Usage Examples:

Generic Response using run time Expression.#
gr = GenericResponse (label    = "Generic Response",
                      function = "(1-FZ(21,31)/501)**2",
                      scale    = 1e5
                     )
Generic Response using User written subroutine.#
gr = GenericResponse (label    = "Generic Response",
                      routine  = mygenericResponse,
                      scale    = 1e5
                     )

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

end

Double

function

Function

id

Int

Auto

label

Str

name

Str

plot

Bool

False

routine

Routine

scale

Double

1.0

script

Script

sensitivity

Bool

True

start

Double

useDeriv

Bool

False

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

end#

Specify the end time of the window of interest.

Type=Double

function#

Function expression for GenericResponse.

Type=Function

id#

The id of the object.

Type=Int

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

routine#

User subroutine for GenericResponse.

Type=Routine

scale#

Scaling factor of Response.

Type=Double, Default=1.0

script#

Path and name of the script that contains the routine.

Type=Script

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

start#

Specify the starting time of the window of interest.

Type=Double

useDeriv#

True if derivative of the function is to be used as response.

Type=Bool, Default=False

class MaxVal(**kwds)#
Computes the approximate maximum value of a MotionSolve expression or a user subroutine during the simulation.

The maximum is approximated by an alpha-soft function so that the analytical sensitivity can be calculated. The math formula used by MaxVal is defined as follows:

\[max(x) = \frac{ \int_{t} x(t) e^{a x{t}} dt }{ \int_{t} e^{a x{t}} dt }\]

where:

  • \(a = coef > 0\)

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

alpha

Double

10.0

coef

Double

1.0

end

Double

function

Function

\(\checkmark\)

id

Int

Auto

k

Int

1

label

Str

name

Str

nominal

Double

0.0

plot

Bool

False

routine

Routine

scale

Double

1.0

script

Script

sensitivity

Bool

True

start

Double

threshold

Double

2.0

wlen

Int

5

See also

See Comment 1 for more information.

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

alpha#

Coef being used in the approximation of extremum.

Type=Double, Default=10.0

coef#

Coefficient used in the approximation of maximum, alpha=coef.

Type=Double, Default=1.0

end#

Specify the end time of the window of interest.

Type=Double

function#

Solver function that defines the extremum being computed.

Type=Function, Required

id#

The id of the object.

Type=Int

k#

The order of the smoothing function.

Type=Int, Default=1

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

nominal#

Estimated value of extremum being calculated.

Type=Double, Default=0.0

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

routine#

An alternative name for the user subroutine.

Type=Routine

scale#

Scaling factor of Response.

Type=Double, Default=1.0

script#

Path and name of the script that contains the routine.

Type=Script

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

start#

Specify the starting time of the window of interest.

Type=Double

threshold#

The threshold value of the sensor.

Type=Double, Default=2.0

wlen#

The window length for the smoothing function.

Type=Int, Default=5

class MinVal(**kwds)#
Computes the approximate minimum value of a MotionSolve expression or a user subroutine during the simulation.

The minimum is approximated by an alpha-soft function so that the analytical sensitivity can be calculated. The math formula used by MinVal is defined as follows:

\[min(x) = \frac{ \int_{t} x(t) e^{a x{t}} dt }{ \int_{t} e^{a x{t}} dt }\]

where:

  • \(a = -coef > 0\)

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

alpha

Double

10.0

coef

Double

1.0

end

Double

function

Function

\(\checkmark\)

id

Int

Auto

k

Int

1

label

Str

name

Str

nominal

Double

0.0

plot

Bool

False

routine

Routine

scale

Double

1.0

script

Script

sensitivity

Bool

True

start

Double

threshold

Double

2.0

wlen

Int

5

See also

See Comment 1 for more information.

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

alpha#

Coef being used in the approximation of extremum.

Type=Double, Default=10.0

coef#

Coefficient used in the approximation of minimum, alpha=-coef.

Type=Double, Default=1.0

end#

Specify the end time of the window of interest.

Type=Double

function#

Solver function that defines the extremum being computed.

Type=Function, Required

id#

The id of the object.

Type=Int

k#

The order of the smoothing function.

Type=Int, Default=1

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

nominal#

Estimated value of extremum being calculated.

Type=Double, Default=0.0

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

routine#

An alternative name for the user subroutine.

Type=Routine

scale#

Scaling factor of Response.

Type=Double, Default=1.0

script#

Path and name of the script that contains the routine.

Type=Script

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

start#

Specify the starting time of the window of interest.

Type=Double

threshold#

The threshold value of the sensor.

Type=Double, Default=2.0

wlen#

The window length for the smoothing function.

Type=Int, Default=5

class RMS2(**kwds)#
Computes the root-mean-square area difference between a measured signal and a target curve.

The math formula used by RMS2 is defined as follows:

\[Response = \int_{0}^{T} (y-y^{*})^2 dt\]

where:

  • \(y\) is the measured value,

  • \(y^{*}\) is the interpolated value based on the value of the state variable.

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

end

Double

id

Int

Auto

independentVariable

Reference - Variable [0]

label

Str

mean

Double

0

measuredValue

Function

name

Str

plot

Bool

False

routine

Routine

scale

Double

1

script

Script

sensitivity

Bool

True

start

Double

std

Double

0

targetValue

CurveProperty

\(\checkmark\)

xValue

Reference - RMS2

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

end#

Specify the end time of the window of interest.

Type=Double

id#

The id of the object.

Type=Int

independentVariable#

Independent Variable in RMS2.

Type=Reference (Variable) [0]

label#

Label string for the Response.

Type=Str

mean#

Mean value of normal distribution used in weighting.

Type=Double, Default=0

measuredValue#

Runtime function expression that defines measured value.

Type=Function

name#

Defines a nametag for the object.

Type=Str

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

routine#

Type=Routine

scale#

Scaling factor of RMS2.

Type=Double, Default=1

script#

Type=Script

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

start#

Specify the starting time of the window of interest.

Type=Double

std#

Standard deviation of normal distribution used in weighting.

Type=Double, Default=0

targetValue#

List of datum that defines the sample points.

Type=CurveProperty, Required

xValue#

Type=Reference (RMS2)

class Response(**kwds)#

The base class for all objectives

The optimizer requires the methods:

responseCost responseSensitivity

The optimizer breadcrumbs the member lastComputedCost

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

big#

Type=Double, Default=10000000000.0

end#

Specify the end time of the window of interest.

Type=Double

id#

The id of the object.

Type=Int

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

small#

Type=Double, Default=1e-08

start#

Specify the starting time of the window of interest.

Type=Double

class ResponseExpression(**kwds)#
Computes the value of an arbitrary function that is composed of design variables and other responses.

It employs the chain rule to compute the sensitivity using sympy to calculate the partial derivatives.

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

function

Str

\(\checkmark\)

id

Int

Auto

label

Str

name

Str

plot

Bool

False

scale

Double

1.0

sensitivity

Bool

True

symbols

Property [0]

\(\checkmark\)

variables

Property [0]

\(\checkmark\)

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

function#

An expression of DVs and RVs whose value is required.

Type=Str, Required

id#

The id of the object.

Type=Int

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

symbols#

Symbols used in expression.

Type=Property [0], Required

variables#

Variables that are referred by Symbols.

Type=Property [0], Required

class SignalDistance(**kwds)#

Computes the distance between two signals by dynamic time warping.

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

end

Double

gamma

Double

0.01

id

Int

Auto

label

Str

name

Str

numPoints

Int

10

periods

Int

1

plot

Bool

False

scale

Double

1.0

sensitivity

Bool

True

signal

Reference - Variable [0]

\(\checkmark\)

start

Double

targetSignal

Property [0]

\(\checkmark\)

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

end#

Specify the end time of the window of interest.

Type=Double

gamma#

Type=Double, Default=0.01

id#

The id of the object.

Type=Int

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

numPoints#

Type=Int, Default=10

periods#

Type=Int, Default=1

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

signal#

Type=Reference (Variable) [0], Required

start#

Specify the starting time of the window of interest.

Type=Double

targetSignal#

Type=Property [0], Required

class Slope2(**kwds)#
Computes the slope of a curve at a particular point of interest \(t^{*}\).

The math formula used by Slope2 is defined as follows:

\[Response = \frac{f(t_{2}) - f(t_{1})}{t_{2} - t_{1}}\]

where:

\(t_{1} < t^{*} < t_{2}\)

Usage Example:

Compute the slope of Toe vs Ride Height at design position (T=5).#
val = Slope2 (label       = "Slope2",
              numerator   = "<Toe_Expression>",
              denominator = "<Ride_Height_Expression>",
              time        = 5,
              delta       = 0.1,
              interval    = 1e-3,   # Optional
             )

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

delta

Double

0.1

denominator

Function

\(\checkmark\)

id

Int

Auto

interval

Double

label

Str

name

Str

numerator

Function

\(\checkmark\)

plot

Bool

False

scale

Double

1.0

sensitivity

Bool

True

time

Double

\(\checkmark\)

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

delta#

Time span at the start&end of which the signal is evaluated.

Type=Double, Default=0.1

denominator#

MS expression for denominator.

Type=Function, Required

id#

The id of the object.

Type=Int

interval#

Interval over which the signal is averaged.

Type=Double

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

numerator#

MS expression for numerator.

Type=Function, Required

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

time#

Time at which the slope is calculated.

Type=Double, Required, Default=0.0

class Slope2Deviation(**kwds)#
Computes the square of the deviation of the slope of a curve at a certain point in time from a target value.

The math formula used by Slope2Deviation is defined as follows:

\[Response = \left( 1 - \frac{m}{m_{d}} \right) ^2\]

where:

  • \(m\) is the slope of a curve at the point of interest,

  • \(m_{d}\) is the target value.

It has all the properties Slope2 has plus the targetValue of the slope.

Usage Example:

Compute the deviation of the slope of TOE vs. DZ at design position (T=5) from a desired value of 3.14159.#
val = Slope2Deviation(label       = "Slope2",
                      numerator   = "<Toe_Expression>",
                      denominator = "<Ride_Height_Expression>",
                      time        = 5,
                      delta       = 0.1,
                      interval    = 1e-3,    # Optional
                      targetValue = 3.14159
                      )

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

delta

Double

0.1

denominator

Function

\(\checkmark\)

id

Int

Auto

interval

Double

label

Str

name

Str

numerator

Function

\(\checkmark\)

plot

Bool

False

scale

Double

1.0

sensitivity

Bool

True

targetValue

Double

\(\checkmark\)

time

Double

\(\checkmark\)

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

delta#

Time span at the start&end of which the signal is evaluated.

Type=Double, Default=0.1

denominator#

MS expression for denominator.

Type=Function, Required

id#

The id of the object.

Type=Int

interval#

Interval over which the signal is averaged.

Type=Double

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

numerator#

MS expression for numerator.

Type=Function, Required

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

targetValue#

Desired value of the slope.

Type=Double, Required, Default=0.0

time#

Time at which the slope is calculated.

Type=Double, Required, Default=0.0

class ValueAtG(**kwds)#
Computes the value of a signal, \(f\) when a second signal \(G\) achieves a certain value \(C\).

The math formula used by ValueAtG is defined as follows:

\[Response = \frac{\int_{t_{0}}^{t_{f}} f(Q,U,U_{d}) w(t) dt} {\int_{t_{0}}^{t_{f}} w(t) dt}\]

where:

  • \(w(t) = Step (G, C-Delta, 0, C, 1) + Step (G, C, 1, C+Delta, 0) - 1\)

Usage Example:

Compute the steer angle difference when the steering wheel angle is ZERO.#
t0      = 0
tf      = 2
delta   = 1e-3
gvalue  = 0

# Steering wheel angle
gsignal = "AZ(77,66)"

# Steering angle difference: Yaw(Left-wheel) - Yaw(right-wheel)
fsignal = "Yaw(33,22) - Yaw(55,44)"

val = ValueAtG (label   = "Steer Angle DIfference at Zero SWA",
                fsignal = fsignal,
                gsignal = gsignal,
                gvalue  = gvalue,
                delta   = delta
               )

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

delta

Double

\(\checkmark\)

fsignal

Function

\(\checkmark\)

gsignal

Function

\(\checkmark\)

gvalue

Double

\(\checkmark\)

id

Int

Auto

label

Str

name

Str

plot

Bool

False

scale

Double

1.0

sensitivity

Bool

True

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

delta#

The interval around ‘gvalue’ used to define the impulse function.

Type=Double, Required, Default=0.0

fsignal#

Function representing a signal whose value is required.

Type=Function, Required

gsignal#

The reference signal associated with fsignal.

Type=Function, Required

gvalue#

Value of gsignal at which fsignal is to be computed .

Type=Double, Required, Default=0.0

id#

The id of the object.

Type=Int

label#

Label string for the Response.

Type=Str

name#

Defines a nametag for the object.

Type=Str

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True

class ValueAtTime(**kwds)#
Computes the value of a signal at a certain time T.

The math formula used by ValueAtTime is defined as follows:

\[Response = \frac{\int_{t_{0}}^{t_{f}} f(Q, U, U_{d})w(t) dt} {\int_{t_{0}}^{t_{f}} w(t) dt} = \frac{1}{delta} \int_{t_{0}}^{t_{f}} f(Q, U, U_{d})w(t) dt\]

where:

\(w(t) = Step (Time, T-Delta, 0, T, 1) + Step (Time, T, 1, T+Delta, 0) - 1\)

Usage Example:

Compute the value of VM(22,11) @ t=1 sec.#
t0     = 0
tf     = 2
t      = 1
delta  = 1e-3
w(t)   = Step (Time, t-delta, 0, t, 1) + Step (Time, t, 1, t+delta, 0) - 1
Num    = Integral ( VM(22,11) * w(t) dt, t=t0, t=tf )

# ValueAtTime = Num / delta

val = ValueAtTime (label  = "VM(22,11) @ Time=1",
                   delta         = delta,
                   atTime        = t,
                   measuredValue = "VM(22,11)",
                   )

Name

Type

Required

Default

Modifiable

active

Bool

True

\(\checkmark\)

atTime

Double

\(\checkmark\)

delta

Double

\(\checkmark\)

id

Int

Auto

label

Str

measuredValue

Function

\(\checkmark\)

name

Str

plot

Bool

False

scale

Double

1.0

sensitivity

Bool

True

active#

Defines the state of the object.

Type=Bool, Default=True, Modifiable

atTime#

Time at which response is computed.

Type=Double, Required, Default=0.0

delta#

Time interval around ‘atTime’ used to define the impulse function.

Type=Double, Required, Default=0.0

id#

The id of the object.

Type=Int

label#

Label string for the Response.

Type=Str

measuredValue#

Function expression for ValueAtTime.

Type=Function, Required

name#

Defines a nametag for the object.

Type=Str

plot#

If True, a dynamic plot will be created.

Type=Bool, Default=False

scale#

Scaling factor of Response.

Type=Double, Default=1.0

sensitivity#

Returns a zero sensitivity vector when set to False.

Type=Bool, Default=True