Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 4.69 KB | None | 0 0
  1.         function [xData,yData] = ApplyParameterExtraction(app,DataSet)
  2.             xVarNameGUI = app.userSelection.Extract.XAxisParam{DataSet};
  3.             xVarName = genvarname(xVarNameGUI);
  4.             %zVarName = app.userSelection.Extract.ZAxisParam{DataSet}; % this has no Z axis capability at this point
  5.            
  6.              
  7.             % In cadence generally multiple parameters can be swept.
  8.             % let's assume we have DPAR_1 with 10 different parameters and DPAR_2 with 5 different parameters
  9.             % we want DPAR_1 as X axis, then we get 5 different plots with 10 points each.
  10.             % So, for each sweep of Y vs DPAR_1, we first have to find 10 runs, in which the rest of the parameters (DPAR_2 in this case) are constant
  11.             allParamVarsGUI = keys(app.SimMetaData.designParamsGUI{1}); %{n} is the run number here, {1} is safe to choose, because it always exists
  12.            
  13. %             here begins a sorting algorithm that will sort run numbers in a 2 dimensional matrix
  14. %             this is based on an idea by Raphael Steinhoff. After a long discussion that involved many recursive and/or cumbersome approaches
  15. %             this was by far the most practical
  16. %            
  17. %             along one row, the only parameter that will change is the one that is selected as "Extraction Parameter"
  18. %             it is sorted from left to right by low value to high value. All other parameters stay constant.
  19. %             The number of rows equals the number of permutations of all "remaining parameters" (all parameters that are not extraction parameters are "remaining parameters").
  20. %            
  21. %            
  22. %             IMPLEMENTATION:
  23. %             To accomplish this, we go through each single run directory, determine a COLUMN value by looking at the extraction Parameter value
  24. %             And then look at the first "remaining parameter" .
  25. %             Let's assume this one has 2 different values. Depending on whether we find the higher or lower value, we can narrow the final position in the matrix down to the lower or upper half of the matrix.
  26. %             The next one is the last remaining parameter and has 3 different values. So each of the two subdivisions (lower or upper half of the matrix) are now subdivided into three rows.
  27. %             depending on the last remaining parameter we can decide for one of those 3 rows. Subdividing is realised by the rowMultiplicator
  28.            
  29.            
  30.             remainingParamVarsGUI = cell(length(allParamVarsGUI)-1,1);
  31.             rowMultiplicator = zeros(length(allParamVarsGUI),1);
  32.             rowMultiplicator(1) = app.SimMetaData.numberOfParametersets / app.SimMetaData.ParametersAsStruct.(xVarName).steps;
  33.            
  34.             runNumberLookupMatrix = zeros(rowMultiplicator(1),app.SimMetaData.ParametersAsStruct.(xVarName).steps);
  35.            
  36.             m = 1;
  37.            
  38.             for n = 1:length(allParamVarsGUI)
  39.                 if(~strcmp(allParamVarsGUI{n},xVarNameGUI))
  40.                     remainingParamVarsGUI{m} = allParamVarsGUI{n}; % create a new cell, that only contains "ramining Parameters"
  41.                     paramVarName = genvarname(remainingParamVarsGUI{m});
  42.                     rowMultiplicator(m+1) = rowMultiplicator(m) / app.SimMetaData.ParametersAsStruct.(paramVarName).steps;
  43.                     m = m+1;
  44.                 end
  45.             end
  46.            
  47.             for n = 1:app.SimMetaData.numberOfParametersets % all runs
  48.                 % find col position by analyzing xVarNameGUI value for run "n" -> lookup via app.SimMetaData.designParamsGUI{n} (containers Map)
  49.                 % length of app.SimMetaData.ParametersAsStruct.(ParamName).all is equal to numberOfParametersets - it just contains the parameter value for EACH run
  50.                 % unique is used to filter out multiples. Sort is used for ascending order
  51.                 xVarValues = sort(unique(app.SimMetaData.ParametersAsStruct.(xVarName).all));
  52.                 COL = find(xVarValues == app.SimMetaData.designParamsGUI{n}(xVarNameGUI));
  53.                 ROW = 1;
  54.                 % and now for the columns
  55.                 for m = 1:length(remainingParamVarsGUI)
  56.                     paramVarName = genvarname(remainingParamVarsGUI{m});
  57.                     paramValues = sort(unique(app.SimMetaData.ParametersAsStruct.(paramVarName).all));
  58.                     paramMultiplier = find(paramValues == app.SimMetaData.designParamsGUI{n}(remainingParamVarsGUI{m})) - 1;
  59.                     ROW = ROW + rowMultiplicator(m+1) * paramMultiplier; %rowMultiplicator is offset by 1 (easier to create)
  60.                 end
  61.                 runNumberLookupMatrix(ROW,COL) = n; % it looks so innocent now...
  62.             end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement