public abstract class MemoryVariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable> extends Object implements VariableTermStore<T,V>
Constructor and Description |
---|
MemoryVariableTermStore() |
Modifier and Type | Method and Description |
---|---|
void |
add(GroundRule rule,
T term)
Add a term to the store that was generated from the given ground rule.
|
void |
clear()
Remove any existing terms and prepare for a new set.
|
void |
close()
Close down the term store, it will not be used any more.
|
protected abstract V |
convertAtomToVariable(RandomVariableAtom atom) |
V |
createLocalVariable(RandomVariableAtom atom)
Create a variable local to a specific term.
|
void |
ensureCapacity(int capacity)
Ensure that the underlying stuctures can have the required term capacity.
|
void |
ensureVariableCapacity(int capacity)
Make sure we allocate the right amount of memory for global variables.
|
T |
get(int index) |
int |
getNumVariables() |
int |
getVariableIndex(V variable)
Get the index that matches up to getVariableValues().
|
Iterable<V> |
getVariables() |
float |
getVariableValue(int index)
Get the variable for the given index.
|
float[] |
getVariableValues()
Get the truth values for variabe atoms.
|
void |
initForOptimization()
A notification by the Reasoner that optimization is about to begin.
|
boolean |
isLoaded()
Is the term store loaded, and can it give an accurate term and variable count.
|
void |
iterationComplete()
A notification by the Reasoner that a single iteration is complete.
|
Iterator<T> |
iterator() |
Iterator<T> |
noWriteIterator()
Get an iterator over the terms in the store that does not write to disk.
|
void |
reset()
Reset the existing terms for another round of inference.
|
int |
size() |
void |
syncAtoms()
Ensure that all the variable atoms have the same value as the array returned by getVariableValues().
|
void |
updateVariableValue(int index,
float gradient,
float gradientStep)
Update the variable value at the given index.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public int getVariableIndex(V variable)
VariableTermStore
getVariableIndex
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public float getVariableValue(int index)
VariableTermStore
getVariableValue
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void updateVariableValue(int index, float gradient, float gradientStep)
VariableTermStore
updateVariableValue
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public float[] getVariableValues()
VariableTermStore
getVariableValues
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void syncAtoms()
VariableTermStore
syncAtoms
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public int getNumVariables()
getNumVariables
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public boolean isLoaded()
VariableTermStore
isLoaded
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public V createLocalVariable(RandomVariableAtom atom)
TermStore
createLocalVariable
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void ensureVariableCapacity(int capacity)
ensureVariableCapacity
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public Iterable<V> getVariables()
getVariables
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void add(GroundRule rule, T term)
TermStore
add
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void clear()
TermStore
clear
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void reset()
TermStore
reset
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void close()
TermStore
close
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void initForOptimization()
TermStore
initForOptimization
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void iterationComplete()
TermStore
iterationComplete
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public T get(int index)
get
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public int size()
size
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void ensureCapacity(int capacity)
TermStore
ensureCapacity
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public Iterator<T> iterator()
iterator
in interface Iterable<T extends ReasonerTerm>
public Iterator<T> noWriteIterator()
TermStore
noWriteIterator
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
protected abstract V convertAtomToVariable(RandomVariableAtom atom)
Copyright © 2020 University of California, Santa Cruz. All rights reserved.