Documentation
¶
Index ¶
- func CreateDAG(numNodes, numEdges int) [][]int
- func EvalExpr(expression dtos.DataChildDTO, getOpinionMode string, ...) (dtos.KeyDTO, error)
- func Evaluator(expression dtos.DataChildDTO, getOpinionMode string, ...) (dtos.KeyDTO, error)
- func ExprToDTO(expression dtos.DataChildExpressionDTO) dtos.DataChildDTO
- func ExpressionSynthesizer(vertexEdges []dtos.VertexEdgeDTO, checkDSPG bool, debug *bool) (bool, dtos.DataChildExpressionDTO)
- func GenerateRandomDSPGGraph(n int) graph.Graph[string, string]
- func Init(logger *slog.Logger, filePath string, debuggingMode bool)
- func MetaToConcreteExpressionConverter(expression dtos.DataChildExpressionDTO, mathematicalModel string) dtos.DataChildExpressionDTO
- func MetaToConcreteExpressionConverterUpd(expression dtos.DataChildExpressionDTO, mathematicalModel string) dtos.DataChildDTO
- func ReferralDiscountChecker(expression dtos.DataChildDTO, target string, debug bool) (dtos.DataChildDTO, error)
- func ToDSPGTransform(vertexEdges []dtos.VertexEdgeDTO, debug *bool) dtos.SynthesizingGraph
- type TLEE
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalExpr ¶
func EvalExpr(expression dtos.DataChildDTO, getOpinionMode string, opinionMap map[dtos.KeyDTO]dtos.OpinionDTOValue, operationFunc map[string]func(dtos.OpinionDTOValue, dtos.OpinionDTOValue) dtos.OpinionDTOValue, target string, debug bool) (dtos.KeyDTO, error)
The EvalExpr function evaluates a logical expression represented by dtos.DataChildDTO. It recursively processes the expression and its child expressions based on the specified getOpinionMode and opinionMap.
If the expression.Data.Operation is an empty string, it directly retrieves the opinion from the opinionMap and returns it. Otherwise, it checks the number of child expressions (n) and handles cases where n is 0 (error), 1 (single child), or greater than 1 (multiple children).
For multiple children, it recursively evaluates each child expression, then applies the logical operation specified in expression.Data.Operation to combine their opinions. The resulting opinion is returned along with the associated nodes.
func Evaluator ¶
func Evaluator(expression dtos.DataChildDTO, getOpinionMode string, values []trustmodelstructure.TrustRelationship, operationFunc map[string]func(dtos.OpinionDTOValue, dtos.OpinionDTOValue) dtos.OpinionDTOValue, target string) (dtos.KeyDTO, error)
The Evaluator function initializes the evaluation of a logical expression represented by dtos.DataChildDTO. It retrieves opinions either from a provided slice or by calling the csv2Opinion function based on the getOpinionMode.
After ensuring the opinions are valid, it constructs a map (opinionMap) to associate each opinion with a corresponding key (FromNode, ToNode). The function then calls EvalExpr to evaluate the logical expression and returns the result.
This function acts as a setup and entry point for evaluating complex logical expressions with opinion data.
func ExprToDTO ¶
func ExprToDTO(expression dtos.DataChildExpressionDTO) dtos.DataChildDTO
func ExpressionSynthesizer ¶
func ExpressionSynthesizer(vertexEdges []dtos.VertexEdgeDTO, checkDSPG bool, debug *bool) (bool, dtos.DataChildExpressionDTO)
The public function is responsible for generating and simplifying an expression based on a given list of dtos.VertexEdgeDTO representing vertex edges. It produces a dtos.DataChildExpression that represents the simplified expression.
The function begins by creating a new directed acyclic graph dspgGraph using the graph package, where each vertex corresponds to a node and edges represent links between nodes. It iterates through the provided vertexEdges and adds vertices and edges to the dspgGraph using dspgFunc.AddVertexAndEdge. The function generates all possible Partial Path Sets (PPS) and their nesting levels using generateExpression.FindPpsAndNestingLevel based on the dspgGraph. Nesting levels are added to the PPS using generateExpression.AddNestingLevelToPps. The minimum nesting level for each PPS is calculated using dspgFunc.MinNestingLevel, and these values are assigned to each PPS. A map expression is created to store expressions for each edge in the dspgGraph. Each edge is represented by an dtos.Expression key with an empty dtos.DataChildExpression value. The PPS are sorted based on their minimum nesting levels and the number of edges using generateExpression.SortPps. The function initializes subgraphExpression to represent the reduced subgraph expression. For each PPS, the function reduces the graph and updates the expression map using generateExpression.ReduceGraph. It also updates the list of PPS by removing the first PPS and adding the newly reduced PPS. The final expression is synthesized using generateExpression.SynthesizeFinalPath based on the original dspgGraph and the expression map. If the final expression is empty, the subgraphExpression is returned as the result. The generated and simplified expression is returned as a dtos.DataChildExpression.
func MetaToConcreteExpressionConverter ¶
func MetaToConcreteExpressionConverter(expression dtos.DataChildExpressionDTO, mathematicalModel string) dtos.DataChildExpressionDTO
The public function is responsible for retrieving the real logical expression based on the provided dtos.DataChildExpression. It transforms the logical operators in the expression according to the specified mathematicalModel and returns the updated expression.
The function checks if the expression has child expressions (sub-expressions). If it does, it recursively calls RetrieveRealExpression on each child expression to transform them accordingly. It checks if the expression.Data.Operation is not an empty string (i.e., it's an operation). If it is, the function transforms the operation using a mapping defined in the dtos.LogicOperator based on the specified mathematicalModel. The updated expression is returned with transformed logical operators.
func MetaToConcreteExpressionConverterUpd ¶
func MetaToConcreteExpressionConverterUpd(expression dtos.DataChildExpressionDTO, mathematicalModel string) dtos.DataChildDTO
The public function is responsible for retrieving the real logical expression based on the provided dtos.DataChildExpression. It transforms the logical operators in the expression according to the specified mathematicalModel and returns the updated expression.
The difference between this function and MetaToConcreteExpressionConverter is that MetaToConcreteExpressionConverter returns a dtos.DataChildExpressionDT while MetaToConcreteExpressionConverterUpd returns a dtos.DataChildDTO
func ReferralDiscountChecker ¶
func ReferralDiscountChecker(expression dtos.DataChildDTO, target string, debug bool) (dtos.DataChildDTO, error)
func ToDSPGTransform ¶
func ToDSPGTransform(vertexEdges []dtos.VertexEdgeDTO, debug *bool) dtos.SynthesizingGraph
Types ¶
type TLEE ¶
type TLEE struct {
//map the trust model instance to a mapping with maps a fingerprint to an expression already synthesized
FingerprintToExpr map[string]map[string]dtos.DataChildDTO
VersionToValue map[int][]trustmodelstructure.TrustRelationship
}
func SpawnNewTLEE ¶
func (*TLEE) RunTLEE ¶
func (tlee *TLEE) RunTLEE(trustmodelID string, version int, fingerprint uint32, structure trustmodelstructure.TrustGraphStructure, values map[string][]trustmodelstructure.TrustRelationship) (map[string]subjectivelogic.QueryableOpinion, error)
A pointer receiver menthod that operates on the instance of the TLEE type.
The modifications made to the receiver inside the method will directly affect the original instance.