private bool ValidateInputSchemas() { if (!InputNodes.All(node => node.IsConnected())) { MessageService.ShowError("Data Connection Error", "Not all input nodes are connected to scripting module"); return(false); } foreach (var node in InputNodes) { string prevModName = node.DisplayName; var state = ((OutputNode)node.Connector).State; if (state == null) { MessageService.ShowError("Data Connection Error", $"In Module {prevModName} passed invalid state object"); return(false); } if (state.Schema == null) { MessageService.ShowError("Data Connection Error", $"In Module {prevModName} Sate has invalid Schema"); return(false); } } return(true); }
public MultilayerPerceptron(int nInputs, int nHidden, int nOutputs) { for (int i = 0; i < nOutputs; ++i) { OutputNodes.Add(new Node()); } for (int i = 0; i < nHidden; ++i) { var node = new Node(); foreach (var hiddenNode in HiddenNodes) { node.Connectors.Add(new Connector() { Weight = 1, Node = hiddenNode }); } } for (int i = 0; i < nInputs; ++i) { var node = new Node(); foreach (var output in OutputNodes) { node.Connectors.Add(new Connector() { Weight = 1, Node = output }); } InputNodes.Add(node); } }
public void InitialiseNetwork() { //Clear all the nodes foreach (Node Node in Nodes) { Node.ClearValue(); } //Check if we have 'shortcuts' to the input and output nodes if (InputNodes.Count == 0 || OutputNodes.Count == 0) { InputNodes.Clear(); OutputNodes.Clear(); foreach (Node Node in Nodes) { switch (Node.Type) { case eNeuralNodeType.eInput: InputNodes.Add(Node); break; case eNeuralNodeType.eOutput: OutputNodes.Add(Node); break; } } } }
protected void AddInputNode(BaseInputNode node) { node.OnConnected += OnNodeConnected; node.OnDisconnect += OnNodeDisconnected; InputNodes.Add(node); OnNodeAdded?.Invoke(this, node); }
public String GetMethodURL(String root = "", HtmlNode formNode = null) { if (formNode == null) { formNode = entry.node; } String sb = root; sb = sb.add(action, ""); var inputNodes = InputNodes.Where(x => x.typeClass == InputNodeTypeClass.data).ToList(); if (inputNodes.Any()) { sb = sb + "?"; } String inner = ""; foreach (var ind in inputNodes) { String relXpath = ind.entry.XPath.GetRelativeXPath(entry.XPath); HtmlNode indn = formNode.selectSingleNode(relXpath); String pair = ind.name + "=" + ind.GetValue(indn); inner = inner.add(pair, "&"); } sb = sb + inner; return(sb); }
public List <InputNodeDefinition> GetMatchedNodes(List <InputNodeValue> input) { List <InputNodeDefinition> output = new List <InputNodeDefinition>(); foreach (InputNodeValue input_value in input) { InputNodeDefinition match = InputNodes.FirstOrDefault(x => x.xkey == input_value.xkey); //foreach (var pair in InputNodes) //{ // if (pair.IsMatch(input_value.xkey)) // { // match = pair; // break; // } //} if (match != null) { match.value = input_value.value; output.Add(match); } } return(output); }
private void CheckTypeDefinition(ArrayList inputValues) { if (InputNodes.Count == 0 || !InputNodes.ContainsKey(0) || InputNodes[0] == null) { TypeDefinition = null; } else { if (inputValues[0] is string typeDef) { if (typeDef != _cachedTypeDefinition) { try { TypeDefinition = TypeDefinitionParser.ParseType(typeDef); _cachedTypeDefinition = typeDef; } catch (Sprache.ParseException e) { TypeDefinition = null; Warning(e.Message, true); } } } else { Warning("Input Type must be of type string", true); } } }
public virtual void TryAndProcess() { int c = Nodes.Count; for (int i = 0; i < c; i++) { Node n = Nodes[i]; if (OutputNodes.Contains(n.Id)) { continue; } if (InputNodes.Contains(n.Id)) { continue; } n.TryAndProcess(); } c = InputNodes.Count; for (int i = 0; i < c; i++) { Node n; if (NodeLookup.TryGetValue(InputNodes[i], out n)) { InputNode inp = (InputNode)n; inp.TryAndProcess(); } } }
protected override void CreateNodes(ref Blocks.BlockBase root) { this.Interpolate = true; InputNodes.Add(new Blocks.BlockInputNode(ref root, "input1", "in1")); InputNodes.Add(new Blocks.BlockInputNode(ref root, "input2", "in2")); InputNodes.Add(new Blocks.BlockInputNode(ref root, "select", "sel")); OutputNodes.Add(new Blocks.BlockOutputNode(ref root, "output", "out")); }
public void Clear() { items.Clear(); InputNodes.Clear(); LabelNodes.Clear(); RebuildIndex(); }
public void ClearNetwork() { //clear the vector of pointers to the input nodes InputNodes.Clear(); OutputNodes.Clear(); //delete all nodes from the network and clear the //vector Nodes.Clear(); }
/// <summary> /// this is used in GraphInstances /// To resize proportionate to new size /// </summary> /// <param name="width"></param> /// <param name="height"></param> public virtual void ResizeWith(int width, int height) { this.width = width; this.height = height; int c = Nodes.Count; for (int i = 0; i < c; i++) { Node n = Nodes[i]; if (OutputNodes.Contains(n.Id)) { continue; } if (InputNodes.Contains(n.Id)) { continue; } if (n is BitmapNode) { BitmapNode bn = (BitmapNode)n; bn.TryAndProcess(); } else { Point osize; if (OriginSizes.TryGetValue(n.Id, out osize)) { float wratio = width / (float)osize.X; float hratio = height / (float)osize.Y; int fwidth = (int)Math.Min(4096, Math.Max(16, Math.Round(osize.X * wratio))); int fheight = (int)Math.Min(4096, Math.Max(16, Math.Round(osize.Y * hratio))); n.Width = fwidth; n.Height = fheight; } } } c = InputNodes.Count; for (int i = 0; i < c; i++) { Node n; if (NodeLookup.TryGetValue(InputNodes[i], out n)) { InputNode inp = (InputNode)n; inp.TryAndProcess(); } } }
public void AddNode(int plLayer, eNeuralNodeType peType) { Node oNode; Connection oConnection; int lNodeIndex; //create node oNode = new Node(peType, plLayer); oNode.Treshold = 0; oNode.Id = Nodes.Count; Nodes.Add(oNode); switch (peType) { case eNeuralNodeType.eInput: { InputNodes.Add(oNode); break; } case eNeuralNodeType.eOutput: { OutputNodes.Add(oNode); break; } } lNodeIndex = Nodes.Count - 1; //create connections to all nodes in previous layer for (int lIndex = 0; lIndex < (int)Nodes.Count; lIndex++) { if (Nodes[lIndex].lLayer == plLayer - 1) { oConnection = new Connection(lIndex, lNodeIndex); oConnection.fWeight = 0; oNode.Connections.Add(oConnection); } } //create connections to all nodes in next layer foreach (Node Node in Nodes) { if (Node.lLayer == plLayer + 1) { oConnection = new Connection(lNodeIndex, Node.Id); oConnection.fWeight = 0; Node.Connections.Add(oConnection); } } }
private void N_OnInputRemovedFromNode(Node n, NodeInput inp) { var uinp = InputNodes.Find(m => m.Input == inp); if (uinp != null) { InputStack.Children.Remove(uinp); InputNodes.Remove(uinp); } ResizeHeight(); }
private void N_OnInputAddedToNode(Node n, NodeInput inp) { UINodePoint inputpoint = new UINodePoint(this, Graph); inputpoint.Input = inp; inputpoint.VerticalAlignment = VerticalAlignment.Center; InputStack.Children.Add(inputpoint); InputNodes.Add(inputpoint); inputpoint.UpdateColor(); ResizeHeight(); }
private void N_OnInputRemovedFromNode(Node n, NodeInput inp, NodeInput previous = null) { var uinp = InputNodes.Find(m => m.Input == inp); if (uinp != null) { //whoops forgot to dispose //on the uinodepoint to remove previous connects //etc uinp.Dispose(); InputStack.Children.Remove(uinp); InputNodes.Remove(uinp); } }
public void RemoveNode(INode node) { if (node is BaseOutputNode) { var sp = spOutputNodes.Children.OfType <StackPanel>().Where(x => x.Name == "nodeContainer" && x.Tag == node).FirstOrDefault(); spOutputNodes.RemoveChild(sp); OutputNodes.RemoveAll(x => x.Node == node); } else if (node is InputNode) { var sp = spInputNodes.Children.OfType <StackPanel>().Where(x => x.Name == "nodeContainer" && x.Tag == node).FirstOrDefault(); spInputNodes.RemoveChild(sp); InputNodes.RemoveAll(x => x.Node == node); } }
protected void RemoveNode(BaseNode node) { node.Disconnect(); node.OnConnected -= OnNodeConnected; node.OnDisconnect -= OnNodeDisconnected; if (node is BaseOutputNode) { OutputNodes.Remove((BaseOutputNode)node); } else { InputNodes.Remove((BaseInputNode)node); } OnNodeRemoved?.Invoke(this, node); }
private void Module_OnNodeAdded(object sender, INode node) { if (node is BaseOutputNode) { if (!OutputNodes.Any(x => x.Node == node)) { AddNode(node); } } else if (node is BaseInputNode) { if (!InputNodes.Any(x => x.Node == node)) { AddNode(node); } } }
public Perceptron(int nInputs, int nOutputs) { for (int i = 0; i < nOutputs; ++i) { OutputNodes.Add(new Node()); } for (int i = 0; i < nInputs; ++i) { var node = new Node(); foreach (var output in OutputNodes) { node.Connectors.Add(new Connector() { Weight = 1, Node = output }); } InputNodes.Add(node); } }
public virtual void Remove(Node n) { if (n is OutputNode) { OutputNodes.Remove(n.Id); } else if (n is InputNode) { InputNodes.Remove(n.Id); } NodeLookup.Remove(n.Id); if (Nodes.Remove(n)) { n.OnUpdate -= N_OnUpdate; } n.Dispose(); }
protected LeafNodeDictionaryEntry ProcessLabelNode(HtmlNode n) { LeafNodeDictionaryEntry entry = AddOrGet(n); if (entry.MetaData == null) { LabelNodeDefinition labelNodeDefinition = new LabelNodeDefinition(n, entry); if (!labelNodeDefinition.for_attribute.isNullOrEmpty()) { var ind = InputNodes.FirstOrDefault(x => x.id.Equals(labelNodeDefinition.for_attribute)); if (ind != null) { ind.Label = labelNodeDefinition; } LabelNodes.Add(labelNodeDefinition); } } return(entry); }
protected LeafNodeDictionaryEntry ProcessInputNode(HtmlNode n) { var input_types_toWatch = InputTypesToWatch.or(DefaultInputTypesToWatch); LeafNodeDictionaryEntry entry = AddOrGet(n); if (entry.MetaData == null) { var formParentNode = n.GetFirstParent(x => x.Name.Equals("form", StringComparison.InvariantCultureIgnoreCase)); InputFormDefinition inf = null; if (formParentNode != null) { if (!FormNodes.Any(x => x.entry.XPath == formParentNode.XPath)) { LeafNodeDictionaryEntry form_entry = Add(formParentNode); inf = new InputFormDefinition(form_entry, formParentNode); FormNodes.Add(inf); } else { inf = FormNodes.FirstOrDefault(x => x.entry.XPath == formParentNode.XPath); } } InputNodeDefinition ind = new InputNodeDefinition(entry, n); if (input_types_toWatch.Contains(ind.type)) { ind.DoWatch = true; } if (!InputNodes.Any(x => x.xkey == ind.xkey)) { InputNodes.Add(ind); if (inf != null) { inf.Add(ind); } } } return(entry); }
private void BindNodesCountToForm(frmMain form) { form.OnInputNodesValueChanged += (newValue) => { if (newValue > InputNodes.Count) { for (int i = newValue - InputNodes.Count; i > 0; i--) { var inNode = new InputNode(this, "Schema", "DataLocation"); AddInputNode(inNode); } } else if (newValue < InputNodes.Count) { for (int i = InputNodes.Count - newValue; i > 0; i--) { RemoveNode(InputNodes.Last()); } } }; form.OnOutputNodesValueChanged += (newValue) => { if (newValue > OutputNodes.Count) { for (int i = newValue - OutputNodes.Count; i > 0; i--) { var outNode = new OutputNode(this, "Schema", "DataLocation"); outNode.State = new ModuleState(); AddOutputNode(outNode); } } else if (newValue < OutputNodes.Count) { for (int i = OutputNodes.Count - newValue; i > 0; i--) { RemoveNode(OutputNodes.Last()); } } }; }
public DocumentNodeChanges Compare(HtmlNode node) { DocumentNodeChanges output = new DocumentNodeChanges(); var input_nodes = node.selectNodes(".//input"); if (input_nodes == null) { return(null); } foreach (HtmlNode n in input_nodes) { LeafNodeDictionaryEntry entry = null; if (CachedIndex.ContainsKey(n.XPath)) { entry = CachedIndex[n.XPath]; } InputNodeDefinition ind = new InputNodeDefinition(entry, n); if (InputNodes.Any(x => x.xkey == ind.xkey)) { InputNodeDefinition o_ind = InputNodes.FirstOrDefault(x => x.xkey == ind.xkey); if (!o_ind.value.Equals(ind.value)) { InputNodeChange change = new InputNodeChange() { oldValue = o_ind.value, newValue = ind.value, NodeDefinition = o_ind, name = o_ind.xkey }; output.InputChanges.Add(change); } } } return(output); }
private void N_OnInputAddedToNode(Node n, NodeInput inp, NodeInput previous = null) { //need to take into account previous //aka we are just replacing the previous one UINodePoint previousNodePoint = null; UINodePoint previousNodePointParent = null; if (previous != null) { previousNodePoint = InputNodes.Find(m => m.Input == previous); } if (previousNodePoint != null) { previousNodePointParent = previousNodePoint.ParentNode; } UINodePoint inputpoint = new UINodePoint(this, Graph); inputpoint.Input = inp; inputpoint.VerticalAlignment = VerticalAlignment.Center; InputStack.Children.Add(inputpoint); InputNodes.Add(inputpoint); inputpoint.UpdateColor(); //try and reconnect previous parent node to it graphically if (previousNodePointParent != null) { previousNodePointParent.ConnectToNode(inputpoint, true); } if (previous != null) { N_OnInputRemovedFromNode(n, previous); } ResizeHeight(); }
private void AddNode(object item) { NodeDisplay newNode = new() { CoreNode = item as INodeBase }; newNode.ShowConnectors = false; newNode.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center; InputNodes.Add(newNode); newNode.PointerPressed += (o, e) => { _lastClickedDisplay = new NodeDisplay() { CoreNode = item as INodeBase }; _dragOffset = e.GetPosition(newNode); }; newNode.PointerReleased += (o, e) => { _lastClickedDisplay = null; }; newNode.CoreNode.NameLabel.NeedsEditing = true; }
public virtual bool Add(Node n) { if (NodeLookup.ContainsKey(n.Id)) { return(false); } if (n is OutputNode) { OutputNodes.Add(n.Id); } else if (n is InputNode) { InputNodes.Add(n.Id); } NodeLookup[n.Id] = n; Nodes.Add(n); n.OnUpdate += N_OnUpdate; return(true); }
/// <summary> /// Lock the Bayes Classifier object so that new inputs can no longer be associated with this classifier object, /// and new classification categories cannot be added. /// </summary> public void Lock() { // lock both lists InputNodes.Lock(); ClassificationCategories.Lock(); // return exception if failed to lock both lists, else, set lock status and inform all parties if (InputNodes.Locked & ClassificationCategories.Locked) { // lock THIS object Locked = true; // actualize in MATLAB Actualize(); // inform everybody if (HasBeenLocked != null) { HasBeenLocked(this, new EventArgs()); } // subscribe to variable value change foreach (var inputNode in _inputNodes) { if (inputNode.GetType() == typeof(Variable)) { var v = (Variable)inputNode; v.ValueHasBeenUpdated += OnInputNodeValueUpdated; } if (inputNode.GetType() == typeof(BayesClassifierModule)) { var bcm = (BayesClassifierModule)inputNode; bcm.NewResultAvailable += OnInputNodeValueUpdated; } } } else { throw new ApplicationException("Failed to lock Bayes Classifier Module " + Name + "."); } }
public InputNodeDefinition GetInputByID(String id) { return(InputNodes.FirstOrDefault(x => x.id.Equals(id, StringComparison.InvariantCultureIgnoreCase))); }