From 76729f9670ba63a9146079b081bdb5b5ae0bbd3d Mon Sep 17 00:00:00 2001 From: Kenny Ballou Date: Fri, 28 Feb 2020 15:36:09 -0700 Subject: CASA fork: initial commit Snapshot from http://cse.unl.edu/~citportal/. --- casa/covering/state/CoveringArray.H | 166 ++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 casa/covering/state/CoveringArray.H (limited to 'casa/covering/state/CoveringArray.H') diff --git a/casa/covering/state/CoveringArray.H b/casa/covering/state/CoveringArray.H new file mode 100644 index 0000000..6241230 --- /dev/null +++ b/casa/covering/state/CoveringArray.H @@ -0,0 +1,166 @@ +// Copyright 2008, 2009 Brady J. Garvin + +// This file is part of Covering Arrays by Simulated Annealing (CASA). + +// CASA is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// CASA is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with CASA. If not, see . + + +#ifndef COVERING_ARRAY_H +#define COVERING_ARRAY_H + +#include +#include +#include +#include + +#include "Lazy.H" +#include "Array.H" + +#include "covering/bookkeeping/Coverage.H" + +#include "sat/SAT.H" + + +class CoveringArray { +protected: + // The first index is the test configuration (row). + // The second index is the option (column). + Array > array; + Lazy, unsigned> > + substitutions; + + SATSolver* solver; + + bool trackingCoverage; + bool trackingNoncoverage; + + unsigned coverageCount; + unsigned multipleCoverageCount; + Coverage coverage; + Lazy, ArrayComparator > > + noncoverage; + +public: + CoveringArray + (unsigned rows, unsigned strength, Options options, SATSolver&solver); + CoveringArray(const CoveringArray©); + + unsigned getRows() const { + return array.getSize(); + } + unsigned getOptions() const { + return array.getSize() ? array[0].getSize() : 0; + } + + void setBackingArrayEntry(unsigned row, unsigned option, unsigned value); + void setBackingArrayRow(unsigned row, Arrayvalue); + + class Entry { + protected: + CoveringArray& owner; + unsigned row; + unsigned option; + public: + Entry(CoveringArray&owner, unsigned row, unsigned option) : + owner(owner), + row(row), + option(option) {} + protected: + void updateTracking(unsigned value); + public: + operator unsigned() const; + Entry&operator =(unsigned value); + }; + + // Warning: CoveringArray::Row assumes that constraints are always satisfied. + class Row { + protected: + CoveringArray& owner; + unsigned row; + public: + Row(CoveringArray&owner, unsigned row) : + owner(owner), + row(row) {} + protected: + void updateTracking(const Arrayvalues); + public: + operator Array() const; + Row&operator =(const Arrayvalues); + }; + + // Warning: CoveringArray::SubRow assumes that constraints are always + // satisfied. + class SubRow { + protected: + CoveringArray& owner; + unsigned row; + Array columns; + public: + SubRow(CoveringArray&owner, unsigned row, Arraycolumns) : + owner(owner), + row(row), + columns(columns) {} + protected: + void updateTracking(const Arrayvalues); + public: + operator Array() const; + SubRow&operator =(const Arrayvalues); + }; + + Entry operator ()(unsigned row, unsigned option) { + return Entry(*this, row, option); + } + const Entry operator ()(unsigned row, unsigned option) const { + return Entry(*const_cast(this), row, option); + } + + Row operator ()(unsigned row) { + return Row(*this, row); + } + const Row operator ()(unsigned row) const { + return Row(*const_cast(this), row); + } + + SubRow operator ()(unsigned row, Arraycolumns) { + return SubRow(*this, row, columns); + } + const SubRow operator ()(unsigned row, Arraycolumns) const { + return SubRow(*const_cast(this), row, columns); + } + + unsigned getCoverageCount() const; + unsigned getMultipleCoverageCount() const; + ArraycountDistinctCoverage() const; + + bool operator <(const CoveringArray&other) const; + bool operator >(const CoveringArray&other) const; + bool operator ==(const CoveringArray&other) const; + bool operator !=(const CoveringArray&other) const; + + void finalizeSubstitutions(); + void autoFinalizeSubstitutions(); + + bool isTrackingCoverage() const; + void setTrackingCoverage(bool trackingCoverage); + + bool isTrackingNoncoverage() const; + void setTrackingNoncoverage(bool trackingNoncoverage); + + const std::set, ArrayComparator >&getNoncoverage() + const; +}; + +std::ostream&operator <<(std::ostream&out,const CoveringArray&array); + +#endif -- cgit v1.2.1