public override Task <OutputReply> SetOutputs(OutputValue value, ServerCallContext context) { hwInterface.SetOutputs(value.Value); return(Task.FromResult(new OutputReply { Done = true })); }
/// <summary> /// 輸出真值表 /// </summary> /// <returns></returns> public static string GetTruthTable() { string Result = string.Empty; Result = "Truth table:\n"; PrivtFieldName(ref Result); // 運行次數:2的N次方,N為Input pin數量 for (int i = 0; i < Math.Pow(2, (iPins.Length - 1)); i++) { int k = i; // 10進制轉2進制,並送入電路的Inputs for (int j = 0; j < iPins.Length - 1; j++) { iPins[((iPins.Length - 1) - j)].iPins = (Convert.ToBoolean(k % 2)); k /= 2; } // 輸出當前input的訊號 0 0 1 for (int j = 1; j < iPins.Length; j++) { Result += (Convert.ToInt32(iPins[j].iPins) + " "); } // 輸出結果 Result += "|"; foreach (dynamic OutputValue in oPins) { Result += (" " + Convert.ToInt32(OutputValue.GetOutput())); } Result += ("\n"); } return(Result); }
public void Run() { OutputValue = ""; Symbols.Clear(); string link = _link + TimeStamp; try { OutputValue = _xmlReader.GetValue(link, "outputValue"); if (!String.IsNullOrEmpty(OutputValue)) { var list = OutputValue.ToArray() .GroupBy(x => x) .Select(grp => new Symbol { Char = grp.Key, Count = grp.Count() }) .OrderBy(g => g.Char) .ToList(); foreach (Symbol s in list) { Symbols.Add(s); } } } catch (Exception ex) { OutputValue = ex.Message; } }
public PPONetworkContinuousSimple(int stateSize, int actionSize, int numLayers, int hiddenSize, DeviceDescriptor device, float initialWeightScale = 0.01f) { Device = device; StateSize = stateSize; ActionSize = actionSize; //create actor network part var inputA = new InputLayerDense(stateSize); var outputA = new OutputLayerDense(actionSize, null, OutputLayerDense.LossFunction.None); outputA.InitialWeightScale = initialWeightScale; valueNetwork = new SequentialNetworkDense(inputA, LayerDefineHelper.DenseLayers(numLayers, hiddenSize, true, NormalizationMethod.None, 0, initialWeightScale, new TanhDef()), outputA, device); InputState = inputA.InputVariable; OutputMean = outputA.GetOutputVariable(); OutputProbabilities = null; //this is for discrete action only. //the variance output will use a seperate parameter as in Unity's implementation var log_sigma_sq = new Parameter(new int[] { actionSize }, DataType.Float, CNTKLib.ConstantInitializer(0), device, "PPO.log_sigma_square"); //test OutputVariance = CNTKLib.Exp(log_sigma_sq); PolicyFunction = Function.Combine(new Variable[] { OutputMean, OutputVariance }); //create value network var inputC = new InputLayerCNTKVar(InputState); var outputC = new OutputLayerDense(1, null, OutputLayerDense.LossFunction.None); outputC.InitialWeightScale = initialWeightScale; policyNetwork = new SequentialNetworkDense(inputC, LayerDefineHelper.DenseLayers(numLayers, hiddenSize, true, NormalizationMethod.None, 0, initialWeightScale, new TanhDef()), outputC, device); OutputValue = outputC.GetOutputVariable(); ValueFunction = OutputValue.ToFunction(); //PolicyParameters.Add(log_sigma_sq); }
public PPONetworkDiscreteSimple(int stateSize, int actionSize, int numLayers, int hiddenSize, DeviceDescriptor device, float initialWeightScale = 0.01f) { Device = device; StateSize = stateSize; ActionSize = actionSize; //create actor network part var inputA = new InputLayerDense(stateSize); var outputA = new OutputLayerDense(actionSize, new SoftmaxDef(), OutputLayerDense.LossFunction.None); outputA.InitialWeightScale = initialWeightScale; valueNetwork = new SequentialNetworkDense(inputA, LayerDefineHelper.DenseLayers(numLayers, hiddenSize, true, NormalizationMethod.None, 0, initialWeightScale, new TanhDef()), outputA, device); InputState = inputA.InputVariable; OutputMean = null; OutputVariance = null; OutputProbabilities = outputA.GetOutputVariable(); //this is for discrete action only. PolicyFunction = OutputProbabilities.ToFunction(); //create value network var inputC = new InputLayerCNTKVar(InputState); var outputC = new OutputLayerDense(1, null, OutputLayerDense.LossFunction.None); outputC.InitialWeightScale = initialWeightScale; policyNetwork = new SequentialNetworkDense(inputC, LayerDefineHelper.DenseLayers(numLayers, hiddenSize, true, NormalizationMethod.None, 0, initialWeightScale, new TanhDef()), outputC, device); OutputValue = outputC.GetOutputVariable(); ValueFunction = OutputValue.ToFunction(); }
public IRepeatingSequence SetOutputValues(params double[] values) { OutputValue outputValue = new OutputValue(values); _OutputValue = outputValue; return(this); }
public void SendValueOnTopic(string topic, string val) { OutputValue outVal = new OutputValue(topic, val); OscMessage message; message = new OscMessage(); message.address = "/incoming"; message.values.Add(outVal.SaveToString()); osc.Send(message); }
/// <summary> /// Adds an output to a transaction /// </summary> /// <param name="value"></param> /// <param name="receiver"></param> /// <returns></returns> public Transaction AddOutput(int value, string receiver) { if (value < 0) { return(this); } OutputValue.Add(value); OutputReceiver.Add(receiver); return(this); }
/// <summary> /// Computes the outgoing values from this Transaction /// </summary> /// <returns></returns> public int ComputeOutgoingValues() { int sum = 0; //we get the trans fees sum += Int32.Parse(Data[0]); //and then each outgoing transaction value OutputValue.ForEach(m => sum += m); return(sum); }
void InitOutputMonitors() { OutputValue output = data.Fase1[solutionCombinantion[0]].MonitorOutput; Interactables.MonitorFase1.SetMaterial((int)output); OutputValue output2 = data.Fase2[solutionCombinantion[1]].MonitorOutput; Interactables.MonitorFase2.SetMaterial((int)output2); Interactables.MonitorFase2.ToggleOnOff(false); Interactables.MonitorFaseOK.ToggleOnOff(false); }
/// <summary> /// This method finalizes and converts the outputString to a floating point value /// </summary> private void FinalizeOutput() { OutputValue = float.Parse(OutputString); OutputValue = (float)Math.Round(OutputValue, 1); if (OutputValue < 0.1f) { OutputValue = 0.1f; } ActiveLabel.Text = OutputValue.ToString(); ClearNumericKeyBoard(); NumericKeyboardPanel.Visible = false; ActiveLabel.BackColor = Color.White; ActiveLabel = null; }
public string GetOutputDirectory(string projectFilePath, string config) { string OutputValue; XmlDocument xd = new XmlDocument(); xd.PreserveWhitespace = true; xd.Load(projectFilePath); string NameSpaceFor2005 = @"http://schemas.microsoft.com/developer/msbuild/2003"; bool Is2005 = xd.DocumentElement.HasAttribute("xmlns"); if (Is2005) { XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xd.NameTable); namespaceManager.AddNamespace("b", NameSpaceFor2005); XmlNode Node = null; Node = xd.SelectSingleNode(string.Format("//b:PropertyGroup[contains(@Condition, '{0}')]/b:OutputPath", config), namespaceManager); if (Node == null) { return(null); } OutputValue = Node.InnerText; OutputValue = OutputValue.TrimEnd(@"\".ToCharArray()); } else { XmlNode Node = null; Node = xd.SelectSingleNode(string.Format("//Config[@Name = '{0}']/@OutputPath", config)); if (Node == null) { return(null); } OutputValue = Node.InnerText; OutputValue = OutputValue.TrimEnd(@"\".ToCharArray()); } if (Path.IsPathRooted(OutputValue)) { return(Path.GetFullPath(OutputValue)); } return(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(projectFilePath), OutputValue))); }
/// <summary> /// Generates the hash of the transaction /// </summary> /// <returns></returns> public IDownloadable GenerateHash() { Curl curl = new Curl(); curl.Absorb(TangleNet::TryteString.FromAsciiString(SendTo).ToTrits()); curl.Absorb(TangleNet::TryteString.FromAsciiString(From).ToTrits()); curl.Absorb(TangleNet::TryteString.FromAsciiString(Mode + "").ToTrits()); curl.Absorb(TangleNet::TryteString.FromAsciiString(Data.GetHashCode() + "").ToTrits()); curl.Absorb(TangleNet::TryteString.FromAsciiString(Time + "").ToTrits()); curl.Absorb(TangleNet::TryteString.FromAsciiString(OutputValue.GetHashCode() + "").ToTrits()); curl.Absorb(TangleNet::TryteString.FromAsciiString(OutputReceiver.GetHashCode() + "").ToTrits()); curl.Absorb(TangleNet::TryteString.FromAsciiString(Data.GetHashCode() + "").ToTrits()); var hash = new int[60]; curl.Squeeze(hash); Hash = Converter.TritsToTrytes(hash); return(this); }
public void Count() { double[] numbers = new double[2]; try { string[] sNumbers = OutputValue.Split(usedOparator); if (OutputValue.Contains("E" + usedOparator)) { //mamy do czynienia z notacją wykładniczą dodatnią, a wiec dwa razy '+' lub '-' na wejściu sNumbers[0] += usedOparator + sNumbers[1]; sNumbers[1] = sNumbers[2]; } if (sNumbers[0] == "" || sNumbers[1] == "" || sNumbers.Count() < 2) { return; } numbers[0] = Convert.ToDouble(sNumbers[0]); numbers[1] = Convert.ToDouble(sNumbers[1]); } catch { return; } double solution = 0; //rozpocznij liczenie try { switch (usedOparator) { case '+': solution = numbers[0] + numbers[1]; break; case '-': solution = numbers[0] - numbers[1]; break; case '*': solution = numbers[0] * numbers[1]; break; case '➗': if (numbers[1] == 0) { ThrowError(); return; } solution = numbers[0] / numbers[1]; break; } // OutputValue = ((decimal)solution).ToString(); OutputValue = solution.ToString(); } catch { ThrowError(); //w razie gdyby z jakiegoś dziwnego powodu sobie nie poradził z liczeniem return; } separatorsPlacedAfterOperator = 0; if (OutputValue.Contains(currentSeparator)) { separatorsPlacedBeforeOperator = 1; //jeśli wynik ma w sobie separator, informacja zostaje } else { separatorsPlacedBeforeOperator = 0; } usedOparator = ' '; }
protected override void MetaOperate(List <MutableObject> entryList, UnaryOperators operation) { switch (operation) { case UnaryOperators.Value: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Operand.GetValue(subEntry), subEntry); } break; case UnaryOperators.Accumulate: var total = Vector3.zero; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Diff: bool first = true; var prior = Vector3.zero; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundEntry = Operand.GetValue(subEntry); prior = foundEntry - prior; if (first) { first = false; OutputValue.SetValue(0, subEntry); prior = foundEntry; continue; } OutputValue.SetValue(prior, subEntry); prior = foundEntry; } break; case UnaryOperators.Sign: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Vector3.Normalize(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Sin: foreach (var subEntry in Operand.GetEntries(entryList)) { var result = Operand.GetValue(subEntry); OutputValue.SetValue( new Vector3( Mathf.Sin(result.x), Mathf.Sin(result.y), Mathf.Sin(result.z)), subEntry); } break; case UnaryOperators.Cos: foreach (var subEntry in Operand.GetEntries(entryList)) { var result = Operand.GetValue(subEntry); OutputValue.SetValue( new Vector3( Mathf.Cos(result.x), Mathf.Cos(result.y), Mathf.Cos(result.z)), subEntry); } break; case UnaryOperators.Tan: foreach (var subEntry in Operand.GetEntries(entryList)) { var result = Operand.GetValue(subEntry); OutputValue.SetValue( new Vector3( Mathf.Tan(result.x), Mathf.Tan(result.y), Mathf.Tan(result.z)), subEntry); } break; default: throw new Exception("Unhandled operation type!"); } }
private static string GetOutputType(OutputValue value) => value switch {
//------------------------------------------------------------------------------------------------------------------------------------------------- public string GetOutputString() { return(OutputValue.ToString()); }
//预览功能 private void PreviewControler() { float X = this.panel1.Size.Width; X = X / 373; float Y = this.panel1.Size.Height; Y = Y / 245; X = Math.Max(1F, Math.Min(2F, Math.Min(X, Y))); panel1.Controls.Clear(); Point XY = new Point(this.panel1.Size.Width / 5 - 10, this.panel1.Size.Height / 6);//定位 Point YX = new Point(this.panel1.Size.Width / 4 - 40, this.panel1.Size.Height / 3 - 15); if (Basic[7] == "Modules") { Modules controler = new Modules(); controler.Location = XY; SetVelue(controler); controler.Scaling = X; panel1.Controls.Add(controler); } else if (Basic[7] == "Arithmetic") { //ControlTactic.SpecialControl.Fuzzy fuzzy = new ControlTactic.SpecialControl.Fuzzy(); Arithmetic controler = new Arithmetic(); controler.Location = XY; SetVelue(controler); controler.Scaling = X; panel1.Controls.Add(controler); } else if (Basic[7] == "OutputValue") { OutputValue controler = new OutputValue(); controler.Location = YX; SetVelue(controler); controler.Scaling = X; panel1.Controls.Add(controler); } else if (Basic[7] == "InputValue") { InputValue controler = new InputValue(); controler.Location = YX; SetVelue(controler); controler.Scaling = X; panel1.Controls.Add(controler); } else if (Basic[7] == "Constant") { Constant controler = new Constant(); controler.Location = YX; SetVelue(controler); controler.Scaling = X; panel1.Controls.Add(controler); } else if (Basic[7] == "SystemConstant") { SystemConstant controler = new SystemConstant(); controler.Location = YX; SetVelue(controler); controler.Scaling = X; panel1.Controls.Add(controler); } else if (Basic[7] == "Lable") { ControlTactic.Label controler = new ControlTactic.Label(); controler.Location = YX; SetVelue(controler); controler.Scaling = 1.8F * X; panel1.Controls.Add(controler); } else if (Basic[7] == "JMP") { ControlTactic.JMP controler = new ControlTactic.JMP(); controler.Location = YX; SetVelue(controler); controler.Scaling = X; panel1.Controls.Add(controler); } }
protected override void MetaOperate(List <MutableObject> entryList, UnaryOperators operation) { switch (operation) { case UnaryOperators.Value: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Operand.GetValue(subEntry), subEntry); } break; case UnaryOperators.Abs: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Abs(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Sum: float total = 0; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); } foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Average: total = 0; int count = 0; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); count++; } total /= count; foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Max: float max = float.MinValue; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundVal = Operand.GetValue(subEntry); if (max < foundVal) { max = foundVal; } } foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(max, subEntry); } break; case UnaryOperators.Min: float min = float.MaxValue; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundVal = Operand.GetValue(subEntry); if (min > foundVal) { min = foundVal; } } foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(min, subEntry); } break; case UnaryOperators.Accumulate: total = 0f; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Diff: bool first = true; var prior = 0f; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundEntry = Operand.GetValue(subEntry); prior = foundEntry - prior; if (first) { first = false; OutputValue.SetValue(0f, subEntry); prior = foundEntry; continue; } OutputValue.SetValue(prior, subEntry); prior = foundEntry; } break; case UnaryOperators.Sign: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue((Operand.GetValue(subEntry) >= 0?1f:-1f), subEntry); } break; case UnaryOperators.Sin: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Sin(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Cos: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Cos(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Tan: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Tan(Operand.GetValue(subEntry)), subEntry); } break; default: throw new Exception("Unknown operation type!"); } }