Function Description
The GRADS block performs one-dimensional optimization of the $f\left(\mathtt{\text{x}},v\right)$ function by gradient method, where is the optimized variable and $v$ is an arbitrary vector variable. It is assumed that the value of the function $f\left(\mathtt{\text{x}},v\right)$ for given x at time $k$ is enumerated and fed to the f input at time $k+\mathtt{\text{n}}\ast {T}_{S}$, where ${T}_{S}$ is the execution period of the GRADS block. This means that the individual optimization iterations have a period of $\mathtt{\text{n}}\ast {T}_{S}$. The length of step of the gradient method is given by

$\begin{array}{rcll}grad& =& \left({\mathtt{\text{f}}}_{i}-{\mathtt{\text{f}}}_{i-1}\right)\ast {\left(dx\right)}_{i-1}& \text{}\\ {\left(dx\right)}_{i}& =& -\mathtt{\text{gamma}}\ast grad,& \text{}\end{array}$

where $i$ stands for $i$-th iteration. The step size is restricted to lie within the interval $⟨\mathtt{\text{dmin}},\mathtt{\text{dmax}}⟩$. The value of the optimized variable for the next iteration is given by

${x}_{i+1}={x}_{i}+{\left(dx\right)}_{i}$

Inputs

 f Value of the optimized $f\left(.\right)$ for given variable x Double (F64) x0 Optimization starting point Double (F64) START Starting signal (rising edge) Bool BRK Termination signal Bool

Outputs

 x Current value of the optimized variable Double (F64) xopt Resulting optimal value of the x variable Double (F64) fopt Resulting optimal value of the function $f\left(\mathtt{\text{x}},v\right)$ Double (F64) BSY Indicator of running optimization Bool iter Number of current iteration Long (I32) E Error flag Bool iE Error code Long (I32) 1 .... $\mathtt{\text{x}}\notin <\mathtt{\text{xmin}},\mathtt{\text{xmax}}>$ 2 .... $\mathtt{\text{x}}=\mathtt{\text{xmin}}$ or $\mathtt{\text{x}}=\mathtt{\text{xmax}}$

Parameters

 xmin Lower limit for the x variable Double (F64) xmax Upper limit for the x variable  $\odot$10.0 Double (F64) gamma Coefficient for determining the step size of the gradient optimization method  $\odot$0.3 Double (F64) d0 Initial step size  $\odot$0.05 Double (F64) dmin Minimum step size  $\odot$0.01 Double (F64) dmax Maximum step size  $\odot$1.0 Double (F64) n Iteration period (in sampling periods ${T}_{S}$)  $\odot$100 Long (I32) itermax Maximum number of iterations  $\odot$20 Long (I32)

2020 © REX Controls s.r.o., www.rexygen.com