本文整理汇总了Java中org.optaplanner.core.impl.score.director.ScoreDirector类的典型用法代码示例。如果您正苦于以下问题:Java ScoreDirector类的具体用法?Java ScoreDirector怎么用?Java ScoreDirector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScoreDirector类属于org.optaplanner.core.impl.score.director包,在下文中一共展示了ScoreDirector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addComputer
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
public void addComputer(final CloudComputer computer) {
logger.info("Scheduling addition of computer ({}).", computer);
doProblemFactChange(new ProblemFactChange() {
public void doChange(ScoreDirector scoreDirector) {
CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
// Set a unique id on the new computer
long nextComputerId = 0L;
for (CloudComputer otherComputer : cloudBalance.getComputerList()) {
if (nextComputerId <= otherComputer.getId()) {
nextComputerId = otherComputer.getId() + 1L;
}
}
computer.setId(nextComputerId);
// A SolutionCloner does not clone problem fact lists (such as computerList)
// Shallow clone the computerList so only workingSolution is affected, not bestSolution or guiSolution
cloudBalance.setComputerList(new ArrayList<CloudComputer>(cloudBalance.getComputerList()));
// Add the problem fact itself
scoreDirector.beforeProblemFactAdded(computer);
cloudBalance.getComputerList().add(computer);
scoreDirector.afterProblemFactAdded(computer);
}
});
}
开发者ID:xmlking,项目名称:ml-experiments,代码行数:24,代码来源:CloudBalancingPanel.java
示例2: addProcess
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
public void addProcess(final CloudProcess process) {
logger.info("Scheduling addition of process ({}).", process);
doProblemFactChange(new ProblemFactChange() {
public void doChange(ScoreDirector scoreDirector) {
CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
// Set a unique id on the new process
long nextProcessId = 0L;
for (CloudProcess otherProcess : cloudBalance.getProcessList()) {
if (nextProcessId <= otherProcess.getId()) {
nextProcessId = otherProcess.getId() + 1L;
}
}
process.setId(nextProcessId);
// Add the planning entity itself
scoreDirector.beforeEntityAdded(process);
cloudBalance.getProcessList().add(process);
scoreDirector.afterEntityAdded(process);
scoreDirector.triggerVariableListeners();
}
});
}
开发者ID:xmlking,项目名称:ml-experiments,代码行数:22,代码来源:CloudBalancingPanel.java
示例3: deleteProcess
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
public void deleteProcess(final CloudProcess process) {
logger.info("Scheduling delete of process ({}).", process);
doProblemFactChange(new ProblemFactChange() {
public void doChange(ScoreDirector scoreDirector) {
CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
// Remove the planning entity itself
for (Iterator<CloudProcess> it = cloudBalance.getProcessList().iterator(); it.hasNext(); ) {
CloudProcess workingProcess = it.next();
if (ObjectUtils.equals(workingProcess, process)) {
scoreDirector.beforeEntityRemoved(workingProcess);
it.remove(); // remove from list
scoreDirector.afterEntityRemoved(workingProcess);
break;
}
}
scoreDirector.triggerVariableListeners();
}
});
}
开发者ID:xmlking,项目名称:ml-experiments,代码行数:20,代码来源:CloudBalancingPanel.java
示例4: doChange
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
public void doChange(ScoreDirector scoreDirector) {
CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
for (CloudProcess process : cloudBalance.getProcessList()) {
if (ObjectUtils.equals(process.getComputer(), removingComputer)) {
scoreDirector.beforeVariableChanged(process, "computer");
process.setComputer(null);
scoreDirector.afterVariableChanged(process, "computer");
}
}
cloudBalance.setComputerList(new ArrayList<CloudComputer>(cloudBalance.getComputerList()));
for (Iterator<CloudComputer> it = cloudBalance.getComputerList().iterator(); it.hasNext();) {
CloudComputer workingComputer = it.next();
if (ObjectUtils.equals(workingComputer, removingComputer)) {
scoreDirector.beforeProblemFactRemoved(workingComputer);
it.remove(); // remove from list
scoreDirector.beforeProblemFactRemoved(workingComputer);
scoreDirector.triggerVariableListeners();
break;
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:OptaPlannerDaemonSolverTest.java
示例5: changeWorkingSolution
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
public void changeWorkingSolution(ScoreDirector scoreDirector) {
ReindeerRoutingSolution originalSolution = (ReindeerRoutingSolution) scoreDirector.getWorkingSolution();
List<Reindeer> reindeerList = originalSolution.getReindeerList();
Iterator<Reindeer> reindeerIterator = reindeerList.iterator();
for (GiftAssignment giftAssignment : originalSolution.getGiftAssignmentList()) {
if (giftAssignment.getGift().isBigGift() && giftAssignment.getPreviousStandstill() == null) {
if (!reindeerIterator.hasNext()) {
throw new IllegalStateException("There are more big gifts than there are reindeer ("
+ reindeerList.size() + ").");
}
Reindeer reindeer = reindeerIterator.next();
scoreDirector.beforeVariableChanged(giftAssignment, "previousStandstill");
giftAssignment.setPreviousStandstill(reindeer);
scoreDirector.afterVariableChanged(giftAssignment, "previousStandstill");
}
}
scoreDirector.triggerVariableListeners();
}
开发者ID:ge0ffrey,项目名称:santas-stolen-sleigh,代码行数:19,代码来源:BigGiftInitializer.java
示例6: doChange
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
public void doChange(ScoreDirector scoreDirector) {
OptimalDistributionStepsSolution space = (OptimalDistributionStepsSolution) scoreDirector.getWorkingSolution();
for (Iterator<Object> i = space.getFixedFacts().iterator(); i.hasNext(); ) {
Object fact = i.next();
if (fact instanceof RunningVm
&& ((RunningVm)fact).getId().equals(uuid)) {
scoreDirector.beforeProblemFactRemoved(fact);
i.remove();
scoreDirector.afterProblemFactRemoved(fact);
}
}
/* Required since Optaplanner 6.3.0 */
scoreDirector.triggerVariableListeners();
}
开发者ID:oVirt,项目名称:ovirt-optimizer,代码行数:18,代码来源:CancelVmRunningFactChange.java
示例7: recomputeScoreUsingScoreDirector
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
/**
* Recompute solution's score and log all rules that affected it (in debug mode)
* This method uses new score director from the passed solver
*
* @param solver
* @param solution
*/
public static void recomputeScoreUsingScoreDirector(Solver solver, OptimalDistributionStepsSolution solution) {
ScoreDirector director = solver.getScoreDirectorFactory().buildScoreDirector();
director.setWorkingSolution(solution);
Score score = director.calculateScore();
for (ConstraintMatchTotal constraintMatchTotal : director.getConstraintMatchTotals()) {
String constraintName = constraintMatchTotal.getConstraintName();
Number weightTotal = constraintMatchTotal.getWeightTotalAsNumber();
for (ConstraintMatch constraintMatch : constraintMatchTotal.getConstraintMatchSet()) {
List<Object> justificationList = constraintMatch.getJustificationList();
Number weight = constraintMatch.getWeightAsNumber();
log.debug("Constraint match {} with weight {}", constraintMatch, weight);
for (Object item : justificationList) {
log.debug("Justified by {}", item);
}
}
}
log.debug("Final score {}", score);
}
开发者ID:oVirt,项目名称:ovirt-optimizer,代码行数:27,代码来源:SolverUtils.java
示例8: doMoveOnGenuineVariables
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
protected void doMoveOnGenuineVariables(ScoreDirector scoreDirector) {
Employee oldLeftEmployee = leftShiftAssignment.getEmployee();
Employee oldRightEmployee = rightShiftAssignment.getEmployee();
EmployeeRosteringMoveHelper.moveEmployee(scoreDirector, leftShiftAssignment, oldRightEmployee);
EmployeeRosteringMoveHelper.moveEmployee(scoreDirector, rightShiftAssignment, oldLeftEmployee);
}
开发者ID:bibryam,项目名称:rotabuilder,代码行数:8,代码来源:ShiftAssignmentSwapMove.java
示例9: doMoveOnGenuineVariables
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
protected void doMoveOnGenuineVariables(ScoreDirector scoreDirector) {
for (ShiftAssignment shiftAssignment : shiftAssignmentList) {
if (!shiftAssignment.getEmployee().equals(fromEmployee)) {
throw new IllegalStateException("The shiftAssignment (" + shiftAssignment + ") should have the same employee ("
+ fromEmployee + ") as the fromEmployee (" + fromEmployee + ").");
}
EmployeeRosteringMoveHelper.moveEmployee(scoreDirector, shiftAssignment, toEmployee);
}
}
开发者ID:bibryam,项目名称:rotabuilder,代码行数:11,代码来源:EmployeeMultipleChangeMove.java
示例10: describeBest
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
public String describeBest() {
Solver<ConferenceData> solver = this.solver;
if (solver == null) {
return "";
}
ConferenceData currentBest = solver.getBestSolution();
if (currentBest == prevBest) {
return prevBestDescr;
}
prevBest = currentBest;
currentBest.sort();
StringWriter sw = new StringWriter();
ScoreDirector<ConferenceData> scorer = solver.getScoreDirectorFactory().buildScoreDirector();
scorer.setWorkingSolution(currentBest);
Collection<ConstraintMatchTotal> totals = scorer.getConstraintMatchTotals();
Map<Object, Indictment> map = scorer.getIndictmentMap();
sw.append("<html><body style='font-family:monospace'>");
for (ConstraintMatchTotal total : totals) {
sw.append(String.valueOf(total.getScoreTotal())).append("\t").append(total.getConstraintName()).append("<br>");
}
sw.append("<br>");
currentBest.print(sw, map);
sw.append("</body></html>");
prevBestDescr = sw.toString();
return prevBestDescr;
}
开发者ID:vlsi,项目名称:confplanner,代码行数:30,代码来源:SolverAction.java
示例11: deleteComputer
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
public void deleteComputer(final CloudComputer computer) {
logger.info("Scheduling delete of computer ({}).", computer);
doProblemFactChange(new ProblemFactChange() {
public void doChange(ScoreDirector scoreDirector) {
CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
// First remove the problem fact from all planning entities that use it
for (CloudProcess process : cloudBalance.getProcessList()) {
if (ObjectUtils.equals(process.getComputer(), computer)) {
scoreDirector.beforeVariableChanged(process, "computer");
process.setComputer(null);
scoreDirector.afterVariableChanged(process, "computer");
}
}
scoreDirector.triggerVariableListeners();
// A SolutionCloner does not clone problem fact lists (such as computerList)
// Shallow clone the computerList so only workingSolution is affected, not bestSolution or guiSolution
cloudBalance.setComputerList(new ArrayList<CloudComputer>(cloudBalance.getComputerList()));
// Remove the problem fact itself
for (Iterator<CloudComputer> it = cloudBalance.getComputerList().iterator(); it.hasNext(); ) {
CloudComputer workingComputer = it.next();
if (ObjectUtils.equals(workingComputer, computer)) {
scoreDirector.beforeProblemFactRemoved(workingComputer);
it.remove(); // remove from list
scoreDirector.afterProblemFactRemoved(workingComputer);
break;
}
}
}
});
}
开发者ID:xmlking,项目名称:ml-experiments,代码行数:31,代码来源:CloudBalancingPanel.java
示例12: split
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
private void split(int partitionCount,String sliceOrChunk) {
File inputFile = new File(importer.getInputDir(), "gifts.csv");
ReindeerRoutingSolution originalSolution = (ReindeerRoutingSolution) importer.readSolution(inputFile);
ScoreDirector scoreDirector = SolverFactory.createFromXmlResource(ReindeerRoutingApp.SOLVER_CONFIG)
.buildSolver().getScoreDirectorFactory().buildScoreDirector();
ReindeerRoutingSolution cloneSolution = (ReindeerRoutingSolution) ((InnerScoreDirector) scoreDirector).cloneSolution(originalSolution);
WeightFactorySelectionSorter<ReindeerRoutingSolution, GiftAssignment> sorter = new WeightFactorySelectionSorter<ReindeerRoutingSolution, GiftAssignment>(
new NorthPoleAngleGiftAssignmentDifficultyWeightFactory(), SelectionSorterOrder.ASCENDING);
sorter.sort(cloneSolution, cloneSolution.getGiftAssignmentList());
int giftSize = cloneSolution.getGiftList().size();
for (int i = 0; i < partitionCount; i++) {
ReindeerRoutingSolution partitionSolution = new ReindeerRoutingSolution();
partitionSolution.setId(cloneSolution.getId());
int giftSubSize = giftSize / partitionCount;
List<GiftAssignment> partitionGiftAssignmentList = cloneSolution.getGiftAssignmentList().subList(giftSubSize * i, giftSubSize * (i + 1));
List<Gift> partitionGiftList = new ArrayList<Gift>(giftSubSize);
for (GiftAssignment partitionGiftAssignment : partitionGiftAssignmentList) {
partitionGiftList.add(partitionGiftAssignment.getGift());
}
partitionSolution.setGiftList(partitionGiftList);
int reindeerSubSize = cloneSolution.getReindeerList().size() / partitionCount;
partitionSolution.setReindeerList(cloneSolution.getReindeerList().subList(reindeerSubSize * i, reindeerSubSize * (i + 1)));
partitionSolution.setGiftAssignmentList(partitionGiftAssignmentList);
File outputFile = new File (importer.getInputDir(), sliceOrChunk + "s/gifts_" + sliceOrChunk + i + ".csv");
writeSolutionButGiftsOnly(partitionSolution, outputFile);
}
}
开发者ID:ge0ffrey,项目名称:santas-stolen-sleigh,代码行数:30,代码来源:ReindeerRoutingSlicerAndChunker.java
示例13: doMove
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
public void doMove(ScoreDirector scoreDirector) {
for (Item item : itemSet) {
scoreDirector.beforeVariableChanged(item, "inside");
item.setInside(!item.getInside().booleanValue());
scoreDirector.afterVariableChanged(item, "inside");
}
}
开发者ID:ge0ffrey,项目名称:coursera-discrete-optimization,代码行数:9,代码来源:MultiItemInverseMove.java
示例14: afterEntityAdded
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
public void afterEntityAdded(ScoreDirector scoreDirector, Migration entity) {
afterVariableChanged(scoreDirector, entity);
// recompute the last step flag
OptimalDistributionStepsSolution solution = (OptimalDistributionStepsSolution)scoreDirector.getWorkingSolution();
solution.establishStepOrdering();
}
开发者ID:oVirt,项目名称:ovirt-optimizer,代码行数:9,代码来源:MigrationStepChangeListener.java
示例15: afterVariableChanged
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
/**
* After any variable change, recompute the cluster situation during
* migration steps.
*/
@Override
public void afterVariableChanged(ScoreDirector scoreDirector, Migration entity) {
logger.trace("Variable changed in {} ({})", entity.toString(), entity.getStepsToFinish());
OptimalDistributionStepsSolution solution = (OptimalDistributionStepsSolution)scoreDirector.getWorkingSolution();
ClusterSituation situation = solution;
boolean stillOK = true;
for (Migration m: solution.getSteps()) {
if (entity == m) {
stillOK = false;
}
if (!stillOK) {
logger.trace("Recomputing shadow variables in {} ({})", m.toString(), m.getStepsToFinish());
scoreDirector.beforeVariableChanged(m, "instanceToHostAssignments");
scoreDirector.beforeVariableChanged(m, "hostToInstanceAssignments");
scoreDirector.beforeVariableChanged(m, "start");
scoreDirector.beforeVariableChanged(m, "valid");
m.recomputeSituationAfter(situation);
scoreDirector.afterVariableChanged(m, "instanceToHostAssignments");
scoreDirector.afterVariableChanged(m, "hostToInstanceAssignments");
scoreDirector.afterVariableChanged(m, "start");
scoreDirector.afterVariableChanged(m, "valid");
}
situation = m;
}
}
开发者ID:oVirt,项目名称:ovirt-optimizer,代码行数:37,代码来源:MigrationStepChangeListener.java
示例16: changeWorkingSolution
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
public void changeWorkingSolution(ScoreDirector scoreDirector) {
/* empty phase, just calculate score */
Score score = scoreDirector.calculateScore();
scoreDirector.getWorkingSolution().setScore(score);
logger.debug(scoreDirector.getWorkingSolution().getScore().toString());
}
开发者ID:oVirt,项目名称:ovirt-optimizer,代码行数:8,代码来源:ScoreOnlyPhase.java
示例17: updateVehicle
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
protected void updateVehicle(ScoreDirector scoreDirector, TimeWindowedCustomer sourceCustomer) {
Standstill previousStandstill = sourceCustomer.getPreviousStandstill();
Integer departureTime = (previousStandstill instanceof TimeWindowedCustomer)
? ((TimeWindowedCustomer) previousStandstill).getDepartureTime() : null;
TimeWindowedCustomer shadowCustomer = sourceCustomer;
Integer arrivalTime = calculateArrivalTime(shadowCustomer, departureTime);
while (shadowCustomer != null && ObjectUtils.notEqual(shadowCustomer.getArrivalTime(), arrivalTime)) {
scoreDirector.beforeVariableChanged(shadowCustomer, "arrivalTime");
shadowCustomer.setArrivalTime(arrivalTime);
scoreDirector.afterVariableChanged(shadowCustomer, "arrivalTime");
departureTime = shadowCustomer.getDepartureTime();
shadowCustomer = shadowCustomer.getNextCustomer();
arrivalTime = calculateArrivalTime(shadowCustomer, departureTime);
}
}
开发者ID:tomasdavidorg,项目名称:android-vehicle-routing-problem,代码行数:16,代码来源:ArrivalTimeUpdatingVariableListener.java
示例18: accept
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
public boolean accept(ScoreDirector scoreDirector, Visit selection) {
final Vehicle v = selection.getVehicle();
if (v != null
&& v.equals(selection)
&& v.getDestination().isPresent()) {
return false;
}
return true;
}
开发者ID:rinde,项目名称:RinLog,代码行数:11,代码来源:EntityFilter.java
示例19: apply
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
static void apply(List<Visit> state, ScoreDirector scoreDirector) {
for (int i = state.size() - 1; i > 0; i--) {
final ParcelVisit subject = (ParcelVisit) state.get(i);
scoreDirector.beforeVariableChanged(subject, PREV_VISIT);
final Visit target = state.get(i - 1);
if (target == NullVisit.INSTANCE) {
subject.setPreviousVisit(null);
} else {
subject.setPreviousVisit(target);
}
scoreDirector.afterVariableChanged(subject, PREV_VISIT);
}
}
开发者ID:rinde,项目名称:RinLog,代码行数:15,代码来源:MovePair.java
示例20: getSize
import org.optaplanner.core.impl.score.director.ScoreDirector; //导入依赖的package包/类
@Override
public long getSize(ScoreDirector scoreDirector) {
final PDPSolution sol = (PDPSolution) scoreDirector.getWorkingSolution();
if (sol.vehicleList.size() <= 1) {
return 0;
}
return sol.parcelList.size() + sol.vehicleList.size();
}
开发者ID:rinde,项目名称:RinLog,代码行数:9,代码来源:SwapMoveIteratorFactory.java
注:本文中的org.optaplanner.core.impl.score.director.ScoreDirector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论