% Delivered to the Government in Accordance with Contract FA8650-10-C-7080
% 
%  (c) 2011 Massachusetts Institute of Technology
% Developed with the sponsorship of the Defense Advanced Research Projects Agency (DARPA).
%  
% Permission is hereby granted, free of charge, to any person obtaining a copy of this data, including any software or models in source or binary form, as well as any drawings, specifications, and documentation (collectively "the Data"), to deal in the Data without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Data, and to permit persons to whom the Data is furnished to do so, subject to the following conditions:
%  
% The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Data.
%  
% THE DATA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, SPONSORS, DEVELOPERS, CONTRIBUTORS, OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA OR THE USE OR OTHER DEALINGS IN THE DATA.
% 

% run_metrics
% Master Script to Run META-II Metric Workbench
% This script runs the various pieces of code that 
% compute metrics of complexity and adaptability
% for the META program.
%
% dWo - Sept 2011
% Appended by Kaushik - sept 07,2011
%
clear all; close all;
pwd
addpath(genpath(pwd));
%
disp(['Computing Structural Complexity metric...']);
load A_GTF;
n=size(A_GTF,1);
alpha=ones(n,1);
W=A_GTF;
[struct_comp,E,connection_complexity,component_complexity,num_connections,num_components] = structural_complexity(A_GTF,alpha,W);
%
disp(['=================================================================================================================================']);
%
disp(['Computing different dynamic complexity metrics...']);
disp(['If explicit Mathematical Equations are not available, but only Black-Box models or experimental data'])
% Dynamic Complexity - Kaushik;
[C,normalized_C,E,normalized_E,total_entropy,normalized_entropy,X,A,entropy_matrix] = dynamical_complexity('3_Spool_Turbofan.csv',0.95);
close all;
%
disp(['=================================================================================================================================']);
% Complexity Components from Sujit Nair..
clf;close all;
disp(['If explicit Mathematical Equations are available and analyzes the dynamics of the system'])
Main
%
disp(['=================================================================================================================================']);
%
% AIMDYN Code...
clf; close all;
disp(['Complexity Measure for directed graphs..'])
%make_matr;
[sum_1, sum_2, sum_2_second, metrics, metrics_second, sinks, kmin, kmin1, answer_all,ncomp_all, cycles_ind, nodes] = ComputeComplexityAndClustering(A_GTF);
%
%Complexity1 = metrics
Cycle_Complexity = metrics_second
disp(['=================================================================================================================================']);
%
disp(['Structural Complexity metric: ']);
Structural_Complexity = struct_comp
Graph_Energy = E
number_of_components = num_components
number_of_connections = num_connections
disp(['=================================================================================================================================']);
%
disp(['If explicit Mathematical Equations are not available, but only Black-Box models or experimental data: '])
dynamic_complexity = C
dynamic_complexity_connectivity_component = E
dynamic_complexity_uncertainty_component = total_entropy
%
disp(['=================================================================================================================================']);
%
disp(['If explicit Mathematical Equations are available and analyzes the system dynamics: '])
dimensional_complexity = dim_complexity
computational_complexity = t_DF
nonlinear_complexity = nc_3spT
timescale_complexity = tscale_complexity
disp(['=================================================================================================================================']);
%
disp(['Cycle Complexity Measure: '])
Cycle_Complexity = metrics_second
%
disp(['=================================================================================================================================']);