Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * This is an implementation of the Simplex Module for the Simplex for 11 : : * DPLL(T) decision procedure. 12 : : * 13 : : * This implements the Simplex module for the Simpelx for DPLL(T) decision 14 : : * procedure. 15 : : * See the Simplex for DPLL(T) technical report for more background.(citation?) 16 : : * This shares with the theory a Tableau, and a PartialModel that: 17 : : * - satisfies the equalities in the Tableau, and 18 : : * - the assignment for the non-basic variables satisfies their bounds. 19 : : * This is required to either produce a conflict or satisifying PartialModel. 20 : : * Further, we require being told when a basic variable updates its value. 21 : : * 22 : : * During the Simplex search we maintain a queue of variables. 23 : : * The queue is required to contain all of the basic variables that voilate 24 : : * their bounds. 25 : : * As elimination from the queue is more efficient to be done lazily, 26 : : * we do not maintain that the queue of variables needs to be only basic 27 : : * variables or only variables that satisfy their bounds. 28 : : * 29 : : * The simplex procedure roughly follows Alberto's thesis. (citation?) 30 : : * There is one round of selecting using a heuristic pivoting rule. 31 : : * (See PreferenceFunction Documentation for the available options.) 32 : : * The non-basic variable is the one that appears in the fewest pivots. 33 : : * (Bruno says that Leonardo invented this first.) 34 : : * After this, Bland's pivot rule is invoked. 35 : : * 36 : : * During this process, we periodically inspect the queue of variables to 37 : : * 1) remove now extraneous extries, 38 : : * 2) detect conflicts that are "waiting" on the queue but may not be detected 39 : : * by the current queue heuristics, and 40 : : * 3) detect multiple conflicts. 41 : : * 42 : : * Conflicts are greedily slackened to use the weakest bounds that still 43 : : * produce the conflict. 44 : : * 45 : : * Extra things tracked atm: (Subject to change at Tim's whims) 46 : : * - A superset of all of the newly pivoted variables. 47 : : * - A queue of additional conflicts that were discovered by Simplex. 48 : : * These are theory valid and are currently turned into lemmas 49 : : */ 50 : : 51 : : #include "cvc5_private.h" 52 : : 53 : : #pragma once 54 : : 55 : : #include "theory/arith/linear/simplex.h" 56 : : #include "util/statistics_stats.h" 57 : : 58 : : namespace cvc5::internal { 59 : : namespace theory { 60 : : namespace arith::linear { 61 : : 62 : : class DualSimplexDecisionProcedure : public SimplexDecisionProcedure{ 63 : : public: 64 : : DualSimplexDecisionProcedure(Env& env, 65 : : LinearEqualityModule& linEq, 66 : : ErrorSet& errors, 67 : : RaiseConflict conflictChannel, 68 : : TempVarMalloc tvmalloc); 69 : : 70 : 3261058 : Result::Status findModel(bool exactResult) override 71 : : { 72 : 3261058 : return dualFindModel(exactResult); 73 : : } 74 : : 75 : : private: 76 : : 77 : : /** 78 : : * Maps a variable to how many times they have been used as a pivot in the 79 : : * simplex search. 80 : : */ 81 : : DenseMultiset d_pivotsInRound; 82 : : 83 : : Result::Status dualFindModel(bool exactResult); 84 : : 85 : : /** 86 : : * This is the main simplex for DPLL(T) loop. 87 : : * It runs for at most maxIterations. 88 : : * 89 : : * Returns true iff it has found a conflict. 90 : : * d_conflictVariable will be set and the conflict for this row is reported. 91 : : */ 92 : : bool searchForFeasibleSolution(uint32_t maxIterations); 93 : : 94 : : 95 : 1810314 : bool processSignals(){ 96 : 1810314 : TimerStat &timer = d_statistics.d_processSignalsTime; 97 : 1810314 : IntStat& conflictStat = d_statistics.d_recentViolationCatches; 98 : 1810314 : return standardProcessSignals(timer, conflictStat); 99 : : } 100 : : /** These fields are designed to be accessible to TheoryArith methods. */ 101 : : class Statistics { 102 : : public: 103 : : IntStat d_statUpdateConflicts; 104 : : TimerStat d_processSignalsTime; 105 : : IntStat d_simplexConflicts; 106 : : IntStat d_recentViolationCatches; 107 : : TimerStat d_searchTime; 108 : : 109 : : ReferenceStat<uint32_t> d_finalCheckPivotCounter; 110 : : 111 : : Statistics(StatisticsRegistry& sr, uint32_t& pivots); 112 : : } d_statistics; 113 : : };/* class DualSimplexDecisionProcedure */ 114 : : 115 : : } // namespace arith 116 : : } // namespace theory 117 : : } // namespace cvc5::internal