| 589 | } |
| 590 | |
| 591 | void MaxConstraint::getCostFunctionComponent( LinearExpression &cost, PhaseStatus phase ) const |
| 592 | { |
| 593 | // If the constraint is not active or is fixed, it contributes nothing |
| 594 | if ( !isActive() || phaseFixed() ) |
| 595 | return; |
| 596 | |
| 597 | if ( phase == MAX_PHASE_ELIMINATED ) |
| 598 | { |
| 599 | // The cost term corresponding to this phase is f - maxValueOfEliminated. |
| 600 | if ( !cost._addends.exists( _f ) ) |
| 601 | cost._addends[_f] = 0; |
| 602 | cost._addends[_f] = cost._addends[_f] + 1; |
| 603 | cost._constant -= _maxValueOfEliminatedPhases; |
| 604 | } |
| 605 | else |
| 606 | { |
| 607 | unsigned element = phaseToVariable( phase ); |
| 608 | unsigned aux = _elementToAux[element]; |
| 609 | if ( !cost._addends.exists( aux ) ) |
| 610 | cost._addends[aux] = 0; |
| 611 | cost._addends[aux] += 1; |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | PhaseStatus |
| 616 | MaxConstraint::getPhaseStatusInAssignment( const Map<unsigned, double> &assignment ) const |