|
@@ 322-362 (lines=41) @@
|
| 319 |
|
} |
| 320 |
|
|
| 321 |
|
|
| 322 |
|
try |
| 323 |
|
{ |
| 324 |
|
/* |
| 325 |
|
* check feasibility of precedence constraint "target < reference" and compute the resulting preserved heuristic value |
| 326 |
|
*/ |
| 327 |
|
|
| 328 |
|
// set reference interval |
| 329 |
|
before.setReference(target.getToken().getInterval()); |
| 330 |
|
// set target interval |
| 331 |
|
before.setTarget(reference.getToken().getInterval()); |
| 332 |
|
// set bounds |
| 333 |
|
before.setLowerBound(0); |
| 334 |
|
before.setUpperBound(this.tdb.getHorizon()); |
| 335 |
|
|
| 336 |
|
// verify constraint feasibility through constraint propagation |
| 337 |
|
this.tdb.propagate(before); |
| 338 |
|
// check temporal consistency |
| 339 |
|
this.tdb.verify(); |
| 340 |
|
|
| 341 |
|
|
| 342 |
|
// compute the preserved space heuristic value resulting after constraint propagation |
| 343 |
|
double preserved = this.computePreservedSpaceHeuristicValue( |
| 344 |
|
target.getToken().getInterval().getEndTime(), |
| 345 |
|
reference.getToken().getInterval().getStartTime()); |
| 346 |
|
|
| 347 |
|
// create and add solution to the MCS |
| 348 |
|
PrecedenceConstraint pc = mcs.addSolution(target, reference, preserved); |
| 349 |
|
// print some debugging information |
| 350 |
|
debug("Feasible solution of MCS found:\n" |
| 351 |
|
+ "- mcs: " + mcs + "\n" |
| 352 |
|
+ "- precedence constraint: " + pc + "\n"); |
| 353 |
|
} |
| 354 |
|
catch (TemporalConstraintPropagationException | ConsistencyCheckException ex) { |
| 355 |
|
// warning message |
| 356 |
|
debug("Unfeasible solution found for MCS:\n- mcs: " + mcs + "\n- unfeasible precedence constraint: " + target + " < " + reference + "\n"); |
| 357 |
|
} |
| 358 |
|
finally { |
| 359 |
|
// retract (inverted) precedence constraint |
| 360 |
|
this.tdb.retract(before); |
| 361 |
|
// clear temporal relation |
| 362 |
|
before.clear(); |
| 363 |
|
} |
| 364 |
|
} |
| 365 |
|
} |
|
@@ 278-318 (lines=41) @@
|
| 275 |
|
// prepare precedence constraint |
| 276 |
|
BeforeIntervalConstraint before = this.tdb.createTemporalConstraint(TemporalConstraintType.BEFORE); |
| 277 |
|
|
| 278 |
|
try |
| 279 |
|
{ |
| 280 |
|
/* |
| 281 |
|
* check feasibility of precedence constraint "reference < target" and compute the resulting preserved heuristic value |
| 282 |
|
*/ |
| 283 |
|
|
| 284 |
|
// set reference interval |
| 285 |
|
before.setReference(reference.getToken().getInterval()); |
| 286 |
|
// set target interval |
| 287 |
|
before.setTarget(target.getToken().getInterval()); |
| 288 |
|
// set bounds |
| 289 |
|
before.setLowerBound(0); |
| 290 |
|
before.setUpperBound(this.tdb.getHorizon()); |
| 291 |
|
|
| 292 |
|
// verify constraint feasibility through constraint propagation |
| 293 |
|
this.tdb.propagate(before); |
| 294 |
|
// check temporal consistency |
| 295 |
|
this.tdb.verify(); |
| 296 |
|
|
| 297 |
|
|
| 298 |
|
// compute the preserved space heuristic value resulting after constraint propagation |
| 299 |
|
double preserved = this.computePreservedSpaceHeuristicValue( |
| 300 |
|
reference.getToken().getInterval().getEndTime(), |
| 301 |
|
target.getToken().getInterval().getStartTime()); |
| 302 |
|
|
| 303 |
|
// create and add solution to the MCS |
| 304 |
|
PrecedenceConstraint pc = mcs.addSolution(reference, target, preserved); |
| 305 |
|
// print some debugging information |
| 306 |
|
debug("Feasible solution of MCS found:\n" |
| 307 |
|
+ "- mcs: " + mcs + "\n" |
| 308 |
|
+ "- precedence constraint: " + pc + "\n"); |
| 309 |
|
} |
| 310 |
|
catch (TemporalConstraintPropagationException | ConsistencyCheckException ex) { |
| 311 |
|
// warning message |
| 312 |
|
debug("Unfeasible solution found for MCS:\n- mcs: " + mcs + "\n- unfeasible precedence constraint: " + reference + " < " + target + "\n"); |
| 313 |
|
} |
| 314 |
|
finally { |
| 315 |
|
// retract propagated constraint |
| 316 |
|
this.tdb.retract(before); |
| 317 |
|
// clear temporal relation |
| 318 |
|
before.clear(); |
| 319 |
|
} |
| 320 |
|
|
| 321 |
|
|