| 1722 | } |
| 1723 | |
| 1724 | void Engine::extractSolution( InputQuery &inputQuery, Preprocessor *preprocessor ) |
| 1725 | { |
| 1726 | Preprocessor *preprocessorInUse = nullptr; |
| 1727 | if ( preprocessor != nullptr ) |
| 1728 | preprocessorInUse = preprocessor; |
| 1729 | else if ( _preprocessingEnabled ) |
| 1730 | preprocessorInUse = &_preprocessor; |
| 1731 | |
| 1732 | for ( unsigned i = 0; i < inputQuery.getNumberOfVariables(); ++i ) |
| 1733 | { |
| 1734 | if ( preprocessorInUse ) |
| 1735 | { |
| 1736 | // Symbolically fixed variables are skipped. They will be re-constructed in the end. |
| 1737 | if ( preprocessorInUse->variableIsUnusedAndSymbolicallyFixed( i ) ) |
| 1738 | continue; |
| 1739 | |
| 1740 | // Has the variable been merged into another? |
| 1741 | unsigned variable = i; |
| 1742 | while ( preprocessorInUse->variableIsMerged( variable ) ) |
| 1743 | variable = preprocessorInUse->getMergedIndex( variable ); |
| 1744 | |
| 1745 | // Fixed variables are easy: return the value they've been fixed to. |
| 1746 | if ( preprocessorInUse->variableIsFixed( variable ) ) |
| 1747 | { |
| 1748 | inputQuery.setSolutionValue( i, preprocessorInUse->getFixedValue( variable ) ); |
| 1749 | continue; |
| 1750 | } |
| 1751 | |
| 1752 | // We know which variable to look for, but it may have been assigned |
| 1753 | // a new index, due to variable elimination |
| 1754 | variable = preprocessorInUse->getNewIndex( variable ); |
| 1755 | |
| 1756 | // Finally, set the assigned value |
| 1757 | inputQuery.setSolutionValue( i, _tableau->getValue( variable ) ); |
| 1758 | } |
| 1759 | else |
| 1760 | { |
| 1761 | inputQuery.setSolutionValue( i, _tableau->getValue( i ) ); |
| 1762 | } |
| 1763 | } |
| 1764 | |
| 1765 | if ( preprocessorInUse ) |
| 1766 | { |
| 1767 | /* |
| 1768 | Recover the assignment of eliminated neurons (e.g., due to merging of WS layers) |
| 1769 | */ |
| 1770 | preprocessorInUse->setSolutionValuesOfEliminatedNeurons( inputQuery ); |
| 1771 | } |
| 1772 | } |
| 1773 | |
| 1774 | bool Engine::allVarsWithinBounds() const |
| 1775 | { |