public void PrintSubDataType(int indnt, StreamWriter writer, IBoolean s) { if (s != null) { indent(indnt, writer); writer.Write("<IBoolean/>\n"); } }
public sdwSSA(ModelInfo modelinfo, double duration, int repeats, int samples) : base(modelinfo, duration, repeats, samples) { Configuration config = Configuration.CurrentConfiguration; _reactions = new StateDependentReactionSet(model.Reactions, _gammaSize); _trajectoryCounter = 0; _runningMean = 0.0; _runningVariance = 0.0; _crossEntropyRuns = config.GetParameterWithDefault("sdwSSA.crossEntropyRuns", 100000); _crossEntropyThreshold = config.GetParameterWithDefault("sdwSSA.crossEntropyThreshold", 0.01); _crossEntropyMinDataSize = config.GetParameterWithDefault("sdwSSA.crossEntropyMinDataSize", 200); _reExpressionName = config.GetParameterWithDefault("sdwSSA.reExpressionName", "reExpression"); _reValName = config.GetParameterWithDefault("sdwSSA.reValName", "reVal"); _gammaSize = config.GetParameterWithDefault("sdwSSA.gammaSize", 15); _binCountThreshold = config.GetParameterWithDefault("sdwSSA.binCount", 20); _reExpression = model.Expressions.FirstOrDefault(e => e.Name == _reExpressionName); _rareEventValue = 0.0; _rareEventTest = new EqualTo(_reExpression, new ConstantValue(_rareEventValue)); _gamma = new List <double[]>(); _propensityCutoff = new List <double[]>(); _gammaIndex = new int[_reactions.NumReactions]; _binIndex = new int[_reactions.NumReactions]; _biasingParametersFileName = config.GetParameterWithDefault("sdwSSA.biasingParametersFileName", modelinfo.Name + "_biasingParameters.json"); _biasingParametersFlag = (String.CompareOrdinal(_biasingParametersFileName, modelinfo.Name + "_biasingParameters.json") == 0); _biasingParameters = _biasingParametersFlag ? new BiasingParameters() : BiasingParametersDeserializer.ReadParametersFromJsonFile(_biasingParametersFileName); _outputFileName = config.GetParameterWithDefault("sdwSSA.outputFileName", modelInfo.Name + "_sdwSSA_1e" + Math.Log(SamplingParams.RealizationCount, 10) + ".txt"); }
protected BinaryBooleanOp(IBooleanOperator firstArgument, IBooleanOperator secondArgument) { _operatorA = firstArgument; _operatorB = secondArgument; ArgumentA = null; ArgumentB = null; }
public IBoolean ResolveReferences(IDictionary <string, IBoolean> bmap, IDictionary <string, IValue> nmap) { if (Argument == null) { Argument = _argument.ResolveReferences(bmap, nmap); } return(GetValue()); }
public void GreaterThanTest() { IBoolean greaterThanTrue = (new GreaterThanOperator(_twentyTwo, _twenty)).ResolveReferences(null, null); IBoolean greaterThanFalse = (new GreaterThanOperator(_twenty, _twentyTwo)).ResolveReferences(null, null); Console.WriteLine("Testing GreaterThan() expressions..."); Console.WriteLine(); Expect(greaterThanTrue.Value); Expect(!greaterThanFalse.Value); }
public BooleanStatementBuilder Or(IBoolean statement) { if (Component == null) { Component = statement; } else { Component = new OrStatement(Component, statement.Wrap()); } return(this); }
public void NotEqualToTest() { IBoolean notEqualTo1 = (new NotEqualToOperator(_twenty, _twenty)).ResolveReferences(null, null); IBoolean notEqualTo2 = (new NotEqualToOperator(_twenty, _twentyTwo)).ResolveReferences(null, null); IBoolean notEqualTo3 = (new NotEqualToOperator(_twentyTwo, _twenty)).ResolveReferences(null, null); Console.WriteLine("Testing NotEqualTo() expressions..."); Console.WriteLine(); Expect(!notEqualTo1.Value); Expect(notEqualTo2.Value); Expect(notEqualTo3.Value); }
public void GreaterThanOrEqualTest() { IBoolean greaterThanOrEqual1 = (new GreaterThanOrEqualOperator(_twenty, _twenty)).ResolveReferences(null, null); IBoolean greaterThanOrEqual2 = (new GreaterThanOrEqualOperator(_twenty, _twentyTwo)).ResolveReferences(null, null); IBoolean greaterThanOrEqual3 = (new GreaterThanOrEqualOperator(_twentyTwo, _twenty)).ResolveReferences(null, null); Console.WriteLine("Testing GreaterThanOrEqual() expressions..."); Console.WriteLine(); Expect(greaterThanOrEqual1.Value); Expect(!greaterThanOrEqual2.Value); Expect(greaterThanOrEqual3.Value); }
public void Initialize() { CheckParameters(); _rareEventValue = model.Parameters.First(p => p.Name == _reValName).Value; _rareEventTest = new EqualTo(_reExpression, new ConstantValue(_rareEventValue)); SetRareEventType(); if (!Configuration.CurrentConfiguration.HasParameter("dwSSA.gamma")) { Console.WriteLine("Biasing parameters not found. Starting multilevel cross entropy simulation with " + _crossEntropyRuns + " realizations..."); RunCrossEntropy(); } }
public IBoolean ResolveReferences(IDictionary <string, IBoolean> bmap, IDictionary <string, IValue> nmap) { if (_value == null) { _value = _rootOperator.ResolveReferences(bmap, nmap); if (_name != null) { bmap.Add(_name, _value); } } return(_value); }
public IBoolean[] Provide() { IBoolean[] booleans = new IBoolean[this._booleans.Length + this._conditions.Length]; int a = 0; this._booleans.CopyTo(booleans, a); a += this._booleans.Length; this._conditions.CopyTo(booleans, a); a += this._conditions.Length; return(booleans); }
public IBoolean ResolveReferences(IDictionary <string, IBoolean> bmap, IDictionary <string, IValue> nmap) { if (ArgumentA == null) { ArgumentA = _operatorA.ResolveReferences(bmap, nmap); } if (ArgumentB == null) { ArgumentB = _operatorB.ResolveReferences(bmap, nmap); } return(GetValue()); }
protected virtual string Boolean(IBoolean boolean) { if (boolean is True) { return("1"); } else if (boolean is False) { return("0"); } else { throw new Exception("不可识别的bool类型。"); } }
public void TestBooleanAnd() { IBoolean andTrueTrue = (new And(new BooleanTrue(), new BooleanTrue())); IBoolean andTrueFalse = (new And(new BooleanTrue(), new BooleanFalse())); IBoolean andFalseTrue = (new And(new BooleanFalse(), new BooleanTrue())); IBoolean andFalseFalse = (new And(new BooleanFalse(), new BooleanFalse())); Console.WriteLine("Testing And() expressions..."); Console.WriteLine(); Expect(andTrueTrue.Value); Expect(!andTrueFalse.Value); Expect(!andFalseTrue.Value); Expect(!andFalseFalse.Value); }
public void Initialize() { CheckParameters(); _rareEventValue = model.Parameters.First(p => p.Name == _reValName).Value; _rareEventTest = new EqualTo(_reExpression, new ConstantValue(_rareEventValue)); SetRareEventType(); if (_biasingParametersFlag) { for (int i = 0; i < _reactions.NumReactions; i++) { _gamma.Add(new double[_gammaSize]); _propensityCutoff.Add(new double[_gammaSize - 1]); } _biasingParameters.RareEvent.ExpressionLocale = "global"; _biasingParameters.RareEvent.ExpressionName = _reExpressionName; foreach (var locale in modelInfo.Locales) { var newLocaleInfo = new BiasingParameters.LocaleInfo { Name = locale.Name }; var newReactionInfo = newLocaleInfo.Reactions; LocaleInfo testLocale = locale; var reactions = modelInfo.Reactions.Where(r => r.Locale == testLocale); newReactionInfo.AddRange(reactions.Select(reaction => new BiasingParameters.ReactionInfo { Name = reaction.Name })); _biasingParameters.Locales.Add(newLocaleInfo); } } else { for (int i = 0; i < _reactions.NumReactions; i++) { var localeIndex = LocaleIndex(_reactions.Reactions[i]); var reactionIndex = ReactionIndex(_reactions.Reactions[i], localeIndex); var tempRareEvent = _biasingParameters.Locales[localeIndex].Reactions[reactionIndex].RareEvents[_biasingParameters.RareEvent.IntermediateRareEventCount - 1]; _gamma.Add(tempRareEvent.Gammas); _propensityCutoff.Add(tempRareEvent.Thresholds); } } }
public void BooleanExpressionTreeTest() { const string name = "bit"; IBooleanOperator expression = new GreaterThanOperator(Three, Two); var bet = new BooleanExpressionTree(name, expression); Console.Write("Created new BooleanExpressionTree: "); Console.WriteLine(bet); Console.WriteLine("BooleanExpressionTreeTest: test Name property..."); Expect(bet.Name == name); Console.WriteLine("BooleanExpressionTreeTest: test expression and ResolveReferences()..."); IDictionary <string, IBoolean> bmap = new Dictionary <string, IBoolean>(); IBoolean predicate = bet.ResolveReferences(bmap, null); Expect(predicate.Value == true); Console.WriteLine("BooleanExpressionTreeTest: testing map size (1)..."); Expect(bmap.Count == 1); Console.WriteLine("BooleanExpressionTreeTest: testing map contents..."); Expect(bmap[name] == predicate); }
public dwSSA(ModelInfo modelInfo, float duration, int repeats, int samples) : base(modelInfo, duration, repeats, samples) { Configuration config = Configuration.CurrentConfiguration; _reactions = new ReactionSet(model.Reactions); _trajectoryCounter = 0; _runningMean = 0.0; _runningVariance = 0.0; _crossEntropyRuns = config.GetParameterWithDefault("dwSSA.crossEntropyRuns", 100000); _crossEntropyThreshold = config.GetParameterWithDefault("dwSSA.crossEntropyThreshold", 0.01f); _crossEntropyMinDataSize = config.GetParameterWithDefault("dwSSA.crossEntropyMinDataSize", 200); _reExpressionName = config.GetParameterWithDefault("dwSSA.reExpressionName", "reExpression"); _reValName = config.GetParameterWithDefault("dwSSA.reValName", "reVal"); _reExpression = model.Expressions.FirstOrDefault(e => e.Name == _reExpressionName); _rareEventValue = 0.0f; _rareEventTest = new EqualTo(_reExpression, new ConstantValue(_rareEventValue)); _gamma = config.GetParameterWithDefault("dwSSA.gamma", new double[_reactions.NumReactions]); _outputFileName = config.GetParameterWithDefault("dwSSA.outputFileName", modelInfo.Name + "_dwSSA_1e" + Math.Log(SamplingParams.RealizationCount, 10) + ".txt"); }
public void SetValueFromDialog(ValueUI valueUI, IValue value) { SetValueDialog setDialog = Instantiate(_resourceProvider.SetValueDialog, _dialogLayer); string inputValue = "0"; bool isNumber = true; INumber number = value as INumber; if (number != null) { inputValue = number.Value.ToString(); } IBoolean boolean = value as IBoolean; if (boolean != null) { inputValue = boolean.IsTrue ? "1" : "0"; isNumber = false; } setDialog.Init("Set Constant", inputValue); setDialog.OnOk.AddListener( (valueString) => { if (isNumber) { if (float.TryParse(valueString, out float floatValue)) { FloatConstant constant = number as FloatConstant; if (constant != null) { number.Value = floatValue; } else { constant = new FloatConstant(); constant.Value = floatValue; _cursorTool.SetLabelTarget.Value = constant; if (_cursorTool.SetLabelTarget.Value.Parent == null) { _cursorTool.SetLabelValueUi.Value = _cursorTool.SetLabelTarget.Value; } } } } else { if (float.TryParse(valueString, out float floatValue)) { BoolConstant constant = boolean as BoolConstant; if (constant != null) { boolean.IsTrue = floatValue != 0; } else { constant = new BoolConstant(); constant.IsTrue = floatValue != 0; _cursorTool.SetLabelTarget.Value = constant; if (_cursorTool.SetLabelTarget.Value.Parent == null) { _cursorTool.SetLabelValueUi.Value = _cursorTool.SetLabelTarget.Value; } } } } valueUI.RebuildAnValue(); }); }
public Join(TabularDataSource source, IBoolean expression) { this.joinType = JoinType.Inner; this.source = source; this.expression = expression; }
public OrStatement(IBoolean lStatement, IBoolean rStatement) : base(lStatement, rStatement, Keywords.Or) { }
public Predicate(BooleanExpressionTree expressionTree, IDictionary <string, IBoolean> bmap, IDictionary <string, IValue> nmap) { _tree = expressionTree; _expression = expressionTree.ResolveReferences(bmap, nmap); }
public BooleanExpression(IBoolean a = null, IBoolean b = null, Operator op = Operator.Or) { A = a; B = b; OP = op; }
public AndStatement(IBoolean lStatement, IBoolean rStatement) : base(lStatement, rStatement, Keywords.And) { }
public Constraint(ConstraintInfo info, IDictionary <string, IBoolean> bmap, IDictionary <string, IValue> nmap) { _info = info; _predicate = info.Predicate.ResolveReferences(bmap, nmap); }
public TriggeredEvent(TriggeredEventInfo eventInfo, IDictionary <string, IBoolean> bmap, IDictionary <string, IValue> nmap, IDictionary <string, IUpdateable> umap) : base(eventInfo, nmap, umap) { _predicate = eventInfo.Predicate.ResolveReferences(bmap, nmap); Repeats = eventInfo.Repeats; }
public Join(JoinType joinType, TabularDataSource source, IBoolean expression) { this.joinType = joinType; this.source = source; this.expression = expression; }
public JoinBuilder(Table mainTable, IBoolean onStatement) { MainTable = mainTable; _statement = onStatement; }
protected BinaryBooleanOperation(IBoolean argA, IBoolean argB) { ArgumentA = argA; ArgumentB = argB; }
public And(IBoolean argA, IBoolean argB) : base(argA, argB) { }
public Xor(IBoolean argA, IBoolean argB) : base(argA, argB) { }