classdef CompareOptimizationResultAction < fxptui.internal.action.Action
    %COMPAREOPTIMIZATIONRESULTACTION Action of launching SDI on a solution
    %from the latest fxpopt OptimizationResult
    
    %   Copyright 2019 The MathWorks, Inc.
    
    
    methods(Access = {?fxptui.internal.action.Action, ?WorkflowTestCase})
        
        function executeLocal(~, ~, workflowSetting)
            
            % extract the TopModel information from the DesignSetting
            designSettings = workflowSetting.getSettingValue('DesignSetting');
            topModel = designSettings.TopModel;
            
            % extract the TopModel information from the DesignSetting
            exploreSetting = workflowSetting.getSettingValue('ExploreSetting');
            solutionIndex = exploreSetting.SolutionIndex;
            scenarioIndex = exploreSetting.ScenarioIndex;
            
            result = fxptui.internal.action.getMostRecentResult(topModel, 'DataTypeOptimization.OptimizationResult');
            allSolutions = fxptui.internal.action.getAllSolutions(result);
            
            solution = allSolutions(solutionIndex);
            result.showComparisonView(solution, scenarioIndex);
            
        end
        
    end
    
end
