estimateHeMatrix

PURPOSE ^

compute the "closest" hE-vector in reach of the given hC-representation

SYNOPSIS ^

function heMatrixProjected = estimateHeMatrix(heMatrix,projectionMatrix, sampleProjectionData)

DESCRIPTION ^

 compute the "closest" hE-vector in reach of the given hC-representation

 Distinguishing confined/valid projections and the PCA approach is ensured
   via the construction of sampleProjetionData and/or the evaluation

 THIS IS NO USER FUNCTION

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function heMatrixProjected = estimateHeMatrix(heMatrix, ...
0002     projectionMatrix, sampleProjectionData)
0003 % compute the "closest" hE-vector in reach of the given hC-representation
0004 %
0005 % Distinguishing confined/valid projections and the PCA approach is ensured
0006 %   via the construction of sampleProjetionData and/or the evaluation
0007 %
0008 % THIS IS NO USER FUNCTION
0009 
0010 % The elk-library: convex geometry applied to crystallization modeling.
0011 %   Copyright (C) 2014 Alexander Reinhold
0012 %
0013 % This program is free software: you can redistribute it and/or modify it
0014 %   under the terms of the GNU General Public License as published by the
0015 %   Free Software Foundation, either version 3 of the License, or (at your
0016 %   option) any later version.
0017 %
0018 % This program is distributed in the hope that it will be useful, but
0019 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0020 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0021 %   General Public License for more details.
0022 %
0023 % You should have received a copy of the GNU General Public License along
0024 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0025 
0026 
0027 %% comments (based on confinement projection)
0028 % We assume appropriate confinement partitions exist so that the sample
0029 %   points are approximated by shapes for which the same validity
0030 %   projection is valid. The target confinement partition is concluded
0031 %   directly from the sample vector.
0032 % If this assumption is not proper, we cannot simply ignore these points
0033 %   when the error measure is calculated. Furthermore, we have to avoid
0034 %   jumps in the objective function.
0035 % To resolve the first issue, a ratio is defined that describes, how
0036 %   many columns of heMatrix contribute to the error:
0037 %      ratio = sum(notProperVector(hcMatrix)) / nCol.
0038 %   Invalid vectors in the hcMatrix are substituted by their original
0039 %   values so that these cannot contribute to the error anymore.
0040 % To resolve the second issue, we have to switch continuously from the
0041 %   proper state to the improper state. This is, fortunately relatively
0042 %   simple when the distance to the constreints is evaluated accordingly.
0043 %   A parameter "distanceLimit" controls this behavior, analogously to the
0044 %   growth rate validity mapping. However, this time we use an approximate
0045 %   of the outer distance so that the fade-out does start when the vectors
0046 %   already have become invalid. (This outer distance approximate is NOT the
0047 %   distance from the validity cone).
0048 % to additionally avoid that NO vectors are proper, a penalty scheme is
0049 %   added at the very end. It fixes optimizations that do converge towards
0050 %   "no vectors", but require a good knowledge or tuning to set the slope
0051 %   according to the expected error values. This penalty scheme could also
0052 %   very simply be used to optimize for "ensure that the existent facets
0053 %   match for original and approximation for as much as posisble vectors".
0054     
0055 % mapping matrices
0056 mappingFullToReduced = orth(projectionMatrix)';
0057 mappingReducedToFull = pinv(mappingFullToReduced);
0058 
0059 % function handle to convert distances to "smoothing-filter" values
0060 % smoothFilter = @(distanceVector)(1*(distanceVector <= 0) + ...
0061 %     (distanceVector <= par.distanceLimit).*(distanceVector > 0).*...
0062 %             (par.distanceLimit - distanceVector)/par.distanceLimit);
0063 
0064 % we cycle through the groups of projections to generate the
0065 %   approximated vectors
0066 heMatrixProjected = nan*heMatrix;
0067 % fadeOutScaling = zeros(1, size(heMatrix, 2));
0068 for iProjection = 1:length(sampleProjectionData.list)
0069     heFilter = sampleProjectionData.assignedProjectionVector == iProjection;
0070     
0071     % generate the closest vectors in the subspace given by the current
0072     %   projection, assuming a confinement region where the
0073     %   pre-calculated validity projection is valid
0074     % when the validityProjection is the unit matrix, we should use the
0075     %   initial projectionMatrix instead of the mapping matrices for
0076     %   accuracy reasons
0077     thisValidityProjection = sampleProjectionData.list(iProjection).validityProjection;
0078     if all(diag(thisValidityProjection) == 1) && ...
0079        all(all(abs(thisValidityProjection - diag(diag(thisValidityProjection))) <= eps))
0080         heMatrixInSubspace = projectionMatrix * heMatrix(:, heFilter);
0081     else
0082         heMatrixInSubspace = mappingReducedToFull*pinv(...
0083             thisValidityProjection * mappingReducedToFull) * ...
0084             heMatrix(:, heFilter);
0085     end
0086 %     projectionApplicableDistance = max(...
0087 %         sampleProjectionData.list(iProjection).projectionApplicableConstraint * ...
0088 %         heMatrixInSubspace, [], 1);
0089     % the projection is smoothened out while we assume this projection
0090     %   is valid for a few MORE points than exact.
0091 %     if isempty(projectionApplicableDistance)
0092 %         projectionApplicableDistance = ones(1, sum(vectorFilter));
0093 %     else
0094 %         projectionApplicableDistance =  smoothFilter(projectionApplicableDistance);
0095 %     end
0096     
0097     % generate the corresponding valid hC-vectors
0098     heMatrixValid = sampleProjectionData.list(iProjection).validityProjection * ...
0099         heMatrixInSubspace;
0100 %     facetsValidDistance = max(...
0101 %         sampleProjectionData.list(iProjection).facetPresentConstraint * ...
0102 %         heMatrixValid , [], 1);
0103 %     if isempty(facetsValidDistance)
0104 %         facetsValidDistance = ones(1, sum(vectorFilter));
0105 %     else
0106 %         facetsValidDistance = smoothFilter(facetsValidDistance);
0107 %     end
0108     
0109     % join applicability
0110 %     vectorSmoothFilter = min(projectionApplicableDistance, ...
0111 %         facetsValidDistance);
0112     
0113     % assign values
0114 %     heMatrixProjected(:, vectorFilter) = ...
0115 %         bsxfun(@times, heMatrixValid, vectorSmoothFilter) + ...
0116 %         bsxfun(@times, heMatrix(:, vectorFilter), (1-vectorSmoothFilter));
0117     heMatrixProjected(:, heFilter) = heMatrixValid;
0118 %     fadeOutScaling(vectorFilter) = vectorSmoothFilter;
0119 end
0120 
0121 if isnan(heMatrixProjected)
0122     error('elk:approximation:internalError', ['Estimated projection of ' ...
0123         'hE-matrix contains nan. This should not happen.']);
0124 end
0125 
0126 % fadeOutScaling = ones(1, size(heMatrix, 2));

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005