public void Init(ParameterGroup parameters1, float paramNameWidth, int totalWidth) { ParameterGroup = parameters1; int nrows = ParameterGroup.Count; grid = new TableLayoutPanel(); grid.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, paramNameWidth)); grid.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, totalWidth - paramNameWidth)); grid.Margin = new Padding(0); for (int i = 0; i < nrows; i++) { float h = ParameterGroup[i].Visible ? ParameterGroup[i].Height : 0; grid.RowStyles.Add(new RowStyle(SizeType.Absolute, h)); } for (int i = 0; i < nrows; i++) { AddParameter(ParameterGroup[i], i); } Controls.Add(grid); Name = "ParameterPanel"; Margin = new Padding(0, 3, 0, 3); grid.Dock = DockStyle.Fill; Dock = DockStyle.Fill; }
// PUT: odata/ParameterGroups(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <ParameterGroup> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ParameterGroup parameterGroup = await db.ParameterGroups.FindAsync(key); if (parameterGroup == null) { return(NotFound()); } patch.Put(parameterGroup); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParameterGroupExists(key)) { return(NotFound()); } else { throw; } } return(Updated(parameterGroup)); }
public static IReadOnlyCollection <IGroupDescriptor> ScanGroups(Type type, bool findParametersNotInGroups = true, bool recursively = true) { var groups = type.ReadFields <IGroupDescriptor>(null, recursively); var rootGroups = new LinkedList <IGroupDescriptor>(groups); foreach (var group in groups) { foreach (var parameterGroup in group.GetAllGroups(false)) { rootGroups.Remove(parameterGroup); } } if (!findParametersNotInGroups) { return(rootGroups.AsReadonly()); } var parameters = type.ReadFields <IParameterDescriptor>(null, recursively); var unusedParameters = new HashSet <IParameterDescriptor>(); foreach (var parameter in parameters) { unusedParameters.Add(parameter); } foreach (var parameter in rootGroups.GetAllParameters()) { unusedParameters.Remove(parameter); } var extraGroup = new ParameterGroup(null, null, unusedParameters.AsReadonly()); return(unusedParameters.Any() ? new List <IGroupDescriptor>(rootGroups) { extraGroup } : rootGroups.AsReadonly()); }
public void VerifyThatContainedGroupsReturnsGroupsThatAreContained() { var elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null); var parameterGroup_1 = new ParameterGroup(Guid.NewGuid(), null, null); elementDefinition.ParameterGroup.Add(parameterGroup_1); var parameterGroup_2 = new ParameterGroup(Guid.NewGuid(), null, null); elementDefinition.ParameterGroup.Add(parameterGroup_2); var parameterGroup_1_1 = new ParameterGroup(Guid.NewGuid(), null, null); elementDefinition.ParameterGroup.Add(parameterGroup_1_1); parameterGroup_1_1.ContainingGroup = parameterGroup_1; var parameterGroup_1_2 = new ParameterGroup(Guid.NewGuid(), null, null); elementDefinition.ParameterGroup.Add(parameterGroup_1_2); parameterGroup_1_2.ContainingGroup = parameterGroup_1; CollectionAssert.Contains(elementDefinition.ContainedGroup(), parameterGroup_1); CollectionAssert.Contains(elementDefinition.ContainedGroup(), parameterGroup_2); }
public void AddParameterGroup(GraphNode r, string pgName, ParameterGroup pg, int index) { float height = pg.parameters.Count * h; float h2 = h * 2; float locY; RectTransform pgui = Instantiate(ParameterGroupPrefab, transform).transform as RectTransform; if (ParameterGroups.Count > 0) { RectTransform lastpgui = ParameterGroups[ParameterGroups.Count - 1]; locY = lastpgui.anchoredPosition.y - lastpgui.sizeDelta.y; } else { locY = h2 * -1; } pgui.anchoredPosition = new Vector2(0, locY); Vector3 size = pgui.sizeDelta; size.y = pg.parameters.Count * h + h; pgui.sizeDelta = size; //dispaly name of the param group pgui.transform.Find("Title").GetComponent <Text>().text = pgName; //assign parameter extraction callback string key = pg.name; string extracName = pg.extractName; InputField extractNameIpf = pgui.transform.Find("InputField").GetComponent <InputField>(); if (pg.extractName != null && pg.extractName != "") { extractNameIpf.text = pg.extractName; } extractNameIpf.onEndEdit.AddListener( delegate { ExtractParamGroup(r, pg, extractNameIpf); }); ParameterGroups.Add(pgui); for (int i = 0; i < pg.parameters.Count; i++) { Parameter p = pg.parameters[i]; float value = p.Value; //Debug.Log("value=" + value); //GameObject o = new GameObject(); InputField ipf = Instantiate(inputFieldPrefab, pgui); RectTransform ipftrans = ipf.transform as RectTransform; ipftrans.anchoredPosition = new Vector2(0, -h * i - h); ipf.text = p.Value.ToString(); Slider sld = Instantiate(sliderPrefab, pgui); sld.value = p.Value; float min = p.min; float max = p.max; if (min > p.Value) { min = p.Value / 2; } if (max < p.Value) { max = p.Value * 2; } sld.minValue = min; sld.maxValue = max; if (p.step == 1) { sld.wholeNumbers = true; } ipf.onEndEdit.AddListener(delegate { OnIpfChanged(ipf, sld, p, r); }); sld.onValueChanged.AddListener(delegate { OnSliderValueChanged(sld, ipf, p, r); }); RectTransform sldtrans = sld.transform as RectTransform; sldtrans.anchoredPosition = new Vector2(30, -h * i - (h / 2)); inputFields.Add(ipf); sliders.Add(sld); } }
public void SetUp() { this.permissionService = new Mock <IPermissionService>(); this.obfuscationService = new Mock <IObfuscationService>(); this.session = new Mock <ISession>(); this.assembler = new Assembler(this.uri); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.option1 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = "1" }; this.option2 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = "2" }; this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); this.state2 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); this.posStateList.PossibleState.Add(this.state1); this.posStateList.PossibleState.Add(this.state2); this.posStateList.DefaultState = this.state1; this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }); this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state2 }, Kind = ActualFiniteStateKind.FORBIDDEN }); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "PTName", ShortName = "PTShortName" }; // Array parameter type with components this.apType = new ArrayParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); // compound parameter type with components this.cptType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain }; var engModel = new EngineeringModel(Guid.NewGuid(), null, null); var modelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null); var person = new Person(Guid.NewGuid(), null, null) { GivenName = "test", Surname = "test" }; var participant = new Participant(Guid.NewGuid(), null, null) { Person = person }; modelSetup.Participant.Add(participant); engModel.EngineeringModelSetup = modelSetup; this.session.Setup(x => x.ActivePerson).Returns(person); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration.Element.Add(this.elementDefinition); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); engModel.Iteration.Add(this.iteration); this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementDefinitionForUsage2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1.ElementDefinition = this.elementDefinitionForUsage1; this.elementUsage2.ElementDefinition = this.elementDefinitionForUsage2; this.parameterGroup1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup3 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup1ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup2ForUsage2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup3ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter2 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter3 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter4 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameterForStates = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain, StateDependence = this.stateList }; this.parameter5ForSubscription = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter6ForOverride = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter6Override = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = this.parameter6ForOverride, Owner = this.activeDomain }; this.parameterArray = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.apType, Owner = this.someotherDomain }; this.parameterCompound = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterCompoundForSubscription = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterSubscriptionCompound = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain }; this.parameterCompoundForSubscription.ParameterSubscription.Add(this.parameterSubscriptionCompound); this.parameterForOptions = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain, IsOptionDependent = true }; this.elementDefinition.ParameterGroup.Add(this.parameterGroup1); this.elementDefinition.ParameterGroup.Add(this.parameterGroup2); this.elementDefinition.ParameterGroup.Add(this.parameterGroup3); this.elementDefinitionForUsage2.ParameterGroup.Add(this.parameterGroup2ForUsage2); this.iteration.Element.Add(elementDefinitionForUsage1); this.iteration.Element.Add(elementDefinitionForUsage2); this.parameterGroup3.ContainingGroup = this.parameterGroup1; this.parameterGroup3ForUsage1.ContainingGroup = this.parameterGroup1ForUsage1; this.parameter4.Group = this.parameterGroup3; }
public static ArgumentCompleterOutput ToArgumentCompleterOutput(this ParameterGroup parameterGroup) => new ArgumentCompleterOutput(parameterGroup);
public void VerifyThatContextMenuIsPopulated() { var group = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.pt }; var def2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); var parameter2 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri); var usage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); var paramOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = parameter2 }; parameter2.ParameterType = this.pt; var usage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { ElementDefinition = def2 }; def2.Parameter.Add(parameter2); usage.ParameterOverride.Add(paramOverride); usage.ElementDefinition = def2; this.elementDef.Parameter.Add(parameter); this.elementDef.ParameterGroup.Add(group); this.elementDef.ContainedElement.Add(usage); this.elementDef.ContainedElement.Add(usage2); this.iteration.Element.Add(this.elementDef); this.iteration.Element.Add(def2); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); vm.PopulateContextMenu(); Assert.AreEqual(2, vm.ContextMenu.Count); var defRow = vm.ElementDefinitionRowViewModels.Last(); vm.SelectedThing = defRow; vm.PopulateContextMenu(); Assert.AreEqual(18, vm.ContextMenu.Count); vm.SelectedThing = defRow.ContainedRows[0]; vm.PopulateContextMenu(); Assert.AreEqual(12, vm.ContextMenu.Count); vm.SelectedThing = defRow.ContainedRows[1]; vm.PopulateContextMenu(); Assert.AreEqual(11, vm.ContextMenu.Count); var usageRow = defRow.ContainedRows[2]; var usage2Row = defRow.ContainedRows[3]; vm.SelectedThing = usageRow; vm.PopulateContextMenu(); Assert.AreEqual(8, vm.ContextMenu.Count); vm.SelectedThing = usageRow.ContainedRows.Single(); vm.PopulateContextMenu(); Assert.AreEqual(12, vm.ContextMenu.Count); vm.SelectedThing = usage2Row.ContainedRows.Single(); vm.PopulateContextMenu(); Assert.AreEqual(12, vm.ContextMenu.Count); vm.Dispose(); }
public void VerifyThatGroupAreAddedCorrectly() { var revisionProperty = typeof(ElementDefinition).GetProperty("RevisionNumber"); var group1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); var group11 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { ContainingGroup = group1 }; this.elementDef.ParameterGroup.Add(group1); this.elementDef.ParameterGroup.Add(group11); var vm = new ElementDefinitionRowViewModel(this.elementDef, this.option, this.session.Object, null); var group1row = vm.ContainedRows.OfType <ParameterGroupRowViewModel>().Single(); Assert.AreSame(group1, group1row.Thing); var group11row = group1row.ContainedRows.OfType <ParameterGroupRowViewModel>().Single(); Assert.AreSame(group11, group11row.Thing); // move group11 group11.ContainingGroup = null; revisionProperty.SetValue(group11, 10); CDPMessageBus.Current.SendObjectChangeEvent(group11, EventKind.Updated); Assert.AreEqual(2, vm.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); Assert.AreEqual(0, group1row.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); // move group11 under group1 group11.ContainingGroup = group1; revisionProperty.SetValue(group11, 20); CDPMessageBus.Current.SendObjectChangeEvent(group11, EventKind.Updated); Assert.AreEqual(1, vm.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); Assert.AreSame(group11, group1row.ContainedRows.OfType <ParameterGroupRowViewModel>().Single().Thing); // add group2 and move group11 under group2 var group2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); group11.ContainingGroup = group2; this.elementDef.ParameterGroup.Add(group2); revisionProperty.SetValue(group11, 30); revisionProperty.SetValue(this.elementDef, 30); CDPMessageBus.Current.SendObjectChangeEvent(this.elementDef, EventKind.Updated); CDPMessageBus.Current.SendObjectChangeEvent(group11, EventKind.Updated); Assert.AreEqual(2, vm.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); Assert.AreEqual(0, group1row.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); var group2row = vm.ContainedRows.OfType <ParameterGroupRowViewModel>().Single(x => x.Thing == group2); Assert.AreEqual(1, group2row.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); // remove group11 this.elementDef.ParameterGroup.Remove(group11); revisionProperty.SetValue(this.elementDef, 40); CDPMessageBus.Current.SendObjectChangeEvent(this.elementDef, EventKind.Updated); Assert.AreEqual(2, vm.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); Assert.AreEqual(0, group1row.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); Assert.AreEqual(0, group2row.ContainedRows.OfType <ParameterGroupRowViewModel>().Count()); }
public void VerifyThatRowsAreInsertedCorrectly() { var list = new ReactiveList <IRowViewModelBase <Thing> >(); var comparer = new ElementBaseChildRowComparer(); var parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.type, Owner = this.domain, Container = this.elementDef }; parameter1.ValueSet.Add(this.valueSet); var parameterRow1 = new ParameterRowViewModel(parameter1, this.session.Object, null, false); var typeClone = this.type.Clone(false); typeClone.Name = "b"; var paraClone = parameter1.Clone(false); paraClone.ParameterType = typeClone; var parameterRow2 = new ParameterRowViewModel(paraClone, this.session.Object, null, false) { Name = "b" }; var group1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "a" }; var groupRow1 = new ParameterGroupRowViewModel(group1, this.domain, this.session.Object, null); var group2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "b" }; var groupRow2 = new ParameterGroupRowViewModel(group2, this.domain, this.session.Object, null); var usage1 = this.elementUsage.Clone(false); usage1.Name = "def"; var usageRow1 = new ElementUsageRowViewModel(usage1, this.domain, this.session.Object, null); var usage2 = this.elementUsage.Clone(false); usage2.Name = "abc"; var usageRow2 = new ElementUsageRowViewModel(usage2, this.domain, this.session.Object, null); var usage3 = this.elementUsage.Clone(false); usage3.Name = "ghi"; var usageRow3 = new ElementUsageRowViewModel(usage3, this.domain, this.session.Object, null); list.SortedInsert(usageRow1, comparer); list.SortedInsert(usageRow3, comparer); list.SortedInsert(parameterRow1, comparer); list.SortedInsert(groupRow1, comparer); list.SortedInsert(parameterRow2, comparer); list.SortedInsert(groupRow2, comparer); list.SortedInsert(usageRow2, comparer); Assert.AreSame(parameterRow1, list[0]); Assert.AreSame(parameterRow2, list[1]); Assert.AreSame(groupRow1, list[2]); Assert.AreSame(groupRow2, list[3]); Assert.AreSame(usageRow2, list[4]); Assert.AreSame(usageRow1, list[5]); Assert.AreSame(usageRow3, list[6]); }
public void Init(ParameterGroup parameters1) { Init(parameters1, 200F, 1050); }
static void Main(string[] args) { DynetParams.FromArgs(args).Initialize(); // Alternatively, can initialize and it directly, e.g: // DynetParams dp = new DynetParams(); // dp.AutoBatch = true; // dp.MemDescriptor = "768"; // dp.Initialize(); const string EOS = "<EOS>"; List <string> characters = "abcdefghijklmnopqrstuvwxyz ".Select(c => c.ToString()).ToList(); characters.Add(EOS); // Lookup - dictionary Dictionary <string, int> c2i = Enumerable.Range(0, characters.Count).ToDictionary(i => characters[i], i => i); // Define the variables VOCAB_SIZE = characters.Count; LSTM_NUM_OF_LAYERS = 2; EMBEDDINGS_SIZE = 32; STATE_SIZE = 32; ATTENTION_SIZE = 32; // ParameterCollection (all the model parameters). ParameterCollection m = new ParameterCollection(); // A class defined locally used to contain all the parameters to transfer // them between functions and avoid global variables ParameterGroup pg = new ParameterGroup(); pg.c2i = c2i; pg.i2c = characters; pg.EOS = EOS; // LSTMs pg.enc_fwd_lstm = new LSTMBuilder(LSTM_NUM_OF_LAYERS, EMBEDDINGS_SIZE, STATE_SIZE, m); pg.enc_bwd_lstm = new LSTMBuilder(LSTM_NUM_OF_LAYERS, EMBEDDINGS_SIZE, STATE_SIZE, m); pg.dec_lstm = new LSTMBuilder(LSTM_NUM_OF_LAYERS, STATE_SIZE * 2 + EMBEDDINGS_SIZE, STATE_SIZE, m); // Create the parameters pg.input_lookup = m.AddLookupParameters(VOCAB_SIZE, new[] { EMBEDDINGS_SIZE }); pg.attention_w1 = m.AddParameters(new[] { ATTENTION_SIZE, STATE_SIZE * 2 }); pg.attention_w2 = m.AddParameters(new[] { ATTENTION_SIZE, STATE_SIZE * 2 * LSTM_NUM_OF_LAYERS }); pg.attention_v = m.AddParameters(new[] { 1, ATTENTION_SIZE }); pg.decoder_W = m.AddParameters(new[] { VOCAB_SIZE, STATE_SIZE }); pg.decoder_b = m.AddParameters(new[] { VOCAB_SIZE }); pg.output_lookup = m.AddLookupParameters(VOCAB_SIZE, new[] { EMBEDDINGS_SIZE }); Trainer trainer = new SimpleSGDTrainer(m); // For good practice, renew the computation graph dy.RenewCG(); // Train string trainSentence = "it is working"; // Run 600 epochs for (int iEpoch = 0; iEpoch < 600; iEpoch++) { // Loss Expression loss = CalculateLoss(trainSentence, trainSentence, pg); // Forward, backward, update float lossValue = loss.ScalarValue(); loss.Backward(); trainer.Update(); if (iEpoch % 20 == 0) { Console.WriteLine(lossValue); Console.WriteLine(GenerateSentence(trainSentence, pg)); } }// next epoch }
private static Expression CalculateLoss(string inputSentence, string outputSentence, ParameterGroup pg) { dy.RenewCG(); // Embed, encode, and decode List <Expression> embeds = EmbedSentence(inputSentence, pg); List <Expression> encodings = EncodeSentence(embeds, pg); return(DecodeSentence(encodings, outputSentence, pg)); }
private static Expression Attend(Expression inputMat, Expression w1dt, RNNState decState, ParameterGroup pg) { // We have w1dt which is Attention x len(seq) // Now, concate the hidden layers from the decoder and multiply that by w2 // will give us 1xAttention Expression w2dt = pg.attention_w2 * dy.concatenate(decState.GetS()); // Add that to each column, run through an activation layer, and those are our // "energies" (we have to transpose in order to get the vector dimensions) Expression unnormalized = dy.transpose(pg.attention_v * dy.tanh(dy.colwise_add(w1dt, w2dt))); Expression attentionWeights = dy.softmax(unnormalized); // Apply the weights and return the new weighted ci return(inputMat * attentionWeights); }
private static IEnumerable<Method> GetMethodsUsingParameterGroup(IEnumerable<Method> methods, ParameterGroup parameterGroup) { return methods.Where(m => ExtractParameterGroupNames(m).Contains(parameterGroup.Name)); }
//[TestMethod] //public void ProductBlockSelectorPreSelectedPart() //{ // ProductBlockSelector productBlockSelector = new ProductBlockSelector(_parameters, selectedProductBlock: _preSelectedProductBlock); // Assert.AreEqual(_preSelectedProductBlock, productBlockSelector.SelectedProductBlock); // Assert.IsTrue(_preSelectedProductBlock.Parameters.AllMembersAreSame(productBlockSelector.SelectedProductBlock.Parameters)); //} //[TestMethod] //public void ProductBlockSelectorActualParameters() //{ // ProductBlockSelector productBlockSelector = new ProductBlockSelector(_parameters, selectedProductBlock: _preSelectedProductBlock); // //находим селектор с токами // var currentSelector = GetParameterSelector(productBlockSelector, _current); // //актуален только параметр с током 3150 // Assert.IsTrue(currentSelector.ParametersFlaged.Where(x => x.IsActual).Select(x => x.Parameter).AllMembersAreSame(new[] { _c3150 })); // //находим селектор с напряженями // var voltageSelector = GetParameterSelector(productBlockSelector, _voltage); // //актуалены все напряжения // Assert.IsTrue(voltageSelector.ParametersFlaged.Where(x => x.IsActual).Select(x => x.Parameter).AllMembersAreSame(_parameters.Where(x => x.ParameterGroup.Equals(_voltage)))); //} //когда прилетают неупорядоченные группы параметров //[TestMethod] //public void ProductBlockSelectorDefaultProductNotOrderedParameters() //{ // var eqType = new List<Parameter> {_breaker, _transformator}; // var voltage = new List<Parameter> {_v110, _v220}; // var current = new List<Parameter> {_c0005, _c2500 }; // var parametersList = new List<List<Parameter>> {current, voltage, eqType}; // var parameters = new List<Parameter> { _breaker, _v110, _c2500 }; // var productBlockSelector = new ProductBlockSelector(_parameters); // Assert.IsTrue(productBlockSelector.ParameterSelectors.Select(x => x.SelectedParameterFlaged.Parameter).AllMembersAreSame(parameters)); // Assert.IsTrue(productBlockSelector.SelectedProductBlock.Parameters.AllMembersAreSame(parameters)); // //проверяем верна ли последовательность // for (int i = 0; i < parametersList.Count; i++) // { // Assert.AreEqual(parameters[i], productBlockSelector.SelectedProductBlock.Parameters.ToList()[i]); // } //} private ParameterSelector GetParameterSelector(ProductBlockSelector productBlockSelector, ParameterGroup group) { return(productBlockSelector.ParameterSelectors.Single(x => x.ParametersFlaged.Select(p => p.Parameter).All(p => Equals(p.ParameterGroup, group)))); }
public static Dictionary <string, uint> CreateSessionConfigurationForMultipleParameter( IClientSession clientSession, IEnumerable <string> identifiers) { var channels = new Dictionary <string, uint>(); const string ConversionFunctionName = "CONV_MyParam:MyApp"; const string ApplicationGroupName = "MyApp"; const string ParameterGroupIdentifier = "MyParamGroup"; const string ParameterName = "MyParam"; var session = clientSession.Session; var config = session.CreateConfiguration(); var group1 = new ParameterGroup(ParameterGroupIdentifier, "pg1_description"); var applicationGroup1 = new ApplicationGroup( ApplicationGroupName, ApplicationGroupName, new List <string> { group1.Identifier }) { SupportsRda = false }; config.AddGroup(applicationGroup1); config.AddParameterGroup(group1); config.AddConversion( new RationalConversion(ConversionFunctionName, "kph", "%5.2f", 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)); var vCarFrequency = new Frequency(2, FrequencyUnit.Hz); uint channelId = 1; foreach (var identifier in identifiers) { channels[identifier] = channelId; var channel = new Channel( channelId++, "Channel" + channelId, vCarFrequency.ToInterval(), DataType.Signed16Bit, ChannelDataSourceType.Periodic); var parameter = new Parameter( identifier, identifier, identifier, 400, //vCar maximum value 0, //vCar minimum value 1, 0, 0, 255, 0, ConversionFunctionName, new List <string> { ParameterGroupIdentifier }, channel.Id, ApplicationGroupName); config.AddChannel(channel); config.AddParameter(parameter); } config.Commit(); return(channels); }
public void SetUp() { this.permissionService = new Mock <IPermissionService>(); this.thingDialognavigationService = new Mock <IThingDialogNavigationService>(); this.thingCreator = new Mock <IThingCreator>(); this.obfuscationService = new Mock <IObfuscationService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.serviceLocator = new Mock <IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IThingCreator>()) .Returns(this.thingCreator.Object); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { RequiredRdl = this.srdl }; this.modelsetup.RequiredRdl.Add(this.mrdl); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.sitedir.Model.Add(this.modelsetup); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.option1 = new Option(Guid.NewGuid(), this.cache, this.uri); this.option2 = new Option(Guid.NewGuid(), this.cache, this.uri); this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.state2 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.posStateList.PossibleState.Add(this.state1); this.posStateList.PossibleState.Add(this.state2); this.posStateList.DefaultState = this.state1; this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }); this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state2 }, Kind = ActualFiniteStateKind.FORBIDDEN }); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.session = new Mock <ISession>(); this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "PTName", ShortName = "PTShortName" }; // Array parameter type with components this.apType = new ArrayParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); // compound parameter type with components this.cptType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.activeDomain }; this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri) { IterationSetup = this.iterationsetup }; var person = new Person(Guid.NewGuid(), null, null) { GivenName = "test", Surname = "test" }; var participant = new Participant(Guid.NewGuid(), null, null) { Person = person, SelectedDomain = this.activeDomain }; this.session.Setup(x => x.ActivePerson).Returns(person); this.modelsetup.Participant.Add(participant); this.model.Iteration.Add(this.iteration); this.iteration.Element.Add(this.elementDefinition); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementDefinitionForUsage2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1.ElementDefinition = this.elementDefinitionForUsage1; this.elementUsage2.ElementDefinition = this.elementDefinitionForUsage2; this.parameterGroup1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup3 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup1ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup2ForUsage2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup3ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter3 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter4 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameterForStates = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain, StateDependence = this.stateList }; this.parameter5ForSubscription = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter6ForOverride = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter6Override = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = this.parameter6ForOverride, Owner = this.activeDomain }; this.parameterArray = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.apType, Owner = this.someotherDomain }; this.parameterCompound = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterCompoundForSubscription = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterSubscriptionCompound = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri) { Owner = this.activeDomain }; this.parameterCompoundForSubscription.ParameterSubscription.Add(this.parameterSubscriptionCompound); this.parameterForOptions = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain, IsOptionDependent = true }; this.elementDefinition.ParameterGroup.Add(this.parameterGroup1); this.elementDefinition.ParameterGroup.Add(this.parameterGroup2); this.elementDefinition.ParameterGroup.Add(this.parameterGroup3); this.elementDefinitionForUsage1.ParameterGroup.Add(this.parameterGroup1ForUsage1); this.elementDefinitionForUsage2.ParameterGroup.Add(this.parameterGroup2ForUsage2); this.elementDefinitionForUsage1.ParameterGroup.Add(this.parameterGroup3ForUsage1); this.iteration.Element.Add(elementDefinitionForUsage1); this.iteration.Element.Add(elementDefinitionForUsage2); this.parameterGroup3.ContainingGroup = this.parameterGroup1; this.parameterGroup3ForUsage1.ContainingGroup = this.parameterGroup1ForUsage1; this.parameter4.Group = this.parameterGroup3; this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); }
public static Parameter CreateTransientConfigurationForOneParameter(Session session) { const string ConversionFunctionName = "CONV_MyParam:MyApp"; const string ApplicationGroupName = "MyApp"; const string ParameterGroupIdentifier = "MyParamGroup"; const string ParameterName = "MyParam"; const uint MyParamChannelId = 999999; //must be unique const int ApplicationId = 999; var parameterIdentifier = $"{ParameterName}:{ApplicationGroupName}"; var transientConfigSet = session.CreateTransientConfiguration(); var parameterGroup = new ParameterGroup(ParameterGroupIdentifier, "some description!"); transientConfigSet.AddParameterGroup(parameterGroup); var applicationGroup = new ApplicationGroup( ApplicationGroupName, ApplicationGroupName + "App Group Desc!!", ApplicationId, new List <string> { parameterGroup.Identifier }); transientConfigSet.AddGroup(applicationGroup); var conversion = RationalConversion.CreateSimple1To1Conversion(ConversionFunctionName, "myunit", "%5.2f"); transientConfigSet.AddConversion(conversion); var paramFrequency = new Frequency(2, FrequencyUnit.Hz); var paramChannel = new Channel( MyParamChannelId, "MyParamChannel", paramFrequency.ToInterval(), DataType.Double64Bit, ChannelDataSourceType.Periodic, string.Empty, true); transientConfigSet.AddChannel(paramChannel); var myParameter = new Parameter( parameterIdentifier, ParameterName, ParameterName + "Description", 400, //maximum value 0, //minimum value 1, 0, 0, 255, 0, ConversionFunctionName, new List <string> { ParameterGroupIdentifier }, paramChannel.Id, ApplicationGroupName); transientConfigSet.AddParameter(myParameter); transientConfigSet.Commit(); return(myParameter); }
internal NorthwindCdkStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props) { var vpc = new Vpc(this, "LabVpc", new VpcProps { MaxAzs = 2 }); // SQL Server var sg = new SecurityGroup(this, "NorthwindDatabaseSecurityGroup", new SecurityGroupProps { Vpc = vpc, SecurityGroupName = "Northwind-DB-SG", AllowAllOutbound = false }); // !!!!!!!!!! replace IP according to the instructions above sg.AddIngressRule(Peer.Ipv4("35.171.193.180/32"), Port.Tcp(1433)); // SQL Server // !!!!!!!!!! var sql = new DatabaseInstance(this, "NorthwindSQLServer", new DatabaseInstanceProps { Vpc = vpc, InstanceIdentifier = "northwind-sqlserver", Engine = DatabaseInstanceEngine.SqlServerEx(new SqlServerExInstanceEngineProps { Version = SqlServerEngineVersion.VER_14 }), // SQL Server Express Credentials = Credentials.FromUsername("adminuser", new CredentialsFromUsernameOptions() { Password = new SecretValue("Admin12345?") }), //MasterUsername = "******", //MasterUserPassword = new SecretValue("Admin12345?"), InstanceType = InstanceType.Of(InstanceClass.BURSTABLE3, InstanceSize.SMALL), // t3.small SecurityGroups = new ISecurityGroup[] { sg }, MultiAz = false, VpcSubnets = new SubnetSelection() { SubnetType = SubnetType.PUBLIC }, // public subnet DeletionProtection = false, // you need to be able to delete database DeleteAutomatedBackups = true, BackupRetention = Duration.Days(0), RemovalPolicy = RemovalPolicy.DESTROY // you need to be able to delete database });; new CfnOutput(this, "SQLServerEndpointAddress", new CfnOutputProps { Value = sql.DbInstanceEndpointAddress }); // SQL Server connection string in Systems Manager Parameter Store new StringParameter(this, "NorthwindDatabaseConnectionString", new StringParameterProps { ParameterName = "/Northwind/ConnectionStrings/NorthwindDatabase", Type = ParameterType.STRING, Description = "SQL Server connection string", StringValue = string.Format("Server={0},1433;Integrated Security=false;User ID=adminuser;Password=Admin12345?;Initial Catalog=NorthwindTraders;", sql.DbInstanceEndpointAddress) }); // PostgreSQL setup // !!!!!!!!!! add 2 rules when you use provided VM, add 1 rule when you use your computer sg.AddIngressRule(Peer.Ipv4("35.171.193.180/32"), Port.Tcp(5432)); // PostgreSQL sg.AddIngressRule(Peer.Ipv4("3.238.53.13/32"), Port.Tcp(5432)); // PostgreSQL // !!!!!!!!!! var postgreSql = new DatabaseCluster(this, "NorthwindPostgreSQL", new DatabaseClusterProps { InstanceProps = new Amazon.CDK.AWS.RDS.InstanceProps { Vpc = vpc, InstanceType = InstanceType.Of(InstanceClass.BURSTABLE3, InstanceSize.MEDIUM), // t3.medium SecurityGroups = new ISecurityGroup[] { sg }, VpcSubnets = new SubnetSelection() { SubnetType = SubnetType.PUBLIC }, // you need to access database from your developer PC ParameterGroup = ParameterGroup.FromParameterGroupName(this, "DBInstanceParameterGroup", "default.aurora-postgresql11"), }, ParameterGroup = ParameterGroup.FromParameterGroupName(this, "DBClusterParameterGroup", "default.aurora-postgresql11"), ClusterIdentifier = "northwind-postgresql", Engine = DatabaseClusterEngine.AuroraPostgres(new AuroraPostgresClusterEngineProps { Version = AuroraPostgresEngineVersion.VER_11_6 }), // Aurora PostgreSQL Credentials = Credentials.FromUsername("adminuser", new CredentialsFromUsernameOptions { Password = new SecretValue("Admin12345?") }), //MasterUser = new Login //{ // Username = "******", // Password = new SecretValue("Admin12345?") //}, Instances = 1, Port = 5432, Backup = new BackupProps { Retention = Duration.Days(1) // minimum is 1 }, DefaultDatabaseName = "NorthwindTraders", InstanceIdentifierBase = "northwind-postgresql-instance", RemovalPolicy = RemovalPolicy.DESTROY // you need to be able to delete database, });; new CfnOutput(this, "PostgreSQLEndpointAddress", new CfnOutputProps { Value = postgreSql.ClusterEndpoint.Hostname }); // Aurora PostgreSQL connection string in Systems Manager Parameter Store new StringParameter(this, "NorthwindPostgreSQLDatabaseConnectionString", new StringParameterProps { ParameterName = "/Northwind/ConnectionStrings/NorthwindPostgreDatabase", Type = ParameterType.STRING, Description = "PostgreSQL connection string", StringValue = string.Format("Server={0};Database=NorthwindTraders;Username=adminuser;Password=Admin12345?", postgreSql.ClusterEndpoint.Hostname) }); }
public static Parameter CreateSessionConfigurationForOneParameter(Session session) { const string ConversionFunctionName = "CONV_MyParam:MyApp"; const string ApplicationGroupName = "MyApp"; const string ParameterGroupIdentifier = "MyParamGroup"; const string ParameterName = "MyParam"; const uint MyParamChannelId = 999998; //must be unique const int ApplicationId = 998; var parameterIdentifier = $"{ParameterName}:{ApplicationGroupName}"; var config = session.CreateConfiguration(); var group1 = new ParameterGroup(ParameterGroupIdentifier, "pg1_description"); var applicationGroup1 = new ApplicationGroup( ApplicationGroupName, ApplicationGroupName, ApplicationId, new List <string> { group1.Identifier }) { SupportsRda = false }; config.AddGroup(applicationGroup1); config.AddParameterGroup(group1); config.AddConversion( new RationalConversion(ConversionFunctionName, "kph", "%5.2f", 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)); var myParamFrequency = new Frequency(2, FrequencyUnit.Hz); var myParameterChannel = new Channel( MyParamChannelId, "MyParamChannel", myParamFrequency.ToInterval(), DataType.Double64Bit, ChannelDataSourceType.Periodic); var myParameter = new Parameter( parameterIdentifier, ParameterName, ParameterName + "Description", 400, 0, 1, 0, 0, 255, 0, ConversionFunctionName, new List <string> { ParameterGroupIdentifier }, myParameterChannel.Id, ApplicationGroupName); config.AddChannel(myParameterChannel); config.AddParameter(myParameter); config.Commit(); return(myParameter); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterGroupDialogViewModel"/> class /// </summary> /// <param name="parameterGroup"> /// The <see cref="ParameterGroup"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="permissionService"> /// The <see cref="IPermissionService"/> that is used to compute whether the current <see cref="ISession"/> can execute CRUD. /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container">The Container <see cref="Thing"/> of the created <see cref="MultiRelationshipRule"/></param> /// <param name="isNewContainer"> /// Value indicating whether the container of the <see cref="Thing"/> that is being created is new /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ParameterGroupDialogViewModel(ParameterGroup parameterGroup, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(parameterGroup, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.SelectedGroupSelection).Subscribe(x => this.SelectedContainingGroup = x != null ? x.Thing : null); }
public void VerifyThatParameterGroupsAreAcyclic() { var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Name = "ElemDef", ShortName = "ED" }; this.testIteration.Element.Add(elementDefinition); var pg1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "1" }; elementDefinition.ParameterGroup.Add(pg1); var pg2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "2", ContainingGroup = pg1 }; elementDefinition.ParameterGroup.Add(pg2); var pg3 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "3", ContainingGroup = pg2 }; elementDefinition.ParameterGroup.Add(pg3); var pg4 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "4", ContainingGroup = pg3 }; elementDefinition.ParameterGroup.Add(pg4); var pg5 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "5" }; elementDefinition.ParameterGroup.Add(pg5); var pg6 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "6", ContainingGroup = pg5 }; elementDefinition.ParameterGroup.Add(pg6); this.cache.TryAdd(new CacheKey(elementDefinition.Iid, this.testIteration.Iid), new Lazy <Thing>(() => elementDefinition)); var clone = elementDefinition.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.testIteration); this.transaction = new ThingTransaction(transactionContext, clone); var vm1 = new ParameterGroupDialogViewModel(pg1, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, clone); Assert.AreEqual(2, vm1.PossibleGroups.Count); var vm2 = new ParameterGroupDialogViewModel(pg2, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, clone); Assert.AreEqual(3, vm2.PossibleGroups.Count); var vm3 = new ParameterGroupDialogViewModel(pg3, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, clone); Assert.AreEqual(4, vm3.PossibleGroups.Count); }
private void BuildModelData() { this.model1 = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); this.model2 = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration1 = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration2 = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.rootDef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "rootdef" }; this.def1 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "def1" }; this.def2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "def2" }; this.usage1 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage11 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage21 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage22 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri); this.override1 = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri); this.subscription1 = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri); this.group1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.group2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.model1.EngineeringModelSetup = this.modelsetup1; this.model2.EngineeringModelSetup = this.modelsetup2; this.iteration1.IterationSetup = this.iterationSetup1; this.iteration2.IterationSetup = this.iterationSetup2; this.rootDef.Owner = this.domain1; this.def1.Owner = this.domain1; this.def2.Owner = this.domain2; this.usage1.Owner = this.domain1; this.usage1.ElementDefinition = this.def1; this.usage11.Owner = this.domain1; this.usage11.ElementDefinition = this.def1; this.usage2.Owner = this.domain1; this.usage2.ElementDefinition = this.def2; this.usage22.Owner = this.domain1; this.usage22.ElementDefinition = this.def2; this.usage21.Owner = this.domain1; this.usage21.ElementDefinition = this.def2; this.parameter1.Owner = this.domain2; this.parameter1.ParameterType = this.booleanPt; this.parameter1.AllowDifferentOwnerOfOverride = true; this.override1.Parameter = this.parameter1; this.override1.Owner = this.domain2; this.subscription1.Owner = this.domain1; this.group2.ContainingGroup = this.group1; this.parameter1.Group = this.group2; this.model1.Iteration.Add(this.iteration1); this.iteration1.Element.Add(this.def1); this.iteration1.Element.Add(this.def2); this.iteration1.Element.Add(this.rootDef); this.rootDef.ContainedElement.Add(this.usage1); this.rootDef.ContainedElement.Add(this.usage11); this.def1.ContainedElement.Add(this.usage2); this.def1.ContainedElement.Add(this.usage22); this.def1.ContainedElement.Add(this.usage21); this.def2.Parameter.Add(this.parameter1); this.def2.ParameterGroup.Add(this.group1); this.def2.ParameterGroup.Add(this.group2); this.usage1.ParameterOverride.Add(this.override1); this.override1.ParameterSubscription.Add(this.subscription1); this.model2.Iteration.Add(this.iteration2); }
private static IEnumerable <Method> GetMethodsUsingParameterGroup(IEnumerable <Method> methods, ParameterGroup parameterGroup) { return(methods.Where(m => ExtractParameterGroupNames(m).Contains(parameterGroup.Name))); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterGroupRowViewModel"/> class /// </summary> /// <param name="parameterGroup">The <see cref="ParameterGroup"/> associated with this row</param> /// <param name="session">The session</param> /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param> public ParameterGroupRowViewModel(ParameterGroup parameterGroup, ISession session, IViewModelBase <Thing> containerViewModel) : base(parameterGroup, session, containerViewModel) { this.currentGroup = this.Thing.ContainingGroup; this.UpdateProperties(); }
public IParameterGroup LocateParameterGroupByName(string identification, string parameterGroupName) { return(ParameterGroup.FromParameterGroupName(Scope, identification, parameterGroupName)); }
public static bool IsComplectDesignationGroup(this ParameterGroup parameterGroup) { return(GlobalAppProperties.Actual.ComplectDesignationGroup.Id == parameterGroup.Id); }
//=================================================================== //=================================================================== public void LoadConfigurationFile() { string folderPath = FileOperations.GetApplicationDirectory(); string parameterFilePath = folderPath + configFileName; //uiText.GetComponent<UnityEngine.UI.Text>().text = parameterFilePath; ParameterGroup configFile = new ParameterGroup(parameterFilePath); // Project projectNotes = configFile.getString("Notes"); // Container containerType = configFile.getEnum <ContainerType>("Container Type"); ContainerScale = configFile.getVector3("Container Scale"); containerDynamicFriction = configFile.getFloat("Container Dynamic Friction"); containerStaticFriction = configFile.getFloat("Container Static Friction"); containerBounciness = configFile.getFloat("Container Bounciness"); modifyScaleAutomatically = configFile.getBoolean("Modify Scale Automatically"); bufferLength = configFile.getFloat("Buffer Length"); estimatedPorosity = configFile.getFloat("Estimated Porosity"); // Simulation FixedDeltaTime = configFile.getFloat("Fixed Delta Time"); SolverIterationCount = configFile.getInteger("Solver Iteration Count"); velocitySolverIterationCount = configFile.getInteger("Velocity Solver Iteration Count"); SleepThreshold = configFile.getFloat("Sleep Threshold"); BounceThreshold = configFile.getFloat("Bounce Threashold"); TimeScale = configFile.getFloat("Time Scale"); TargetFrameRate = configFile.getInteger("Target Frame Rate"); contactOffset = configFile.getFloat("Contact Offset"); // Shaking shakeTransversly = configFile.getBoolean("Shake Transversly"); shakeRotationaly = configFile.getBoolean("Shake Rotationally"); stabilizeCamera = configFile.getBoolean("Stabilize Camera"); ShakingFraction = configFile.getFloat("Shaking Fracton"); ShakingRotationFraction = configFile.getFloat("Shaking Roation Fraction"); // Folder projectFolderPath = configFile.getString("Project Folder Path"); pdfFolderName = configFile.getString("PDF Folder Name"); saveFolderName = configFile.getString("Save Folder Name"); createNewFolderAutomatically = configFile.getBoolean("Create New Folder Automatically"); overrideOutputFolder = configFile.getBoolean("Override Output Folder"); // Particle Groups useVolumeProportion = configFile.getBoolean("Use Volume Proportion"); grainCountGoal = configFile.getInteger("Grain Count Goal"); int nbeds = configFile.getInteger("Number of Beds"); beds = new Bed[nbeds]; for (int bedNumber = 0; bedNumber < nbeds; bedNumber++) { int bedNumberOne = bedNumber + 1; beds[bedNumber] = new Bed(); beds[bedNumber].bedName = configFile.getString("Bed " + bedNumberOne + " Name"); beds[bedNumber].proportion = configFile.getFloat("Bed " + bedNumberOne + " Proportion"); beds[bedNumber].waitAfterDepostion = configFile.getInteger("Bed " + bedNumberOne + " Wait After Deposition"); beds[bedNumber].cementAfterDeposition = configFile.getBoolean("Bed " + bedNumberOne + " Cement After Deposition"); beds[bedNumber].disappearAfterDeposition = configFile.getBoolean("Bed " + bedNumberOne + " Disappear After Deposition"); int nGrainGroups = configFile.getInteger("Bed " + bedNumberOne + " Number of Grains"); if (nGrainGroups > 0) { Grain[] grains = new Grain[nGrainGroups]; for (int grainGroupNumber = 0; grainGroupNumber < nGrainGroups; grainGroupNumber++) { int grainGroupNumberOne = grainGroupNumber + 1; grains[grainGroupNumber] = new Grain(); grains[grainGroupNumber].grainName = configFile.getString("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Name"); grains[grainGroupNumber].Type = configFile.getEnum <Grain.GrainType>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Type"); grains[grainGroupNumber].parameters = configFile.getString("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Parameters"); grains[grainGroupNumber].PDF = configFile.getString("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " PDF"); grains[grainGroupNumber].PDFMultiplier = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " PDF Multiplier"); grains[grainGroupNumber].PDFOffset = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " PDF Offset"); grains[grainGroupNumber].density = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Density"); grains[grainGroupNumber].exactVerticalCreation = configFile.getBoolean("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Disappear At Bottom"); grains[grainGroupNumber].disappearAtBottom = configFile.getBoolean("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Exact Vertical Creation"); grains[grainGroupNumber].proportion = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Proportion"); grains[grainGroupNumber].depostionType = configFile.getEnum <Grain.DepostionType>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Deposition Type"); grains[grainGroupNumber].dynamicFriction = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Dynamic Friction"); grains[grainGroupNumber].staticFriction = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Static Friction"); grains[grainGroupNumber].bounciness = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Bounciness"); grains[grainGroupNumber].frictionCombine = configFile.getEnum <PhysicMaterialCombine>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Friction Combine"); grains[grainGroupNumber].bounceCombine = configFile.getEnum <PhysicMaterialCombine>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Bounce Combine"); grains[grainGroupNumber].colorType = configFile.getEnum <Grain.GrainColorType>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Color Type"); grains[grainGroupNumber].baseColor = configFile.getColor("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Base Color"); grains[grainGroupNumber].secondaryColor = configFile.getColor("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Secondary Color"); grains[grainGroupNumber].scale = configFile.getVector3("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Scale"); } beds[bedNumber].grains = grains; } } // Deposition automaticDepostion = configFile.getBoolean("Automatic Deposition"); depostionRatePerSec = configFile.getFloat("Deposition Rate Per Sec"); // Saving saveRockAutomatically = configFile.getBoolean("Save Rock Automatically"); saveDataFile = configFile.getBoolean("Save Data File"); saveRockFile = configFile.getBoolean("Save Rock File"); saveGrainsFile = configFile.getBoolean("Save Grains File"); exitAutomatically = configFile.getBoolean("Exit Automatically"); }
public static DefaultInfoOutput ToDefaultInfoOutput(this ParameterGroup parameterGroup) => new DefaultInfoOutput(parameterGroup);
static void Main(string[] args) { var group = new ParameterGroup(typeof(DataFolder), typeof(FileCount), typeof(HeaderCount), typeof(DataRowCount)); }