LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/arith/linear - dual_simplex.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 6 100.0 %
Date: 2026-02-23 11:51:46 Functions: 2 2 100.0 %
Branches: 0 0 -

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

Generated by: LCOV version 1.14