Class ComponentCache

Class Documentation

class ComponentCache

component_cache.h

Purpose: Defines the ComponentCache() class for storing components in the cache.

Copyright (C) 2018 Zayd Hammoudeh. All rights reserved.

Author
Zayd Hammoudeh zayd@ucsc.edu
Version
0.00.00

This software may be modified and distributed under the terms of the MIT license. See the LICENSE file for details.

Original Author: Marc Thurley. Data structure that is used as the component cache for the number of solutions for different components.

Public Functions

ComponentCache(DataAndStatistics &statistics, SolverConfiguration &config)

component_cache.cpp

Purpose: Defines methods for the ComponentCache() class for storing components in the cache.

Copyright (C) 2018 Zayd Hammoudeh. All rights reserved.

Author
Zayd Hammoudeh zayd@ucsc.edu
Version
0.00.00

This software may be modified and distributed under the terms of the MIT license. See the LICENSE file for details.

Original Author: Marc Thurley.

~ComponentCache()
void init(Component &super_comp, bool quiet = false)
uint64_t compute_byte_size_infrastructure()

Rebuild the size of the cache infrastructure (in bytes) from scratch by computing the size of the individual component including:

  • Size of the cache entry ID table (based on its capacity
  • Size of the cacheable component area.
  • Size of the cache entry slots used to store the list of free entries.

It also updates the statistics for the formula including the cache infrastructure bytes usage,

This is called when the cache entries are deleted.

Return
Size of the cache infrastructure.

const CacheableComponent &entry_const(const CacheEntryID id) const

Access a reference to an entry in the component cache. If the specified entry ID does not exist, the program will crash. This is the constant version of the function and is safe to use in assert statements.

Return
Reference to the specified cache entry ID.
Parameters
  • id: Cache entry identification number

CacheableComponent &entry(const CacheEntryID id)

Access a reference to an entry in the component cache. If the specified entry ID does not exist, the program will crash.

Return
Reference to the specified cache entry ID.
Parameters
  • id: Cache entry identification number

bool hasEntry(CacheEntryID id) const

Uses a cached component’s CacheEntryID to extract the components cached information.

Return
Cache entry for the specified component. Determines whether the
Return
Parameters
  • comp: Component to be extracted from the cache.
Parameters

void removeFromHashTable(CacheEntryID id)

Removes the entry ID from the hash table but not from the entry base.

Parameters
  • id: Identification number of the cache entry.

void cleanPollutionsInvolving(CacheEntryID id)
CacheEntryID storeAsEntry(CacheableComponent &ccomp, CacheEntryID super_comp_id)
bool manageNewComponent(StackLevel &top, CacheableComponent &packed_comp, Component *unpacked_comp, CachedAssignment &cached_assn, CacheEntryID &cache_entry_id)

New Component Cache Checker

MT - Check quickly if the model count of the component is cached. If so, incorporate it into the model count of top If not, store the packed version of it in the entry_base of the cache

Return
True if the new component is in cache.
Parameters
  • top: Top of the literal decision stack.
  • packed_comp: New component to check whether it is in cache.
  • cached_assn: Cached assignment to be modified

void eraseEntry(CacheEntryID id)
void storeValueOf(CacheEntryID id, const mpz_class &model_count)

Stores the model count of the specified CacheEntryId item in the cache.

If may invoke a cache resize if the new entry cannot fit in the cache.

Parameters
  • id: ID number of the cache entry.
  • model_count: Number of models for the specified ID.

bool deleteEntries()

Purges old entries from the cache to get the cache size to roughly half of its current size.

It then rehashes the table and updates the cache size information.

Return
Always true.

void removeFromDescendantsTree(CacheEntryID id)
void test_descendantstree_consistency()
void debug_dump_data()