coser.datamodel.decisionsystem
类 TestCostDecisionSystemFixedNeighborhoodGA

java.lang.Object
  继承者 Instances
      继承者 coser.datamodel.decisionsystem.RoughDecisionSystem
          继承者 coser.datamodel.decisionsystem.CostSensitiveDecisionSystem
              继承者 coser.datamodel.decisionsystem.NumericDecisionSystem
                  继承者 coser.datamodel.decisionsystem.DecisionSystemNeighborhood
                      继承者 coser.datamodel.decisionsystem.DecisionSystemFixedNeighborhood
                          继承者 coser.datamodel.decisionsystem.TestCostDecisionSystemFixedNeighborhood
                              继承者 coser.datamodel.decisionsystem.TestCostDecisionSystemFixedNeighborhoodGA

public class TestCostDecisionSystemFixedNeighborhoodGA
extends TestCostDecisionSystemFixedNeighborhood

Project: The cost-sensitive rough sets project.

Summary: Test cost sensitive decision system with genetic algorithms for numeric data. Note that, the method is unsatisfactory. We may improve it later. They are written independently because those programs belong to different authors.

Author: Shujiao Liao sjliao2011@163.com

Copyright: The source code and all documents are open and free. PLEASE keep this header while revising the program.

Organizaion: Lab of Granular Computing, Zhangzhou Normal University, Fujian 363000, China.

Progress: Test-cost-sensitive attribute reduction based on genetic algorithms implemented.
Written time: July 25, 2011.
Last modify time: September 2, 2011.


字段摘要
修饰符 和 类型 字段 和 描述
(专用软件包)  long bestChromosome
          The best fitness value of the chromosome.
(专用软件包)  double bestFitnessValue
          The best fitness value of the group of chromosomes.
(专用软件包)  long[] candidateReductArray
          The candidate reducts.
(专用软件包)  boolean[][] chromosomes
          The population.
(专用软件包)  int computeCoreTime
          The numericCore runTime
(专用软件包)  boolean[] coreAttributes
          The boolean coreAttributes array
(专用软件包)  java.lang.String distributionString
          The name of distribution.
(专用软件包)  java.lang.String GAFilename
          The gred filename.
(专用软件包)  int generations
          The max generation.
(专用软件包)  int numberOfCandidateReducts
          The number of candidate reducts.
(专用软件包)  int numberOfChromosomes
          The number of Chromosomes.
(专用软件包)  int numberOfOne
          The number of 1 in the given boolean conditional attribute array
(专用软件包)  int runTime
          The geneticAlgorithmBasedTCSAttributeReduction runTime
(专用软件包)  boolean weighting
          Weighting or not.
 
从类 coser.datamodel.decisionsystem.TestCostDecisionSystemFixedNeighborhood 继承的字段
normalizedIndividualTestCostArray, testCostSum
 
从类 coser.datamodel.decisionsystem.DecisionSystemFixedNeighborhood 继承的字段
array_tmp, d, data_array, delta, dependency, granuleRangeArray, isItNormalized, POSsize, sample_lft, sqare_distance
 
从类 coser.datamodel.decisionsystem.DecisionSystemNeighborhood 继承的字段
candidateReductsArray, neighborhoodSizeArray, seed
 
从类 coser.datamodel.decisionsystem.CostSensitiveDecisionSystem 继承的字段
alpha, COMPLEX_COMMON_TEST_COST, COST_TYPE_MONEY, COST_TYPE_TESTING_TIME, COST_TYPE_WAITING_TIME, currentReductCost, currentReductTime, currentReductTotalTestCost, DEFAULT_AVERAGE_NUMBER_OF_TESTS_PER_GROUP, groupCommonTestCostArray, groupInclusionArray, groupInclusionMatrix, IMPOSSIBLE_COST, individualCostDistributions, individualCostLowerBounds, individualCostMatrix, individualCostRandom, individualCostUpperBounds, minimalTestCostReduct, minimalTimeReduct, misclassificationCostMatrix, misclassificationCostSumArray, NORMAL, optimalReductTestCost, optimalReductTime, PARETO, randomMode, SIMPLE_COMMON_TEST_COST, TEST_COST_INDEPENDENT, TEST_COST_TYPES, testCostConstraint, testCostRelationship, testingOrderMatrix, timeParts, totalTimeConstraint, unifiedMisclassificationCost, UNIFORM
 
从类 coser.datamodel.decisionsystem.RoughDecisionSystem 继承的字段
allConditions, allReducts, allReductsFilename, allSubreducts, allSubreductsFilename, arffFilename, backtrackSteps, candidateSubreductArray, candidateSubreductConsistencyArray, classSize, CONDITIONAL_ENTROPY, consistency, core, currentReduct, currentSelectedAttributes, endTime, MAJORITY, minimalReductSize, numberOfCandidateSubreducts, numberOfConditions, numberOfInstances, optimalReduct, POSITIVE_REGION, runTimeInformation, startTime, totalEntropy, totalMajority, totalPositiveRegion
 
构造方法摘要
构造函数 和 描述
TestCostDecisionSystemFixedNeighborhoodGA(TestCostDecisionSystemFixedNeighborhood paraDecisionSystem)
          Construct the decision system.
 
方法摘要
修饰符 和 类型 方法 和 描述
 boolean[][] bestInsteadOfWorst(boolean[][] paraChromosomes)
          The worst individual in offsprings is replaced by & the best individual in parent generation.
 double computeExceedingFactor()
          Get the exceeding factor.
 double computeFitnessValue_FirstVersion(boolean[] paraChromosome, int paraMaxPositiveRegion, double paraLambda)
          Compute the fitness of the given chromosome in the first version of the genetic algorithm.
 double computeFitnessValue_SecondVersion(boolean[] paraChromosome, int paraMaxPositiveRegion, double paraLambda)
          Compute the fitness of the given chromosome in the second version of the genetic algorithm.
 double computeFitnessValue(boolean[] paraChromosome, int paraMaxPositiveRegion)
          Compute the fitness of the given chromosome.
 int computeTestCost(long paraSelectedTests)
          Compute the cost of selected tests.
 boolean[][] crossoverOperation(boolean[][] paraChromosomes)
          Uniform crossover.
 long[] GABasedMinimalAttributeReduction()
          Find a (possibly) minimal reduct using the genetic algorithm based reduction algorithm.
 void geneticAlgorithmBasedTCSAttributeReduction_FirstVersion(double paraLambda)
          The first version of the genetic algorithm.
 void geneticAlgorithmBasedTCSAttributeReduction_SecondVersion(double paraLambda)
          The second version of the genetic algorithm.
 boolean[] geneticAlgorithmBasedTCSAttributeReduction(double paraLambda, boolean paraAlgorithm)
          Find a (possibly) minimal test-cost reduct using the genetic algorithm based reduction algorithm.
 java.lang.String getGAFilename()
          Get the GA filename.
 boolean[] initializeChromosome(boolean[] paraAllAttributes)
          Initialize a chromosome.
 boolean[][] initializeChromosomes(boolean[] paraAllAttributes)
          Initialize a group of chromosomes.
 void initializePartOfChromosomesToTrue()
          If no chromosome is a solution, then initialize a part of chromosomes(one tenth) to all true.
 void initializePopulation()
          Initialize a population.
 boolean isCurrentReductOptimal()
          Is the current reduct optimal?
 boolean[][] mutationOperation(boolean[][] paraChromosomes)
          Mutation operation.
 boolean[] numericCore()
          Compute the core of numeric attribute set
 void refreshTestCost()
          Refresh the test-cost settings.
 long[] removeRedundantReducts()
          Remove redundant candidate reducts.
 int searchPairsOfChromosomes(boolean[] paraCheckChromosome)
          Select a chromosomes for crossover.
 boolean[][] selectionOperation_FirstVersion(boolean[][] paraChromosomes, int paraMaxPositiveRegion, double paraLambda)
          Select new the group of chromosomes in the first version of the genetic algorithm.
 boolean[][] selectionOperation_SecondVersion(boolean[][] paraChromosomes, int paraMaxPositiveRegion, double paraLambda)
          Select new the group of chromosomes in the second version of the genetic algorithm.
 boolean[][] selectionOperation(boolean[][] paraChromosomes, int paraMaxPositiveRegion)
          Select new the group of chromosomes.
 void setGAFilename()
          Set the filename such that it can store results produced by GABasedTCSAttributeReduction.
 void setGeneration(int paraGenerations)
          Set the number of generation.
 void setNumberOfChromosomes(int paraNumberOfChromosome)
          Set the number of chromosome.
 void setWeighting(boolean paraWeighting)
          Set the weighting option for lambda-weighted reduction.
 char subSetCheck(long[] paraCandidateSubReducts, int fisrt, int second)
          Check Who is who's subset.
 
从类 coser.datamodel.decisionsystem.TestCostDecisionSystemFixedNeighborhood 继承的方法
allReductsToString, computeOptimalReductTestCostFNBacktrack, getNomalizedIndividualTestCostArray, oneOptimalFNBacktrack, printIndividualTestCostArray, printNormalizedIndividualTestCostArray, refreshTestCost1, setNomalizedIndividualTestCostArray, sumOfTestCostArray
 
从类 coser.datamodel.decisionsystem.DecisionSystemFixedNeighborhood 继承的方法
assignment, buildCandidatesNHBacktrack, computeAllReductsNHBacktrack, dataMatrixOfBooleanAttribute, getDelta, getGranuleRangeArray, isNormalized, isNormalizedJudge, numOne, POSsizeAndDependency, setDelta, setGranuleRangeArray, setGranuleRangeArray, toDoubleMatrix
 
从类 coser.datamodel.decisionsystem.DecisionSystemNeighborhood 继承的方法
addAttribute, averageMisclassificationCost, buildCandidatesBacktrack, computeAllReductsBacktrack, computeNeighborhood, computeOptimalReductTestCostBacktrack, computeOptimalTestCost, getNeighborhoodSizeArray, inconsistencyBasedLambdaReduction, inconsistencyDecrease, isConsistent, oneOptimalBacktrack, removeSuperReducts, setMisclassificationCostMatrix, setNeighborhoodSizeArray, totalCost, totalCost
 
从类 coser.datamodel.decisionsystem.NumericDecisionSystem 继承的方法
toString
 
从类 coser.datamodel.decisionsystem.CostSensitiveDecisionSystem 继承的方法
averageMisclassificationCost, averageMisclassificationCost, bestClassValue, computeAdditiveCost, computeReductTestCost, computeReductWaitingTime, computeTestCost, copyForClone, generateIndividualCosts, generateOneCost, getClassificationCost, getDistributionString, getIndividualCost, getIndividualTestCost, getIndividualTestCostArray, getMisclassificationCostMatrix, getOptimalReductTestCost, getReductTotalTestCost, initializeForReduction, setAlpha, setComplexCommonTestCostArrays, setCostRandomMode, setIndividualCostArray, setIndividualCostBounds, setIndividualCostDistribution, setMisclassificationCostMatrix, setMisclassificationCostMatrix, setSimpleCommonTestCostArrays, setTestCostsRelationShip, setUnifiedMisclassificationCost, sortByTestCost
 
从类 coser.datamodel.decisionsystem.RoughDecisionSystem 继承的方法
classEntropy, classEntropy, computeConsistency, computeConsistency, computeConsistency, computeCore, computeCore, conditionalEntropy, conditionalEntropy, conditionalEntropy, conditionalEntropy, copyForClone, delete, divideInTwo, entropyReciprocal, entropyReciprocal, entropyReciprocal, entropyReciprocal, entropyReciprocal, getAllReductsFilename, getAllReductsString, getAllSubreductsFilename, getArffFilename, getArffSource, getBacktrackSteps, getCandidateSubreductConsistencyArray, getCurrentReduct, getCurrentReductIndex, getMeasure, getNumberOfConditions, getOptimalReduct, getReductionTime, getReductString, getRunTimeInformation, hasMissingValue, isNominal, isNumeric, majority, majority, majority, normalize, positiveRegion, positiveRegion, positiveRegion, printAllReducts, readAllReducts, readAllReducts, readAllSubreducts, readAllSubreducts, setAllReductsFilename, setAllReductsFilename, setAllSubreductsFilename, setAllSubreductsFilename, setArffFilename, setCurrentReduct, setCurrentReduct, setMeasure, writeAllReducts
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

numberOfChromosomes

int numberOfChromosomes
The number of Chromosomes.


generations

int generations
The max generation.


bestFitnessValue

double bestFitnessValue
The best fitness value of the group of chromosomes.


bestChromosome

long bestChromosome
The best fitness value of the chromosome.


chromosomes

boolean[][] chromosomes
The population.


candidateReductArray

long[] candidateReductArray
The candidate reducts.


numberOfCandidateReducts

int numberOfCandidateReducts
The number of candidate reducts.


distributionString

java.lang.String distributionString
The name of distribution.


GAFilename

java.lang.String GAFilename
The gred filename.


weighting

boolean weighting
Weighting or not.


numberOfOne

int numberOfOne
The number of 1 in the given boolean conditional attribute array


coreAttributes

boolean[] coreAttributes
The boolean coreAttributes array


runTime

int runTime
The geneticAlgorithmBasedTCSAttributeReduction runTime


computeCoreTime

int computeCoreTime
The numericCore runTime

构造方法详细信息

TestCostDecisionSystemFixedNeighborhoodGA

public TestCostDecisionSystemFixedNeighborhoodGA(TestCostDecisionSystemFixedNeighborhood paraDecisionSystem)
                                          throws java.io.IOException,
                                                 java.lang.Exception
Construct the decision system. Simply adopt everything of the super class.

抛出:
java.io.IOException
java.lang.Exception
方法详细信息

refreshTestCost

public void refreshTestCost()
                     throws java.lang.Exception
Refresh the test-cost settings.

覆盖:
类 TestCostDecisionSystemFixedNeighborhood 中的 refreshTestCost
抛出:
java.lang.Exception

setWeighting

public void setWeighting(boolean paraWeighting)
Set the weighting option for lambda-weighted reduction.


setNumberOfChromosomes

public void setNumberOfChromosomes(int paraNumberOfChromosome)
Set the number of chromosome.

参数:
paraNumberOfChromosome - The number you need.

setGeneration

public void setGeneration(int paraGenerations)
Set the number of generation.

参数:
paraGenerations - The number you need.

setGAFilename

public void setGAFilename()
Set the filename such that it can store results produced by GABasedTCSAttributeReduction.


getGAFilename

public java.lang.String getGAFilename()
Get the GA filename.


geneticAlgorithmBasedTCSAttributeReduction

public boolean[] geneticAlgorithmBasedTCSAttributeReduction(double paraLambda,
                                                            boolean paraAlgorithm)
                                                     throws java.lang.Exception
Find a (possibly) minimal test-cost reduct using the genetic algorithm based reduction algorithm. There are two versions, whose difference lies in the condition of computing fitness values. In the first version, the fitness function can be always executed for every solution. In the second version, the fitness function is executed only if the solution may be a reduct or super-reduct.

参数:
paraLambda - The given lambda value.
paraAlgorithm - Algorithms choice.
返回:
the reduct with the form of boolean vector. This reduct is also stored in the & object as currentReduct.
抛出:
java.lang.Exception

initializePopulation

public void initializePopulation()
                          throws java.lang.Exception
Initialize a population.

抛出:
java.lang.Exception

initializeChromosome

public boolean[] initializeChromosome(boolean[] paraAllAttributes)
                               throws java.lang.Exception
Initialize a chromosome.

参数:
paraAllAttributes - All conditional attribubes.
返回:
tempChromosome A boolean array denoting a solution.
抛出:
java.lang.Exception

initializeChromosomes

public boolean[][] initializeChromosomes(boolean[] paraAllAttributes)
                                  throws java.lang.Exception
Initialize a group of chromosomes.

参数:
paraAllAttributes - The given attributes are not core.
返回:
A group of chromosomes.
抛出:
java.lang.Exception

initializePartOfChromosomesToTrue

public void initializePartOfChromosomesToTrue()
                                       throws java.lang.Exception
If no chromosome is a solution, then initialize a part of chromosomes(one tenth) to all true.

抛出:
java.lang.Exception

geneticAlgorithmBasedTCSAttributeReduction_FirstVersion

public void geneticAlgorithmBasedTCSAttributeReduction_FirstVersion(double paraLambda)
                                                             throws java.lang.Exception
The first version of the genetic algorithm.

参数:
paraLambda - The given lambda value.
抛出:
java.lang.Exception

selectionOperation_FirstVersion

public boolean[][] selectionOperation_FirstVersion(boolean[][] paraChromosomes,
                                                   int paraMaxPositiveRegion,
                                                   double paraLambda)
                                            throws java.lang.Exception
Select new the group of chromosomes in the first version of the genetic algorithm.

参数:
paraChromosomes - The given chromosomes.
paraMaxPositiveRegion - The candinality of the positive region of the decision.
paraLambda - The lambad value.
返回:
A new group of chromosomes.
抛出:
java.lang.Exception

computeFitnessValue_FirstVersion

public double computeFitnessValue_FirstVersion(boolean[] paraChromosome,
                                               int paraMaxPositiveRegion,
                                               double paraLambda)
                                        throws java.lang.Exception
Compute the fitness of the given chromosome in the first version of the genetic algorithm.

参数:
paraChromosome - The given chromosome.
paraMaxPositiveRegion - The candinality of the positive region of the decision.
paraLambda - The lambad value.
返回:
A fitness value of the chromosome.
抛出:
java.lang.Exception

geneticAlgorithmBasedTCSAttributeReduction_SecondVersion

public void geneticAlgorithmBasedTCSAttributeReduction_SecondVersion(double paraLambda)
                                                              throws java.lang.Exception
The second version of the genetic algorithm.

参数:
paraLambda - The given lambda value.
抛出:
java.lang.Exception

selectionOperation_SecondVersion

public boolean[][] selectionOperation_SecondVersion(boolean[][] paraChromosomes,
                                                    int paraMaxPositiveRegion,
                                                    double paraLambda)
                                             throws java.lang.Exception
Select new the group of chromosomes in the second version of the genetic algorithm.

参数:
paraChromosomes - The given chromosomes.
paraMaxPositiveRegion - The candinality of the positive region of the decision.
paraLambda - The lambad value.
返回:
A new group of chromosomes.
抛出:
java.lang.Exception

computeFitnessValue_SecondVersion

public double computeFitnessValue_SecondVersion(boolean[] paraChromosome,
                                                int paraMaxPositiveRegion,
                                                double paraLambda)
                                         throws java.lang.Exception
Compute the fitness of the given chromosome in the second version of the genetic algorithm.

参数:
paraChromosome - The given chromosome.
paraMaxPositiveRegion - The candinality of the positive region of the decision.
paraLambda - The lambad value.
返回:
A fitness value of the chromosome.
抛出:
java.lang.Exception

crossoverOperation

public boolean[][] crossoverOperation(boolean[][] paraChromosomes)
                               throws java.lang.Exception
Uniform crossover.

参数:
paraChromosomes - The given group of chromosomes.
返回:
A new population after crossover operation.
抛出:
java.lang.Exception

searchPairsOfChromosomes

public int searchPairsOfChromosomes(boolean[] paraCheckChromosome)
                             throws java.lang.Exception
Select a chromosomes for crossover.

参数:
paraCheckChromosome - The given checked of chromosomes.
返回:
The index of selected chromosome.
抛出:
java.lang.Exception

mutationOperation

public boolean[][] mutationOperation(boolean[][] paraChromosomes)
                              throws java.lang.Exception
Mutation operation.

参数:
paraChromosomes - The given chromosomes.
返回:
The chromosomes.
抛出:
java.lang.Exception

numericCore

public boolean[] numericCore()
                      throws java.lang.Exception
Compute the core of numeric attribute set

抛出:
java.lang.Exception

GABasedMinimalAttributeReduction

public long[] GABasedMinimalAttributeReduction()
                                        throws java.lang.Exception
Find a (possibly) minimal reduct using the genetic algorithm based reduction algorithm.

返回:
The candidate reducts.
抛出:
java.lang.Exception

computeFitnessValue

public double computeFitnessValue(boolean[] paraChromosome,
                                  int paraMaxPositiveRegion)
                           throws java.lang.Exception
Compute the fitness of the given chromosome.

参数:
paraChromosome - The given chromosome
返回:
A fitness value of the chromosome.
抛出:
java.lang.Exception

selectionOperation

public boolean[][] selectionOperation(boolean[][] paraChromosomes,
                                      int paraMaxPositiveRegion)
                               throws java.lang.Exception
Select new the group of chromosomes.

参数:
paraChromosomes - The given chromosomes.
返回:
A new group of chromosomes.
抛出:
java.lang.Exception

removeRedundantReducts

public long[] removeRedundantReducts()
                              throws java.lang.Exception
Remove redundant candidate reducts.

返回:
object status.
抛出:
java.lang.Exception

bestInsteadOfWorst

public boolean[][] bestInsteadOfWorst(boolean[][] paraChromosomes)
                               throws java.lang.Exception
The worst individual in offsprings is replaced by & the best individual in parent generation.

参数:
paraChromosomes - The given popution.
返回:
paraChromosomes The new popution.
抛出:
java.lang.Exception

computeExceedingFactor

public double computeExceedingFactor()
                              throws java.lang.Exception
Get the exceeding factor.

覆盖:
类 DecisionSystemNeighborhood 中的 computeExceedingFactor
返回:
the exceeding factor.
抛出:
exception - if the optimal reduct is not obtained yet.
java.lang.Exception

computeTestCost

public int computeTestCost(long paraSelectedTests)
                    throws java.lang.Exception
Compute the cost of selected tests.

覆盖:
类 CostSensitiveDecisionSystem 中的 computeTestCost
参数:
paraSelectedTests - which tests are selected, represented by an integer.
返回:
the cost of selected tests.
抛出:
exception - if the optimal reduct is not obtained yet.
java.lang.Exception
另请参见:
CostSensitiveDecisionSystem.computeTestCost(boolean[])

isCurrentReductOptimal

public boolean isCurrentReductOptimal()
                               throws java.lang.Exception
Is the current reduct optimal?

覆盖:
类 DecisionSystemNeighborhood 中的 isCurrentReductOptimal
返回:
true if it is optimal.
抛出:
java.lang.Exception - if the reduct or the set of all reducts not computed yet.

subSetCheck

public char subSetCheck(long[] paraCandidateSubReducts,
                        int fisrt,
                        int second)
Check Who is who's subset.

参数:
paraCandidateSubReducts - The long array of CandidateSubReducts.
fisrt - the first set.
second - the second set.
返回:
A char as a check.