当前位置: 首页>>代码示例>>Java>>正文


Java Solution类代码示例

本文整理汇总了Java中org.optaplanner.core.api.domain.solution.Solution的典型用法代码示例。如果您正苦于以下问题:Java Solution类的具体用法?Java Solution怎么用?Java Solution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Solution类属于org.optaplanner.core.api.domain.solution包,在下文中一共展示了Solution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertAll

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void convertAll() {
    File inputDir = getInputDir();
    if (!inputDir.exists()) {
        throw new IllegalStateException("The directory inputDir (" + inputDir.getAbsolutePath()
                + ") does not exist.");
    }
    File outputDir = getOutputDir();
    outputDir.mkdirs();
    File[] inputFiles = inputDir.listFiles();
    Arrays.sort(inputFiles, new ProblemFileComparator());
    for (File inputFile : inputFiles) {
        String inputFileName = inputFile.getName();
        if (inputFileName.endsWith("." + getInputFileSuffix())) {
            Solution solution = solutionDao.readSolution(inputFile);
            String outputFileName = inputFileName.substring(0,
                    inputFileName.length() - getInputFileSuffix().length())
                    + getOutputFileSuffix();
            File outputFile = new File(outputDir, outputFileName);
            writeSolution(solution, outputFile);
        }
    }
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:23,代码来源:AbstractSolutionExporter.java

示例2: plan

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public List<ShiftAssignment> plan() {
    SolverFactory<Solution> solverFactory = SolverFactory.createFromXmlResource("planner/EmployeeRosteringSolverConfig.xml");
    Solver solver = solverFactory.buildSolver();

    EmployeeRoster employeeRoster = new EmployeeRoster();
    employeeRoster.setCode("TEST");
    employeeRoster.setSkillList(employeeRepository.listSkills());
    employeeRoster.setShiftTypeList(shiftRepository.listShiftTypes());
    employeeRoster.setShiftTypeSkillRequirementList(generateShiftTypeSkillRequirements());
    employeeRoster.setPatternList(patternsRepository.listAll());
    employeeRoster.setContractList(contractRepository.listAll());
    employeeRoster.setContractLineList(generateContractLines());
    employeeRoster.setPatternContractLineList(generateContractPatternList());
    employeeRoster.setEmployeeList(employeeRepository.listAll());
    employeeRoster.setSkillProficiencyList(generateSkillProficiency());
    employeeRoster.setShiftDateList(shiftRepository.listShiftDates());
    employeeRoster.setShiftList(shiftRepository.listShifts());
    employeeRoster.setDayOffRequestList(employeeRepository.listDayOffRequests());
    employeeRoster.setDayOnRequestList(employeeRepository.listDayOnRequests());
    employeeRoster.setShiftOffRequestList(employeeRepository.listShiftOffRequests());
    employeeRoster.setShiftOnRequestList(employeeRepository.listShiftOnRequests());
    employeeRoster.setEmployeeRosterParametrization(generateEmployeeRosterInfo());
    employeeRoster.setShiftAssignmentList(generateAssigments());

    employeeRoster = (EmployeeRoster) solver.solve(employeeRoster);
    final HardSoftScore score = employeeRoster.getScore();
    for (ShiftAssignment shiftAssignment : employeeRoster.getShiftAssignmentList()) {
        shiftRepository.createShiftAssignment(shiftAssignment.getShift(), shiftAssignment.getEmployee());
    }
    messageService.informUser(String.format("'%s' score ", score.toString()));

    return shiftRepository.listShiftAssignments();
}
 
开发者ID:bibryam,项目名称:rotabuilder,代码行数:34,代码来源:ShiftService.java

示例3: resetPanel

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void resetPanel(Solution solution) {
    CloudBalance cloudBalance = (CloudBalance) solution;
    maximumComputerCpuPower = 0;
    maximumComputerMemory = 0;
    maximumComputerNetworkBandwidth = 0;
    for (CloudComputer computer : cloudBalance.getComputerList()) {
        if (computer.getCpuPower() > maximumComputerCpuPower) {
            maximumComputerCpuPower = computer.getCpuPower();
        }
        if (computer.getMemory() > maximumComputerMemory) {
            maximumComputerMemory = computer.getMemory();
        }
        if (computer.getNetworkBandwidth() > maximumComputerNetworkBandwidth) {
            maximumComputerNetworkBandwidth = computer.getNetworkBandwidth();
        }
    }
    for (CloudComputerPanel computerPanel : computerToPanelMap.values()) {
        if (computerPanel.getComputer() != null) {
            computersPanel.remove(computerPanel);
        }
    }
    computerToPanelMap.clear();
    computersPanel.removeAll();
    unassignedPanel = new CloudComputerPanel(this, null);
    computersPanel.add(unassignedPanel);
    computerToPanelMap.put(null, unassignedPanel);
    updatePanel(solution);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:29,代码来源:CloudBalancingPanel.java

示例4: doProblemFactChange

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void doProblemFactChange(ProblemFactChange problemFactChange, boolean reset) {
    solutionBusiness.doProblemFactChange(problemFactChange);
    Solution solution = solutionBusiness.getSolution();
    if (reset) {
        resetPanel(solution);
    } else {
        updatePanel(solution);
    }
    validate();
    solverAndPersistenceFrame.refreshScoreField(solution);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:12,代码来源:SolutionPanel.java

示例5: bestSolutionChanged

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void bestSolutionChanged() {
    Solution solution = solutionBusiness.getSolution();
    if (refreshScreenDuringSolvingCheckBox.isSelected()) {
        solutionPanel.updatePanel(solution);
        validate(); // TODO remove me?
    }
    refreshScoreField(solution);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:9,代码来源:SolverAndPersistenceFrame.java

示例6: refreshScoreField

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void refreshScoreField(Solution solution) {
    // TODO Fix after https://issues.jboss.org/browse/PLANNER-405
    int uninitializedVariableCount = solutionBusiness.getUninitializedVariableCount();
    Score score = solution.getScore();
    scoreField.setForeground(determineScoreFieldForeground(uninitializedVariableCount, score));
    scoreField.setText("Latest best score: " + ScoreUtils.getScoreWithUninitializedPrefix(uninitializedVariableCount, score));
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:8,代码来源:SolverAndPersistenceFrame.java

示例7: writeSolution

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void writeSolution(Solution solution, File outputFile) {
    BufferedWriter bufferedWriter = null;
    try {
        bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"));
        TxtOutputBuilder txtOutputBuilder = createTxtOutputBuilder();
        txtOutputBuilder.setBufferedWriter(bufferedWriter);
        txtOutputBuilder.setSolution(solution);
        txtOutputBuilder.writeSolution();
    } catch (IOException e) {
        throw new IllegalArgumentException("Could not write the file (" + outputFile.getName() + ").", e);
    } finally {
        IOUtils.closeQuietly(bufferedWriter);
    }
    logger.info("Exported: {}", outputFile);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:16,代码来源:AbstractTxtSolutionExporter.java

示例8: readSolution

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public Solution readSolution() throws IOException {
    String firstLine = readStringValue();
    if (firstLine.matches("\\s*NAME\\s*:.*")) {
        solution = new VehicleRoutingSolution();
        solution.setId(0L);
        solution.setName(removePrefixSuffixFromLine(firstLine, "\\s*NAME\\s*:", ""));
        readVrpWebFormat();
    } else if (splitBySpacesOrTabs(firstLine).length == 3) {
        solution = new VehicleRoutingSolution();
        solution.setId(0L);
        /* ORIGINAL
        solution.setName(FilenameUtils.getBaseName(inputFile.getName())); */
        solution.setName(FilenameUtils.getBaseName(inputFileNameWithExt));
        String[] tokens = splitBySpacesOrTabs(firstLine, 3);
        customerListSize = Integer.parseInt(tokens[0]);
        vehicleListSize = Integer.parseInt(tokens[1]);
        capacity = Integer.parseInt(tokens[2]);
        readCourseraFormat();
    } else {
        solution = new TimeWindowedVehicleRoutingSolution();
        solution.setId(0L);
        solution.setName(firstLine);
        readTimeWindowedFormat();
    }
     /* TODO enable logger
    BigInteger possibleSolutionSize
            = factorial(customerListSize + vehicleListSize - 1).divide(factorial(vehicleListSize - 1));

    logger.info("VehicleRoutingSolution {} has {} depots, {} vehicles and {} customers with a search space of {}.",
            getInputId(),
            solution.getDepotList().size(),
            solution.getVehicleList().size(),
            solution.getCustomerList().size(),
            getFlooredPossibleSolutionSize(possibleSolutionSize));
    */
    return solution;
}
 
开发者ID:tomasdavidorg,项目名称:android-vehicle-routing-problem,代码行数:38,代码来源:VehicleRoutingInputBuilder.java

示例9: updatePanel

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void updatePanel(Solution solution) {
    resetPanel(solution);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:4,代码来源:SolutionPanel.java

示例10: resetScreen

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void resetScreen() {
    Solution solution = solutionBusiness.getSolution();
    solutionPanel.resetPanel(solution);
    validate();
    refreshScoreField(solution);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:7,代码来源:SolverAndPersistenceFrame.java

示例11: convert

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
protected void convert(File inputFile, File outputFile) {
    Solution solution = readSolution(inputFile);
    solutionDao.writeSolution(solution, outputFile);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:5,代码来源:AbstractSolutionImporter.java

示例12: readSolution

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public Solution readSolution(File inputSolutionFile) {
    Solution solution = xStreamSolutionFileIO.read(inputSolutionFile);
    logger.info("Opened: {}", inputSolutionFile);
    return solution;
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:6,代码来源:XStreamSolutionDao.java

示例13: writeSolution

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void writeSolution(Solution solution, File outputSolutionFile) {
    xStreamSolutionFileIO.write(solution, outputSolutionFile);
    logger.info("Saved: {}", outputSolutionFile);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:5,代码来源:XStreamSolutionDao.java

示例14: setSolution

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void setSolution(Solution solution) {
    guiScoreDirector.setWorkingSolution(solution);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:4,代码来源:SolutionBusiness.java

示例15: importSolution

import org.optaplanner.core.api.domain.solution.Solution; //导入依赖的package包/类
public void importSolution(File file) {
    AbstractSolutionImporter importer = determineImporter(file);
    Solution solution = importer.readSolution(file);
    solutionFileName = file.getName();
    guiScoreDirector.setWorkingSolution(solution);
}
 
开发者ID:xmlking,项目名称:ml-experiments,代码行数:7,代码来源:SolutionBusiness.java


注:本文中的org.optaplanner.core.api.domain.solution.Solution类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。