| 2599 | } |
| 2600 | |
| 2601 | void Engine::warmStart() |
| 2602 | { |
| 2603 | // An NLR is required for a warm start |
| 2604 | if ( !_networkLevelReasoner ) |
| 2605 | return; |
| 2606 | |
| 2607 | // First, choose an arbitrary assignment for the input variables |
| 2608 | unsigned numInputVariables = _preprocessedQuery->getNumInputVariables(); |
| 2609 | unsigned numOutputVariables = _preprocessedQuery->getNumOutputVariables(); |
| 2610 | |
| 2611 | if ( numInputVariables == 0 ) |
| 2612 | { |
| 2613 | // Trivial case: all inputs are fixed, nothing to evaluate |
| 2614 | return; |
| 2615 | } |
| 2616 | |
| 2617 | double *inputAssignment = new double[numInputVariables]; |
| 2618 | double *outputAssignment = new double[numOutputVariables]; |
| 2619 | |
| 2620 | for ( unsigned i = 0; i < numInputVariables; ++i ) |
| 2621 | { |
| 2622 | unsigned variable = _preprocessedQuery->inputVariableByIndex( i ); |
| 2623 | inputAssignment[i] = _tableau->getLowerBound( variable ); |
| 2624 | } |
| 2625 | |
| 2626 | // Evaluate the network for this assignment |
| 2627 | _networkLevelReasoner->evaluate( inputAssignment, outputAssignment ); |
| 2628 | |
| 2629 | // Try to update as many variables as possible to match their assignment |
| 2630 | for ( unsigned i = 0; i < _networkLevelReasoner->getNumberOfLayers(); ++i ) |
| 2631 | { |
| 2632 | const NLR::Layer *layer = _networkLevelReasoner->getLayer( i ); |
| 2633 | unsigned layerSize = layer->getSize(); |
| 2634 | const double *assignment = layer->getAssignment(); |
| 2635 | |
| 2636 | for ( unsigned j = 0; j < layerSize; ++j ) |
| 2637 | { |
| 2638 | if ( layer->neuronHasVariable( j ) ) |
| 2639 | { |
| 2640 | unsigned variable = layer->neuronToVariable( j ); |
| 2641 | if ( !_tableau->isBasic( variable ) ) |
| 2642 | _tableau->setNonBasicAssignment( variable, assignment[j], false ); |
| 2643 | } |
| 2644 | } |
| 2645 | } |
| 2646 | |
| 2647 | // We did what we could for the non-basics; now let the tableau compute |
| 2648 | // the basic assignment |
| 2649 | _tableau->computeAssignment(); |
| 2650 | |
| 2651 | delete[] outputAssignment; |
| 2652 | delete[] inputAssignment; |
| 2653 | } |
| 2654 | |
| 2655 | void Engine::checkOverallProgress() |
| 2656 | { |
nothing calls this directly
no test coverage detected