Main Content

OptimizerTRSADEA

Access TR-SADEA optimizer and its properties

Since R2025a

    Description

    Use the OptimizerTRSADEA object to create a TR-SADEA optimizer. Use the object properties and functions set up and tune the optimizer parameters, and integrate the TR-SADEA optimizer as a black box into your workflow using a function handle.

    You can use the TR-SADEA optimizer for high-dimensional (with 30 or more design variables), highly nonlinear problems where focused local search and adaptive refinement is necessary. It is particularly effective for applications such as optimizing large-scale antenna arrays (phased arrays, MIMO antennas, or reconfigurable metasurfaces), high-fidelity EM simulations with many constraints, and fine-tuning near an optimal design.

    The TR-SADEA optimizer aims to find a local minimum of the objective function across several design variables within a bounded domain. For more information, see optimization algorithms.

    Creation

    Description

    s = OptimizerTRSADEA(bounds) creates a TR-SADEA optimizer object using default property values and the bounds specified in bounds.

    example

    s = OptimizerTRSADEA(bounds,PropertyName=Value) sets properties using one or more name-value arguments. PropertyName is the property name and Value is the corresponding value. You can specify the name-value arguments in any order as PropertyName1=Value1,...,PropertyNameN=ValueN. Properties that you do not specify retain their default values.

    For example, s = OptimizerTRSADEA([1;3],UseParallel=1) creates a TR-SADEA optimizer object with a single design variable with a lower bound of 1 and upper bound of 3 and uses a parallel pool for optimization.

    Input Arguments

    expand all

    Lower and upper bounds of the design variables, specified as a 2-by-N matrix, where N is the number of design variables for optimization. Each column represents one design variable, with the first row representing the lower bound and the second row the upper bound.

    This argument sets the Bounds property.

    Example: [3 0.11; 7 0.13]

    Data Types: double

    Properties

    expand all

    Lower and upper bounds of design variables, specified as a 2-by-N matrix. N is the number of design variables for optimization. Each column represents one design variable, with first row as lower bound and second row as upper bound.

    Example: [3 0.11; 7 0.13]

    Data Types: double

    Objective of antenna or array optimization, specified as one of these options:

    • Custom objective function — Optimizes the antenna or array as per the user-defined objective function.

    • Anonymous function handle — Optimizes the antenna or array for the objectives defined using the anonymous function handle.

    Example: @MinimizeArraySpacing

    Data Types: function_handle

    Weight or penalty of each constraint function, specified as a vector of positive integers in the range (0,100]. The summation of all the weights must be 100. If you specify a high value, the function gives a higher priority to the constraint when optimizing multiple constraints.

    When optimizing multiple constraints, the function prioritizes constraint functions based on the weights.

    Example: [20 50 30]

    Data Types: double

    Option to enable parallel pool, specified as a logical value. The default value is 0. Set this option to 1 to enable the parallel pool. Use parallel pool to speed up the optimization for computationally large antennas and arrays, or in case of high number of design variables. To use this feature, you need a license for Parallel Computing Toolbox™.

    Use the canUseParallelPool function to check if Parallel Computing Toolbox is installed and licensed for use, a default parallel pool is configured and supported, and automatic creation of parallel pools is enabled.

    Example: 1

    Data Types: logical

    Geometric constraints for optimization, specified as a structure of coefficient matrix and constant vector.

    Specify linear inequality constraints in the A matrix and b vector.

    • A is a real M-by-N matrix, where M is the number of inequalities, and N is the number of design variables. A holds the design variable coefficients of the inequalities.

    • b is a real M-element column vector and holds the constants of inequalities corresponding to the coefficients in A.

    For example, consider an optimization problem consisting of five design variables as follows:

    designVariables = {'CenterArmNotchLength','NotchLength','Width',...
                'CenterArmNotchWidth','NotchWidth'};
    The geometric constraints for optimization are:

    • 5*CenterArmNotchLength - NotchLength < 0

    • CenterArmNotchWidth + 2*Notchwidth - Width < 0

    Define the A and b as follows:

    A = [5,-1,0,0,0;...
         0,0,-1,1,2];
    b = [0;0];

    Specify linear equality constraints in the Aeq matrix and beq vector.

    • Aeq is an Me-by-N matrix, where Me is the number of equalities, and N is the number of design variables. Aeq holds the design variable coefficients of the equalities.

    • beq is a real Me-element column vector and holds the constants of equalities corresponding to the coefficients in Aeq.

    Specify nonlinear inequality constraints in the nlcon matrix and nrlv vector.

    • nlcon is a function handle that defines nonlinear constraints. It stores the design variables.

    • nrlv is a 1-by-N vector of 0 and 1. N is the number of design variables in nlcon. Each element in nrlv represents an index and corresponds to a design variable in nlcon in the same sequence as nlcon. Specify 1 to convey to the optimize function that the corresponding design variable is relevant for optimization. Specify 0 to convey to the optimize function that the corresponding design variable is not relevant for optimization.

    For example, to maximize the gain of a dipole antenna operating at 75 MHz with constraints on its length and width, use this code:

    optAnt = OptimizerTRSADEA([1 4; 3 7]);
    optAnt = OptimizerTRSADEA(GeometricConstraints=opt);
    opt = 
    
      struct with fields:
    
            A: [100×2 double]
            b: [100×1 double]
          Aeq: [-1 5]
          beq: 0
        nlcon: @btw
         nrlv: [1 1]

    For additional information on linear and nonlinear equalities and nonlinear inequalities, see the fmincon (Optimization Toolbox) function documentation.

    Example: A=[5,-1,0,0,0; 0,0,-1,1,2]; b=[0;0]; structure.A=A; structure.b=b;

    Example: Aeq=[-1 5]; beq=0; structure.Aeq=Aeq; structure.beq=beq;

    Example: nlcon=@btw; nrlv=[1 1]; structure.nlcon=nlcon; structure.nrlv=nrlv;

    Data Types: struct

    Option to print iteration number and value of convergence at the command line, specified as a logical 1 to enable or 0 to disable. By default, this option is disabled.

    Example: 1

    Data Types: logical

    Object Functions

    checkExitConditionCheck exit status of optimizer
    defineInitialPopulationSet initial population size
    getBestMemberDataView best member data after optimization
    getInitializationDataView optimizer member data at initialization
    getIterationDataView optimization data for completed iterations
    getNumberOfEvaluationsGet number of function evaluations performed
    isConvergedCheck convergence status of optimizer
    isFunctionEvaluationsExhaustedCheck function evaluations completion status
    optimizeOptimize custom evaluation function using specified parameters
    optimizeWithPlotsOptimize custom evaluation function and plot population density and convergence
    performRestoreRestore optimizer parameters to values from the previous successful iteration
    setMaxFunctionEvaluationsSet upper limit for number of function evaluations
    showConvergenceTrendPlot optimization convergence trend

    Examples

    collapse all

    Create a four-element linear array of dipole antennas. Use it as an exciter for a reflector antenna.

    Calculate maximum directivity of this reflector antenna.

    la = linearArray(NumElements=4);
    la.Tilt = 90;
    referenceAnt = reflector;
    referenceAnt.Exciter = la;
    referenceAnt.GroundPlaneLength = 8;
    referenceAnt.GroundPlaneWidth = 4;
    referenceAnt.Spacing = 4;
    InitialDirectivity = max(max(pattern(referenceAnt,70e6)))
    InitialDirectivity = 
    9.9028
    
    figure
    pattern(referenceAnt,70e6)

    Figure contains 2 axes objects and other objects of type uicontrol. Axes object 1 contains 11 objects of type patch, surface. Hidden axes object 2 contains 18 objects of type surface, line, text, patch.

    Find the lowest return loss among all ports of this antenna at 70 MHz.

    freq = 70e6;
    sp = sparameters(referenceAnt,freq);
    RetLossPort1 = 20*log10(max(abs(rfparam(sp,1,1))));
    RetLossPort2 = 20*log10(max(abs(rfparam(sp,2,2))));
    RetLossPort3 = 20*log10(max(abs(rfparam(sp,3,3))));
    RetLossPort4 = 20*log10(max(abs(rfparam(sp,4,4))));
    InitialLowestRetLossVal = max([RetLossPort1,RetLossPort2,RetLossPort3,RetLossPort4]);

    Choose spacing between the dipoles of the exciter and exciter to reflector spacing as design variables. Specify the lower and upper bounds of these design variables.

    Use the TR-SADEA optimizer to optimize this reflector antenna for its directivity and return loss. Specify an evaluation function for optimization using the CustomEvaluationFunction property of the OptimizerTRSADEA object. The evaluation function used in this example is defined at the end of this example.

    Set the maximum number of function evaluations to 90 and initial population sample size to 10. Setting these parameters is optional. The TR-SADEA optimizer calculates best sample size automatically if you do not specify it.

    Bounds = [0.1 0.1; 10 10];
    s = OptimizerTRSADEA(Bounds);
    s.CustomEvaluationFunction = @customEvaluationWithConstraint2;
    setMaxFunctionEvaluations(s,90);
    defineInitialPopulation(s,10);

    Run optimization for 50 iterations and check if maximum function evaluations have been reached. Observe the convergence trends plot.

    optimize(s,50);
    flag0 = isFunctionEvaluationsExhausted(s)
    flag0 = logical
       0
    
    
    showConvergenceTrend(s) 

    Figure contains an axes object. The axes object with title Convergence Trend Plot, xlabel Number of Iterations, ylabel Fitness contains an object of type line.

    View the best member data.

    bestDesign = s.getBestMemberData
    bestDesign = 
      bestMemberData with properties:
    
                 member: [2.2926 2.8495]
           performances: -13.5865
                fitness: -13.5865
        bestIterationId: 41
    
    
    bestdesignValues = bestDesign.member
    bestdesignValues = 1×2
    
        2.2926    2.8495
    
    

    Update reference antenna with the design values obtained from the optimization and calculate the directivity.

    Observe the increase in directivity post optimization.

    referenceAnt.Exciter.ElementSpacing = bestdesignValues(1);
    referenceAnt.Spacing = bestdesignValues(2);
    postOptimizationDirectivity = max(max(pattern(referenceAnt,70e6)))
    postOptimizationDirectivity = 
    13.5865
    
    figure
    pattern(referenceAnt,70e6)

    Figure contains 2 axes objects and other objects of type uicontrol. Axes object 1 contains 11 objects of type patch, surface. Hidden axes object 2 contains 18 objects of type surface, line, text, patch.

    Calculate the post optimization return loss. Use the lowest return loss value among all ports.

    Observe that the value of return loss after optimization is better than its previous value.

    sp = sparameters(referenceAnt,freq);
    RetLossPort1 = 20*log10(max(abs(rfparam(sp,1,1))));
    RetLossPort2 = 20*log10(max(abs(rfparam(sp,2,2))));
    RetLossPort3 = 20*log10(max(abs(rfparam(sp,3,3))));
    RetLossPort4 = 20*log10(max(abs(rfparam(sp,4,4))));
    NewLowestRetLossVal = max([RetLossPort1,RetLossPort2,RetLossPort3,RetLossPort4]);

    Check the exit status of the optimizer.

    flag1 = isFunctionEvaluationsExhausted(s)
    flag1 = logical
       0
    
    
    flag2 = checkExitCondition(s)
    flag2 = logical
       0
    
    

    Restore the optimizer parameters to their previous successful iteration values. Use this step if the current iteration is interrupted and the iteration data is incomplete.

    res = performRestore(s)
    res = 
      OptimizerTRSADEA with properties:
    
                          Bounds: [2×2 double]
        CustomEvaluationFunction: @customEvaluationWithConstraint2
                         Weights: []
                     UseParallel: 0
            GeometricConstraints: [1×1 struct]
                       EnableLog: 0
    
    

    Following code defines the evaluation function used in this example.

    function fitness = customEvaluationWithConstraint2(designVariables)
        fitness = [];
        try
            % Create geometry
            la = linearArray(NumElements=4);
            la.Tilt = 90;
            la.ElementSpacing = designVariables(1);
            r = reflector;
            r.Exciter = la;
            r.GroundPlaneLength = 8;
            r.GroundPlaneWidth = 4;
            r.Spacing = designVariables(2);
        catch
            % Handle errors during geometry creation
            % High penalty value is used to handle errors
            fitness = 1e6;
        end
        
        if isempty(fitness)
            try
                % Calculate realized gain 
                objective = max(max(pattern(r, 70e6)));
                objective = -objective; % As optimizer always minimizes objective, 
                % sign is reversed to maximize gain.
            catch
                % Handle errors during gain computation
                % High penalty value is used to handle errors
                objective = 1e6;
            end
        
            try
                % Constraints s11 < -10
                % Calculate S-parameters
                freq = 70e6;
                s = sparameters(r,freq);
                RetLossPort1 = 20*log10(max(abs(rfparam(s,1,1))));
                RetLossPort2 = 20*log10(max(abs(rfparam(s,2,2))));
                RetLossPort3 = 20*log10(max(abs(rfparam(s,3,3))));
                RetLossPort4 = 20*log10(max(abs(rfparam(s,4,4))));
                lowestRetLossVal = max([RetLossPort1,RetLossPort2,RetLossPort3,RetLossPort4]);
                expVal = -20;
                % As constraint is satisfied when it is less than -20 dB, better
                % values are made to be equal to -20 dB to not affect optimizer
                % direction.
                constraint = (lowestRetLossVal-expVal);
                constraint = max(constraint,0);
            catch
                % Handle errors during S-parameters computation.
                % High penalty value is used to handle errors.
                constraint = 1e6;
            end
            fitness = objective + constraint;
        end
    end

    Version History

    Introduced in R2025a