<commit_before>/*
 * 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.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import org.drools.planner.config.localsearch.LocalSearchSolverConfig;
import org.drools.planner.core.score.Score;

@XStreamAlias("solverBenchmark")
public class SolverBenchmark {

    private String name = null;

    @XStreamAlias("localSearchSolver")
    private LocalSearchSolverConfig localSearchSolverConfig = null;
    @XStreamImplicit(itemFieldName = "unsolvedSolutionFile")
    private List<File> unsolvedSolutionFileList = null;

    @XStreamImplicit(itemFieldName = "solverBenchmarkResult")
    private List<SolverBenchmarkResult> solverBenchmarkResultList = null;

    // Ranking starts from 0
    private Integer ranking = null;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public LocalSearchSolverConfig getLocalSearchSolverConfig() {
        return localSearchSolverConfig;
    }

    public void setLocalSearchSolverConfig(LocalSearchSolverConfig localSearchSolverConfig) {
        this.localSearchSolverConfig = localSearchSolverConfig;
    }

    public List<File> getUnsolvedSolutionFileList() {
        return unsolvedSolutionFileList;
    }

    public void setUnsolvedSolutionFileList(List<File> unsolvedSolutionFileList) {
        this.unsolvedSolutionFileList = unsolvedSolutionFileList;
    }

    public List<SolverBenchmarkResult> getSolverBenchmarkResultList() {
        return solverBenchmarkResultList;
    }

    public void setSolverBenchmarkResultList(List<SolverBenchmarkResult> solverBenchmarkResultList) {
        this.solverBenchmarkResultList = solverBenchmarkResultList;
    }

    public Integer getRanking() {
        return ranking;
    }

    public void setRanking(Integer ranking) {
        this.ranking = ranking;
    }

    // ************************************************************************
    // Builder methods
    // ************************************************************************

    public void inherit(SolverBenchmark inheritedSolverBenchmark) {
        if (localSearchSolverConfig == null) {
            localSearchSolverConfig = inheritedSolverBenchmark.getLocalSearchSolverConfig();
        } else if (inheritedSolverBenchmark.getLocalSearchSolverConfig() != null) {
            localSearchSolverConfig.inherit(inheritedSolverBenchmark.getLocalSearchSolverConfig());
        }
        if (unsolvedSolutionFileList == null) {
            unsolvedSolutionFileList = inheritedSolverBenchmark.getUnsolvedSolutionFileList();
        } else if (inheritedSolverBenchmark.getUnsolvedSolutionFileList() != null) {
            for (File inheritedUnsolvedSolutionFile : inheritedSolverBenchmark.getUnsolvedSolutionFileList()) {
                if (!unsolvedSolutionFileList.contains(inheritedUnsolvedSolutionFile)) {
                    unsolvedSolutionFileList.add(inheritedUnsolvedSolutionFile);
                }
            }
        }
    }

    public void resetSolverBenchmarkResultList() {
        solverBenchmarkResultList = new ArrayList<SolverBenchmarkResult>();
        for (File unsolvedSolutionFile : unsolvedSolutionFileList) {
            SolverBenchmarkResult result = new SolverBenchmarkResult();
            result.setUnsolvedSolutionFile(unsolvedSolutionFile);
            solverBenchmarkResultList.add(result);
        }
    }

    public List<Score> getScoreList() {
        List<Score> scoreList = new ArrayList<Score>(solverBenchmarkResultList.size());
        for (SolverBenchmarkResult solverBenchmarkResult : solverBenchmarkResultList) {
            scoreList.add(solverBenchmarkResult.getScore());
        }
        return scoreList;
    }

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

    /**
     * @return the average score
     */
    public Score getAverageScore() {
        return getTotalScore().divide(solverBenchmarkResultList.size());
    }

}
<commit_msg>solverbenchmark: The inherited unsolvedSolutionFiles should be before the non-inherited unsolvedSolutionFiles.<commit_after>/*
 * 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.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import org.drools.planner.config.localsearch.LocalSearchSolverConfig;
import org.drools.planner.core.score.Score;

@XStreamAlias("solverBenchmark")
public class SolverBenchmark {

    private String name = null;

    @XStreamAlias("localSearchSolver")
    private LocalSearchSolverConfig localSearchSolverConfig = null;
    @XStreamImplicit(itemFieldName = "unsolvedSolutionFile")
    private List<File> unsolvedSolutionFileList = null;

    @XStreamImplicit(itemFieldName = "solverBenchmarkResult")
    private List<SolverBenchmarkResult> solverBenchmarkResultList = null;

    // Ranking starts from 0
    private Integer ranking = null;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public LocalSearchSolverConfig getLocalSearchSolverConfig() {
        return localSearchSolverConfig;
    }

    public void setLocalSearchSolverConfig(LocalSearchSolverConfig localSearchSolverConfig) {
        this.localSearchSolverConfig = localSearchSolverConfig;
    }

    public List<File> getUnsolvedSolutionFileList() {
        return unsolvedSolutionFileList;
    }

    public void setUnsolvedSolutionFileList(List<File> unsolvedSolutionFileList) {
        this.unsolvedSolutionFileList = unsolvedSolutionFileList;
    }

    public List<SolverBenchmarkResult> getSolverBenchmarkResultList() {
        return solverBenchmarkResultList;
    }

    public void setSolverBenchmarkResultList(List<SolverBenchmarkResult> solverBenchmarkResultList) {
        this.solverBenchmarkResultList = solverBenchmarkResultList;
    }

    public Integer getRanking() {
        return ranking;
    }

    public void setRanking(Integer ranking) {
        this.ranking = ranking;
    }

    // ************************************************************************
    // Builder methods
    // ************************************************************************

    public void inherit(SolverBenchmark inheritedSolverBenchmark) {
        if (localSearchSolverConfig == null) {
            localSearchSolverConfig = inheritedSolverBenchmark.getLocalSearchSolverConfig();
        } else if (inheritedSolverBenchmark.getLocalSearchSolverConfig() != null) {
            localSearchSolverConfig.inherit(inheritedSolverBenchmark.getLocalSearchSolverConfig());
        }
        if (unsolvedSolutionFileList == null) {
            unsolvedSolutionFileList = inheritedSolverBenchmark.getUnsolvedSolutionFileList();
        } else if (inheritedSolverBenchmark.getUnsolvedSolutionFileList() != null) {
            // The inherited unsolvedSolutionFiles should be before the non-inherited unsolvedSolutionFiles.
            List<File> mergedList = new ArrayList<File>(inheritedSolverBenchmark.getUnsolvedSolutionFileList());
            for (File unsolvedSolutionFile : unsolvedSolutionFileList) {
                if (!mergedList.contains(unsolvedSolutionFile)) {
                    mergedList.add(unsolvedSolutionFile);
                }
            }
            unsolvedSolutionFileList = mergedList;
        }
    }

    public void resetSolverBenchmarkResultList() {
        solverBenchmarkResultList = new ArrayList<SolverBenchmarkResult>();
        for (File unsolvedSolutionFile : unsolvedSolutionFileList) {
            SolverBenchmarkResult result = new SolverBenchmarkResult();
            result.setUnsolvedSolutionFile(unsolvedSolutionFile);
            solverBenchmarkResultList.add(result);
        }
    }

    public List<Score> getScoreList() {
        List<Score> scoreList = new ArrayList<Score>(solverBenchmarkResultList.size());
        for (SolverBenchmarkResult solverBenchmarkResult : solverBenchmarkResultList) {
            scoreList.add(solverBenchmarkResult.getScore());
        }
        return scoreList;
    }

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

    /**
     * @return the average score
     */
    public Score getAverageScore() {
        return getTotalScore().divide(solverBenchmarkResultList.size());
    }

}

{'fraction_non_alphanumeric': 0.10166746069556933, 'fraction_numerical': 0.001715102429728442, 'mean_word_length': 3.39163179916318, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4827466', 'n_tokens_mistral': 2896, 'n_tokens_neox': 2727, 'n_words': 588}