Ich versuche, das Projekt-Job-Zeitplanungsbeispiel in der 7.4.1.Final-Distribution wiederzuverwenden. Ich änderte projectJobSchedulingSolverConfig.xml
DateiBeispiel für einen Job-Ablaufplan von optaplanner-Projekt - kann nicht erfolgreich kompiliert werden, wenn ich in drl-Datei umschalte
<scoreDrl>org/optaplanner/examples/projectjobscheduling/solver/projectJobSchedulingScoreRules.drl</scoreDrl>
statt <incrementalScoreCalculatorClass>org.optaplanner.examples.projectjobscheduling.solver.score.ProjectJobSchedulingIncrementalScoreCalculator</incrementalScoreCalculatorClass>
zu verwenden.
Um deutlicher:
ich diesen Teil nur von projectJobSchedulingSolverConfig.xml
Datei ändern:
<scoreDirectorFactory>
<!--<incrementalScoreCalculatorClass>org.optaplanner.examples.projectjobscheduling.solver.score.ProjectJobSchedulingIncrementalScoreCalculator</incrementalScoreCalculatorClass>-->
<scoreDrl>org/optaplanner/examples/projectjobscheduling/solver/projectJobSchedulingScoreRules.drl</scoreDrl>
</scoreDirectorFactory>
Aber dann Kompilierungsfehler ich gestoßen:
Exception in thread "main" java.lang.IllegalStateException: There are errors in a score DRL:
Error Messages:
Message [id=1, kieBase=defaultKieBase, level=ERROR, path=org/optaplanner/examples/projectjobscheduling/solver/projectJobSchedulingScoreRules.drl, line=95, column=0
text=Rule Compilation error The operator - is undefined for the argument type(s) Comparable]
---
Warning Messages:
---
Info Messages:
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildDroolsScoreDirectorFactory(ScoreDirectorFactoryConfig.java:507)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:331)
at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:220)
at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:61)
at org.optaplanner.examples.common.app.CommonApp.createSolver(CommonApp.java:103)
at org.optaplanner.examples.common.app.CommonApp.createSolutionBusiness(CommonApp.java:97)
at org.optaplanner.examples.common.app.CommonApp.init(CommonApp.java:84)
at org.optaplanner.examples.common.app.CommonApp.init(CommonApp.java:80)
at org.optaplanner.examples.projectjobscheduling.app.ProjectJobSchedulingApp.main(ProjectJobSchedulingApp.java:34)
ich nicht die projectJobSchedulingScoreRules.drl
Datei ändern haben, aber hier ist der Dateiinhalt:
/*
* Copyright 2010 Red Hat, Inc. and/or its affiliates.
*
* 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.optaplanner.examples.projectjobscheduling.solver;
dialect "java"
import org.optaplanner.core.api.score.buildin.bendable.BendableScoreHolder;
import org.optaplanner.examples.projectjobscheduling.domain.Allocation;
import org.optaplanner.examples.projectjobscheduling.domain.ExecutionMode;
import org.optaplanner.examples.projectjobscheduling.domain.Job;
import org.optaplanner.examples.projectjobscheduling.domain.JobType;
import org.optaplanner.examples.projectjobscheduling.domain.Project;
import org.optaplanner.examples.projectjobscheduling.domain.ResourceRequirement;
import org.optaplanner.examples.projectjobscheduling.domain.resource.Resource;
import org.optaplanner.examples.projectjobscheduling.solver.score.capacity.NonrenewableResourceCapacityTracker;
import org.optaplanner.examples.projectjobscheduling.solver.score.capacity.RenewableResourceCapacityTracker;
import org.optaplanner.examples.projectjobscheduling.solver.score.capacity.ResourceCapacityTracker;
import org.optaplanner.examples.projectjobscheduling.solver.score.drools.RenewableResourceUsedDay;
global BendableScoreHolder scoreHolder;
// ############################################################################
// Hard constraints
// ############################################################################
rule "nonrenewableResourceCapacity"
when
$resource : Resource(renewable == false, $capacity : capacity)
accumulate(
ResourceRequirement(resource == $resource,
$executionMode : executionMode,
$requirement : requirement)
and Allocation(executionMode == $executionMode);
$used : sum($requirement);
$used > $capacity
)
then
scoreHolder.addHardConstraintMatch(kcontext, 0, $capacity - $used);
end
rule "renewableResourceUsedDay"
salience 1 // Do these rules first (optional, for performance)
when
ResourceRequirement(resourceRenewable == true, $executionMode : executionMode, $resource : resource)
Allocation(executionMode == $executionMode,
$startDate : startDate, $endDate : endDate)
then
for (int i = $startDate; i < $endDate; i++) {
insertLogical(new RenewableResourceUsedDay($resource, i));
}
end
rule "renewableResourceCapacity"
when
RenewableResourceUsedDay($resource : resource, $capacity : resourceCapacity, $usedDay : usedDay)
accumulate(
ResourceRequirement(resource == $resource,
$executionMode : executionMode,
$requirement : requirement)
and Allocation(executionMode == $executionMode, $usedDay >= startDate, $usedDay < endDate);
$used : sum($requirement);
$used > $capacity
)
then
scoreHolder.addHardConstraintMatch(kcontext, 0, $capacity - $used);
end
// ############################################################################
// Soft constraints
// ############################################################################
rule "totalProjectDelay"
when
Allocation(jobType == JobType.SINK, endDate != null, $endDate : endDate,
$criticalPathEndDate : projectCriticalPathEndDate)
then
scoreHolder.addSoftConstraintMatch(kcontext, 0, $criticalPathEndDate - $endDate);
end
rule "totalMakespan"
when
accumulate(
Allocation(jobType == JobType.SINK, $endDate : endDate);
$maxProjectEndDate : max($endDate)
)
then
scoreHolder.addSoftConstraintMatch(kcontext, 1, -$maxProjectEndDate);
end
Hat jemand ähnliches Problem festgestellt? Irgendein Hinweis, wie man es repariert? Danke im Voraus.
Ich habe versucht, die Schritte, die Sie zur Verfügung stellen, um das Problem zu reproduzieren, aber ich stoße auf keine Probleme. Von der geworfenen Ausnahme heißt es, dass Sie ein Problem in der Drools-Datei (projectJobSchedulingScoreRules.drl) Zeile 95 haben. Ändern Sie etwas in dieser Drools-Datei? Es ist besser, wenn Sie hier Ihre Drools-Datei posten, damit ich Ihnen besser helfen kann. –
@ the.wizard danke für deine antwort. Ich habe meinen Post aktualisiert, indem ich die Drools-Datei hinzugefügt habe. –
Die Fehlermeldung sagt 'projectJobSchedulingScoreRules.drl, Zeile = 95' –