| 729 | } |
| 730 | |
| 731 | void MILPEncoder::encodeRoundConstraint( GurobiWrapper &gurobi, RoundConstraint *round, bool relax ) |
| 732 | { |
| 733 | /* |
| 734 | We have already introduced during preprocessing |
| 735 | f - b <= 0.5 |
| 736 | b - f <= 0.5 |
| 737 | |
| 738 | Therefore, nothing needs to be done if we are encoding the relaxation. |
| 739 | Otherwise, we introduce a new integer variable i and assert that f is |
| 740 | equal to i. |
| 741 | */ |
| 742 | if ( !relax ) |
| 743 | { |
| 744 | unsigned targetVariable = round->getF(); |
| 745 | String varName = Stringf( "i%u", _intVarIndex ); |
| 746 | gurobi.addVariable( varName, |
| 747 | _tableau.getLowerBound( targetVariable ), |
| 748 | _tableau.getUpperBound( targetVariable ), |
| 749 | GurobiWrapper::INTEGER ); |
| 750 | List<GurobiWrapper::Term> terms; |
| 751 | terms.append( GurobiWrapper::Term( 1, Stringf( "x%u", targetVariable ) ) ); |
| 752 | terms.append( GurobiWrapper::Term( -1, Stringf( "i%u", _intVarIndex ) ) ); |
| 753 | gurobi.addEqConstraint( terms, 0 ); |
| 754 | ++_intVarIndex; |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | void MILPEncoder::encodeCostFunction( GurobiWrapper &gurobi, const LinearExpression &cost ) |
| 759 | { |
nothing calls this directly
no test coverage detected