public void Add(Node node, bool isOutput = false, bool isInput = false) { if (isOutput && !Outputs.Contains(node)) { Outputs.Add(node); } if (isInput && !Inputs.Contains(node)) { Inputs.Add(node); } if (graph.ContainsVertex(node)) { return; } if (!NodeIndex.ContainsKey(node.Value)) { NodeIndex[node.Value] = node; } else if (NodeIndex[node.Value] != node) { NodeIndex[node.Value] = node; //TODO: this could be really bad!!! //throw new InvalidOperationException($"a node with the value '{node.Value}' already exists!"); } graph.AddVertex(node); node.OnAdd(this); }
public bool AddNode(Node node) { bool added = false; if (node.ParentNetwork == this && !Nodes.Contains(node)) { added = true; Nodes.Add(node); if (node is OutputPipeNode && !Outputs.Contains(node)) { Outputs.Add((OutputPipeNode)node); } else if (node is InputPipeNode && !Inputs.Contains(node)) { Inputs.Add((InputPipeNode)node); } else if (node is ConnectorPipeNode && !Connectors.Contains(node)) { Connectors.Add((ConnectorPipeNode)node); } else if (node is PPMNode && Invis == null) { Invis = (PPMNode)node; } } else if (node.ParentNetwork != this) { //Printer.Info($"Tried to add {node.Print()} to N{ID}, but they dont match."); } return(added); }
public bool RemoveNode(Node node) { bool removed = false; if (Nodes.Contains(node)) { removed = true; Nodes.Remove(node); if (Outputs.Contains(node)) { Outputs.Remove((OutputPipeNode)node); } else if (Inputs.Contains(node)) { Inputs.Remove((InputPipeNode)node); } else if (Connectors.Contains(node)) { Connectors.Remove((ConnectorPipeNode)node); } else if (node is PPMNode && Invis != null) { Invis = null; if (IsPassable) { Deinvisibilize((PPMNode)node); } } } return(removed); }
/// <summary> /// Adds an output to this logger. /// </summary> /// <param name="output">The output.</param> public void AddOutput(ILoggerOutput output) { if (Outputs.Contains(output)) { return; } Outputs.Add(output); }
public bool IsExistingOutputAsset(object obj) { OutputAsset outputAsset = obj as OutputAsset; if (outputAsset != null) { TOutputAsset toutputAsset = outputAsset as TOutputAsset; return(Outputs.Contains(toutputAsset)); } return(false); }
public void RemoveOutput(Output output) { if (output == null || !Outputs.Contains(output)) { LogError("Can`t remove output. Does not exist."); return; } var links = engine.GetLinksForOutput(output); engine.RemoveLinks(links, true); Outputs.Remove(output); }
internal void AddPlatformSizes() { var toAdd = new List <OutputConfig>(); if (Platform == Platform.Android) { toAdd.Add(new OutputConfig { Ratio = 0.75, Path = "drawable-ldpi" }); toAdd.Add(new OutputConfig { Ratio = 1.0, Path = "drawable-mdpi" }); toAdd.Add(new OutputConfig { Ratio = 1.5, Path = "drawable-hdpi" }); toAdd.Add(new OutputConfig { Ratio = 2.0, Path = "drawable-xhdpi" }); toAdd.Add(new OutputConfig { Ratio = 3.0, Path = "drawable-xxhdpi" }); toAdd.Add(new OutputConfig { Ratio = 4.0, Path = "drawable-xxxhdpi" }); } else if (Platform == Platform.iOS) { toAdd.Add(new OutputConfig { Ratio = 1.0 }); toAdd.Add(new OutputConfig { Ratio = 2.0, FileSuffix = "@2x" }); toAdd.Add(new OutputConfig { Ratio = 3.0, FileSuffix = "@3x" }); } foreach (var i in toAdd) { if (!Outputs.Contains(i)) { Outputs.Add(i); } } }
public override void TrainFromQueries(params string[] queries) { InParseMode = false; var examples = new List <NodeExample>(); var queryId = 0; foreach (var query in queries) { queryId++; var tokeniser = new SparqlTokeniser(ParsingTextReader.Create(new StringReader(query)), SparqlQuerySyntax.Sparql_1_1); var token = tokeniser.GetNextToken(); IToken beforeLastToken = null; IToken lastToken = null; while (token != null && !(token is EOFToken)) { token = tokeniser.GetNextToken(); var tokenValue = token is VariableToken ? queryId + "." + token.Value : token.Value; var node = Node(tokenValue); node.UseEdgesAsInterface = false; if (tokenValue.Contains(Prefix) && Outputs.Contains(node)) { var last = Node(queryId + "." + lastToken.Value); examples.Add(new NodeExample(last, node)); } if (beforeLastToken is VariableToken && (lastToken.Value.Contains("a") || lastToken.Value.Contains(Prefix))) { var n = Node(queryId + "." + beforeLastToken.Value); n.AddEdge(Node("a"), node); } beforeLastToken = lastToken; lastToken = token; } } Train(examples.ToArray()); InParseMode = true; }
public IEnumerable <Tact> TactsOfExtinction() { if (_tactsOfExtinction != null) { return(_tactsOfCreation); } if (_tactsOfCreation == null) { _tactsOfCreation = TactsOfCreation(); } var tactsOfCreation = _tactsOfCreation.ToList(); var result = new List <Tact>(); for (var row = 0; row < _adjacencyMatrix.Height; row++) { if (Outputs.Contains(row + 1)) { result.Add(new Tact(row + 1, Power)); continue; } var maxCell = 0; for (var node = 0; node < _adjacencyMatrix.Height; node++) { var currentCell = _adjacencyMatrix[row, node] * tactsOfCreation[node].Value; if (maxCell < currentCell) { maxCell = currentCell; } } result.Add(new Tact(row + 1, maxCell)); } _tactsOfExtinction = result.OrderBy(it => it.Node); return(_tactsOfExtinction); }
public override void Train(params Example[] examples) { List <Node> allNodes = GetNodeIndex(); net = new Net(allNodes, Outputs, MaxPathLenght, MaxNumberOfPaths); foreach (var ouputNode in Outputs) { ouputNode.Train(examples); } foreach (Example example in examples) { var paths = GetPaths(example); //TODO: check that this trim is safe if (paths.Count >= MaxNumberOfPaths && LimitNumberOfPaths) { paths = paths.OrderBy(p => p.Count).Take(MaxNumberOfPaths - 1).ToList(); } if (paths.Count > 0) { var first = paths[0]; var output = Node(first[first.Count - 1]); if (!Outputs.Contains(output)) { throw new InvalidOperationException($"{output} is not an output in { this}"); } paths.ForEach(p => { var o = Node(p[p.Count - 1]); if (o != output) { throw new InvalidOperationException($"multiple outputs"); } }); net.AddToTraining(paths, output); } } net.Train(); }
public static void TranslatePageParametersToEntities(Process process, IDictionary <string, string> parameters, string defaultOutput) { var output = parameters.ContainsKey("output") ? parameters["output"] : defaultOutput; var isOutput = Outputs.Contains(output); var isMode = Modes.Contains(output); foreach (var entity in process.Entities) { if (isMode) { if (output == "map") { entity.Page = 1; entity.PageSize = 0; } else { if (entity.Page > 0) { int page; if (parameters.ContainsKey("page")) { if (!int.TryParse(parameters["page"], out page)) { page = 1; } } else { page = 1; } entity.Page = page; var size = 0; if (parameters.ContainsKey("size")) { int.TryParse(parameters["size"], out size); } if (size > 0 || output == "page") { entity.PageSize = size > 0 && entity.PageSizes.Any(s => s.Size == size) ? size : entity.PageSizes.First().Size; } else { entity.PageSize = size; } } } } else { if (isOutput) { entity.Page = 0; entity.PageSize = 0; } else // unknown output request { entity.Page = 1; entity.PageSize = 0; } } } }
public bool IsInput(string s) { return(Inputs.Contains(s) || Outputs.Contains("*")); }
public bool OutputExists(IReceiver output) { return(Outputs.Contains(output)); }
public bool OutputExists(Output output) { return(Outputs.Contains(output)); }