Main Content

validateSetup

Validate optimizer setup

Since R2026a

    Description

    status = validateSetup(obj) runs validation on the optimizer object specified in obj and returns the validation status as 1 if validation succeeds or an appropriate error message otherwise.

    [___] = validateSetup(___,numsamples) runs the validation using the number of samples of design variables specified in numsamples.

    example

    Examples

    collapse all

    Define the bounds for the optimizer. Specify the evaluation function.

    s = OptimizerSADEA([3 0.11; 7 0.13]);
    s.CustomEvaluationFunction = @customEvaluationOnlyObjective;

    Validate the optimizer setup using 10 design variable samples.

    validateSetup(s,10)
    ans = logical
       1
    
    

    Define the evaluation function.

    function fitness = customEvaluationOnlyObjective(designVariables)
    
        % Create geometry
        ant = design(dipole,75e6);
        ant.Length = designVariables(1);
        ant.Width = designVariables(2);
    
        % Calculate directivity
        % Optimizer always minimizes the objective hence reverse the sign to maximize gain.
        objective = max(max(pattern(ant,75e6)));
        objective = -objective; 
        
        % As there are no constraints, fitness equals objective.
        fitness = objective;
    
    end

    Input Arguments

    collapse all

    Optimizer to validate, specified as an OptimizerSADEA or OptimizerTRSADEA object.

    Example: OptimizerSADEA

    Number of samples of design variables for validation, specified as a positive integer. By default, the validation check runs for a single sample.

    Example: 10

    Data Types: double

    Output Arguments

    collapse all

    Validation status, returned as a logical value 1 for successful validation or appropriate error message otherwise.

    Version History

    Introduced in R2026a