/*
 * ARX: Powerful Data Anonymization
 * Copyright (C) 2012 - 2014 Florian Kohlmayer, Fabian Prasser
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package org.deidentifier.arx.metric;

import org.deidentifier.arx.framework.check.groupify.IHashGroupify;
import org.deidentifier.arx.framework.lattice.Node;

/**
 * This class provides an implementation of the Height metric.
 * 
 * @author Fabian Prasser
 * @author Florian Kohlmayer
 */
public class MetricHeight extends MetricDefault {

    /** SVUID */
    private static final long serialVersionUID = 5911337622032778562L;

    /**
     * Creates a new instance
     */
    protected MetricHeight() {
        super(true, true);
    }

    @Override
    public String toString() {
        return "Height";
    }
    
    @Override
    protected InformationLossWithBound<InformationLossDefault> getInformationLossInternal(final Node node, final IHashGroupify g) {
        int level = node.getLevel();
        return new InformationLossDefaultWithBound(level, level);
    }

    @Override
    protected InformationLossDefault getLowerBoundInternal(Node node) {
        return new InformationLossDefault(node.getLevel());
    }
    
    @Override
    protected InformationLossDefault getLowerBoundInternal(Node node,
                                                           IHashGroupify groupify) {
        return new InformationLossDefault(node.getLevel());
    }
}

@@ -799,66 +799,296 @@
 ort 
-org.deidentifier.arx.framework.check.groupify.IHashGroupif
+java.util.Set;%0A%0Aimport org.deidentifier.arx.ARXConfiguration;%0Aimport org.deidentifier.arx.DataDefinition;%0Aimport org.deidentifier.arx.framework.check.groupify.IHashGroupify;%0Aimport org.deidentifier.arx.framework.data.Data;%0Aimport org.deidentifier.arx.framework.data.GeneralizationHierarch
 y;%0Ai
@@ -1409,16 +1409,184 @@
 8562L;%0A%0A
+    /** The minimum height */%0A    private int               minHeight        = -1;%0A%0A    /** The maximum height */%0A    private int               maxHeight        = -1;%0A%0A
     /**%0A
@@ -1756,36 +1756,584 @@
 %22Height%22;%0A    %7D%0A
+%0A
     
+@Override%0A    public InformationLoss%3C?%3E createMinInformationLoss() %7B%0A        if (minHeight == -1) %7B%0A            throw new IllegalStateException(%22Metric must be intialized first%22);%0A        %7D else %7B%0A            return new InformationLossDefault(minHeight);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public InformationLoss%3C?%3E createMaxInformationLoss() %7B%0A        if (maxHeight == -1) %7B%0A            throw new IllegalStateException(%22Metric must be intialized first%22);%0A        %7D else %7B%0A            return new InformationLossDefault(maxHeight);%0A        %7D%0A    %7D%0A
 %0A    @Override%0A 
@@ -2729,13 +2729,9 @@
   %7D%0A
-    
 %0A
+
     
@@ -2891,24 +2891,24 @@
 groupify) %7B%0A
-
         retu
@@ -2960,11 +2960,633 @@
 );%0A    %7D
+%0A%0A    @Override%0A    protected void initializeInternal(final DataDefinition definition,%0A                                      final Data input,%0A                                      final GeneralizationHierarchy%5B%5D hierarchies,%0A                                      final ARXConfiguration config) %7B%0A        super.initializeInternal(definition, input, hierarchies, config);%0A%0A        Set%3CString%3E qis = definition.getQuasiIdentifyingAttributes();%0A        for (String qi : qis) %7B%0A            minHeight += definition.getMinimumGeneralization(qi);%0A            maxHeight += definition.getMaximumGeneralization(qi);%0A        %7D%0A%0A    %7D
 %0A%7D%0A

Introduce min/max information loss