|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.algorithms.graphs.tensor.Tensor
de.jstacs.algorithms.graphs.tensor.SymmetricTensor
public class SymmetricTensor
This class can be used for Tensor
s with a special symmetry property.
This property states that for a given target node and for all permutations of
parent nodes the edge weight is constant. This is very helpful to save
storage and time in some algorithms. Since it is very useful it also enables
you to use this class if your tensor does not fulfill this property. For that
case the tensor saves only the maximum edge weight and the permutation of the
parent nodes.
Tensor
,
AsymmetricTensor
Field Summary |
---|
Fields inherited from class de.jstacs.algorithms.graphs.tensor.Tensor |
---|
L, order, powers |
Constructor Summary | |
---|---|
SymmetricTensor(AsymmetricTensor asym_tensor)
This constructor creates and checks a filled asymmetric tensor from an AsymmetricTensor instance. |
|
SymmetricTensor(double[][][] asym_tensor,
int N,
byte k)
This constructor creates and checks a filled asymmetric tensor with given dimension. |
|
SymmetricTensor(int n,
byte k)
This constructor creates an empty symmetric tensor with given dimension. |
|
SymmetricTensor(SymmetricTensor[] parts,
double[] weights)
The constructor can be used creating a new SymmetricTensor as
weighted sum of SymmetricTensor s. |
Method Summary | |
---|---|
double |
getBest(int child,
int[] par,
byte k)
Returns the maximal weight which can be reached for an edge from k nodes from the (encoded) set par to the node
child . |
int[] |
getEdgeFromIndex(int idx,
int k)
This method decodes an index in an edge. |
int[] |
getMaximalEdgeFor(byte k,
int child,
int... parents)
Returns the edge permute(parents[0],... |
double |
getRootValue(int child)
Returns the value for child as root. |
int |
getTrueIndexForLastGetBest()
Returns the edge from getBest(int, int[], byte) in an encoded
index. |
double |
getValue(byte k,
int child,
int... parents)
Returns the value for the edge parents[0],... |
void |
resetValue(byte k,
int child,
int... parents)
Sets the value for the edge parents -> child to
Double.NEGATIVE_INFTINITY . |
void |
setRootValue(int child,
double val)
Sets the value val for the root node child . |
void |
setValue(byte k,
double val,
int child,
int... parents)
Sets the value if it is bigger than the current value and keeps the parents information. |
Methods inherited from class de.jstacs.algorithms.graphs.tensor.Tensor |
---|
getAsymIndex, getNumberOfNodes, getOrder, readTensorFromFile, toDouble3DArray, writeTensorToFile |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SymmetricTensor(int n, byte k)
n
- the number of nodesk
- the orderTensor.Tensor(int, byte)
public SymmetricTensor(SymmetricTensor[] parts, double[] weights) throws IllegalArgumentException
SymmetricTensor
as
weighted sum of SymmetricTensor
s.
parts
- the SymmetricTensor
sweights
- the weight for each SymmetricTensor
IllegalArgumentException
- if something went wrongSymmetricTensor(int, byte)
public SymmetricTensor(AsymmetricTensor asym_tensor)
AsymmetricTensor
instance.
asym_tensor
- the asymmetric instanceAsymmetricTensor
,
SymmetricTensor(double[][][], int, byte)
public SymmetricTensor(double[][][] asym_tensor, int N, byte k)
asym_tensor
- the tensor weightsN
- the number of nodesk
- the orderSymmetricTensor(int, byte)
Method Detail |
---|
public double getBest(int child, int[] par, byte k)
k
nodes from the (encoded) set par
to the node
child
.
child
- the target nodepar
- an encoded set, elements are sorted and for all elements
e >= child
the real value is (e+1)
,
e.g. child = 3
and possible parents
= {5,2,0,6,1}
then
par = {0,1,2,4,5}
k
- the number of parents used from par
public int[] getEdgeFromIndex(int idx, int k)
idx
- the encoded indexk
- the order
public int[] getMaximalEdgeFor(byte k, int child, int... parents)
Tensor
permute(parents[0],...,parents[k-1]) -> child
that maximizes
the score.
getMaximalEdgeFor
in class Tensor
k
- the number of parents to be usedchild
- the child nodeparents
- the parent nodes (only the first k
will be used)
permute(parents[0],...,parents[k-1]) -> child
that
maximizes the scorepublic double getRootValue(int child)
Tensor
child
as root.
getRootValue
in class Tensor
child
- the name of the node
public int getTrueIndexForLastGetBest()
getBest(int, int[], byte)
in an encoded
index.
getBest(int, int[], byte)
in an encoded
indexgetBest(int, int[], byte)
public double getValue(byte k, int child, int... parents)
Tensor
parents[0],...,parents[k-1] -> child
.
getValue
in class Tensor
k
- the number of parents to be usedchild
- the child nodeparents
- the parent nodes (only the first k
will be used)
parents[0],...,parents[k-1] -> child
public void resetValue(byte k, int child, int... parents)
parents -> child
to
Double.NEGATIVE_INFTINITY
.
resetValue
in class Tensor
k
- the orderchild
- the index of the child nodeparents
- the indices of the parent nodespublic void setRootValue(int child, double val)
Tensor
val
for the root node child
.
setRootValue
in class Tensor
child
- the name of the nodeval
- the value for the nodepublic void setValue(byte k, double val, int child, int... parents)
setValue
in class Tensor
k
- the orderval
- the value to be setchild
- the index of the child nodeparents
- the indices of the parent nodes
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |