/**
* Copyright (C) 2013-2017 Vasilis Vryniotis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.datumbox.framework.core.mathematics.linearprogramming;
import com.datumbox.framework.common.dataobjects.AssociativeArray;
import com.datumbox.framework.common.dataobjects.FlatDataList;
import com.datumbox.framework.core.common.utilities.PHPMethods;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Class that performs Data Envelopment Analysis. It requires the installation of
* lpsolve 5.5.2.0. http://lpsolve.sourceforge.net/5.5/
*
* References:
* http://en.wikipedia.org/wiki/Data_envelopment_analysis
* http://deazone.com/en/resources/tutorial/weights-to-determine-relative-efficiency
*
* @author Vasilis Vryniotis
*/
public class DataEnvelopmentAnalysis {
/**
* DEA method separates the features of the observations in input and output;
* The DeaRecord is a wrapper Object which stores the input and output parts of our
* data points.
*/
public static class DeaRecord {
/**
* The values of features that are considered as input. It can be empty if
* if no input is assumed.
*/
private final double[] input;
/**
* The values of features that are considered as output.
*/
private final double[] output;
/**
* Constructor of DEA Record with only output
*
* @param output The output part of our data record
*/
public DeaRecord(FlatDataList output) {
this.output=new double[output.size()];
int column=0;
Iterator it = output.iteratorDouble();
while(it.hasNext()) {
this.output[column]=it.next();
++column;
}
this.input= new double[0];
}
/**
* Constructor of DEA Record with both input and output
*
* @param output The output part of our data record
* @param input The input part of our data record
*/
public DeaRecord(FlatDataList output, FlatDataList input) {
this.output=new double[output.size()];
int column=0;
Iterator it = output.iteratorDouble();
while(it.hasNext()) {
this.output[column]=it.next();
++column;
}
this.input=new double[input.size()];
column=0;
it = input.iteratorDouble();
while(it.hasNext()) {
this.input[column]=it.next();
++column;
}
}
/**
* Getter for input.
*
* @return Returns the input part of our data.
*/
public double[] getInput() {
return PHPMethods.array_clone(input);
}
/**
* Getter for output.
*
* @return Returns the output part of our data.
*/
public double[] getOutput() {
return PHPMethods.array_clone(output);
}
}
/**
* Estimates the efficiency of the records by running DEA
*
* @param id2DeaRecordMapInput AssociativeArray with the DeaRecords
* @param id2DeaRecordMapOutput
* @return Map with the scores of the records
*/
public AssociativeArray estimateEfficiency(Map
Ads help maintain this website.