Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * 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 org.drools.planner.benchmark;
 
 import java.io.File;
 import java.util.List;
 
 
 @XStreamAlias("solverBenchmark")
 public class SolverBenchmark {
 
     private String name = null;
 
     @XStreamAlias("solver")
     private SolverConfig solverConfig = null;
     @XStreamImplicit(itemFieldName = "unsolvedSolutionFile")
     private List<FileunsolvedSolutionFileList = null;
 
     @XStreamImplicit(itemFieldName = "solverBenchmarkResult")
 
     // Ranking starts from 0
     private Integer ranking = null;
 
     public String getName() {
         return ;
     }
 
     public void setName(String name) {
         this. = name;
     }
 
     public SolverConfig getSolverConfig() {
         return ;
     }
 
     public void setSolverConfig(SolverConfig solverConfig) {
         this. = solverConfig;
     }
 
     public List<FilegetUnsolvedSolutionFileList() {
         return ;
     }
 
     public void setUnsolvedSolutionFileList(List<FileunsolvedSolutionFileList) {
         this. = unsolvedSolutionFileList;
     }
 
         return ;
     }
 
     public void setSolverBenchmarkResultList(List<SolverBenchmarkResultsolverBenchmarkResultList) {
         this. = solverBenchmarkResultList;
     }
 
     public Integer getRanking() {
         return ;
     }
 
     public void setRanking(Integer ranking) {
         this. = ranking;
     }
 
     // ************************************************************************
     // Builder methods
     // ************************************************************************
 
     public void inherit(SolverBenchmark inheritedSolverBenchmark) {
         if ( == null) {
              = inheritedSolverBenchmark.getSolverConfig();
         } else if (inheritedSolverBenchmark.getSolverConfig() != null) {
             .inherit(inheritedSolverBenchmark.getSolverConfig());
         }
         if ( == null) {
              = inheritedSolverBenchmark.getUnsolvedSolutionFileList();
         } else if (inheritedSolverBenchmark.getUnsolvedSolutionFileList() != null) {
             // The inherited unsolvedSolutionFiles should be before the non-inherited one
             List<FilemergedList = new ArrayList<File>(inheritedSolverBenchmark.getUnsolvedSolutionFileList());
             for (File unsolvedSolutionFile : ) {
                if (!mergedList.contains(unsolvedSolutionFile)) {
                    mergedList.add(unsolvedSolutionFile);
                }
            }
             = mergedList;
        }
    }
    public void resetSolverBenchmarkResultList() {
        for (File unsolvedSolutionFile : ) {
            SolverBenchmarkResult result = new SolverBenchmarkResult();
            result.setUnsolvedSolutionFile(unsolvedSolutionFile);
            .add(result);
        }
    }
    public List<ScoregetScoreList() {
        List<ScorescoreList = new ArrayList<Score>(.size());
        for (SolverBenchmarkResult solverBenchmarkResult : ) {
            scoreList.add(solverBenchmarkResult.getScore());
        }
        return scoreList;
    }

    

Returns:
the total score
    public Score getTotalScore() {
        Score totalScore = null;
        for (SolverBenchmarkResult solverBenchmarkResult : ) {
            if (totalScore == null) {
                totalScore = solverBenchmarkResult.getScore();
            } else {
                totalScore = totalScore.add(solverBenchmarkResult.getScore());
            }
        }
        return totalScore;
    }

    

Returns:
the average score
    public Score getAverageScore() {
    }
    public void validate() {
        if ( == null || .isEmpty()) {
            throw new IllegalArgumentException(
                    "Configure at least 1 <unsolvedSolutionFile> for the <solverBenchmark> (" + 
                            + ") directly or indirectly by inheriting it.");
        }
    }
New to GrepCode? Check out our FAQ X