public Movement(Organism organism, DUpdateState updateState) : base(organism, updateState) { Organism.collider.enabled = true; motor = organism.motor; last = Organism.transform.position; }
public int Update(Organism self, float deltaTime) { if (Game1.Debug == self) Debug.WriteLine("[ChaseObject] " + _targetMemoryLocation.ToString("X2")); var target = self.Remember<GameObject>(_targetMemoryLocation); if (target == null) return 0; if (target.Removed) { if (Game1.Debug == self) Debug.WriteLine("[ChaseGameObject][Forget]" + _targetMemoryLocation.ToString("X2")); self.Forget(_targetMemoryLocation); return 0; } if (Game1.Debug == self) Debug.WriteLine("[ChaseObject][Chasing] " + target.Position); var direction = target.Position - self.Position; direction.Normalize(); direction *= _desiredSpeed; self.Force = (direction / deltaTime) * self.Mass; if (Game1.Debug == self) Debug.WriteLine("[ChaseObject][Force] " + self.Force); return 1; }
public int Update(Organism self, float deltaTime) { var currentColor = self.Color.ToVector4(); if (currentColor == _targetColor) { if (_timeUsed > 0f) _timeUsed = -1f; return 0; } if (_timeUsed < 0f) Init(currentColor); _timeUsed += deltaTime; if (_timeUsed > _changeTime) _timeUsed = _changeTime; var lerpFactor = _timeUsed/_changeTime; var newColor = Vector4.Lerp(_startColor, _targetColor, lerpFactor); self.Color = new Color(newColor); return 0; }
public void Execute(Tile[,] tiles, Organism organism) { var newX = organism.Tile.Coordinate.X; var newY = organism.Tile.Coordinate.Y; switch (_Direction) { case Direction.Left: newX--; break; case Direction.Right: newX++; break; case Direction.Up: newY--; break; case Direction.Down: newY++; break; } if (newX < 0 || newY < 0 || newX >= tiles.GetLength(0) || newY >= tiles.GetLength(1)) return; tiles[newX, newY].Organism = organism; }
public OrganismVisual(Organism source, Ellipse organism, Polygon sight, PointCollection boundaries, TextBlock energy) { this.source = source; source.OnDeath += source_OnDeath; this.organism = organism; this.boundaries = boundaries; this.energy = energy; organism.Dispatcher.Invoke(new Action(() => organism.Fill = new SolidColorBrush(Colors.Red))); organism.Dispatcher.Invoke(new Action(() => organism.Height = source.getSize())); organism.Dispatcher.Invoke(new Action(() => organism.Width = source.getSize())); this.sight = sight; sight.Dispatcher.Invoke(new Action(() => sight.Fill = new SolidColorBrush(Color.FromArgb(50, 200, 200, 200)))); sight.Dispatcher.Invoke(new Action(() => sight.Points = boundaries)); energy.Dispatcher.Invoke(new Action(() => energy.Foreground = new SolidColorBrush(Colors.White))); energy.Dispatcher.Invoke(new Action(() => energy.HorizontalAlignment = HorizontalAlignment.Center)); energy.Dispatcher.Invoke(new Action(() => energy.VerticalAlignment = VerticalAlignment.Center)); energy.Dispatcher.Invoke(new Action(() => energy.TextAlignment = TextAlignment.Center)); energy.Dispatcher.Invoke(new Action(() => energy.Height = 15)); energy.Dispatcher.Invoke(new Action(() => energy.Width = 40)); constructPointCollection(); }
public int Update(Organism self, float deltaTime) { if (Game1.Debug == self) Debug.WriteLine("[TargetOrganisms] " + _targetingRange); var organismsInRange = ObjectManager.Instance.GetObjectsWithinRange<Organism>(self, _targetingRange).Where(t => t.Radius < self.Radius) .OrderBy(self.Distance).ToList(); if (Game1.Debug == self) Debug.WriteLine("[TargetOrganisms] " + organismsInRange.Count); if (organismsInRange.Count < 1) return _noTargetsGoto; var memoryLocation = _targetMemoryLocation; for (int i = 0; i < _trackingCapacity; i++) { if (i >= organismsInRange.Count) break; self.Remember(memoryLocation++, organismsInRange[i]); } return 0; }
public Death(Organism organism, DUpdateState updateState) : base(organism, updateState) { Organism.Death = SimHandler.Instance().Step; Organism.LogSelf(); SimHandler.PopulationHandler().Kill(Organism); }
public int Update(Organism self, float deltaTime) { if (Game1.Debug == self) Debug.WriteLine("[TopSpeed] " + _topSpeed); self.TopSpeed = _topSpeed; return 0; }
public int Update(Organism self, float deltaTime) { if (Game1.Debug == self) Debug.WriteLine("[SetColor] " + _color); self.Color = _color; return 0; }
public int Update(Organism self, float deltaTime) { for (int i = 0; i < _updates.Count; i++) { i += _updates[i].Update(self, deltaTime); } return 0; }
public bool IsFulfilled(Tile[,] tiles, Organism organism) { var absoluteX = organism.Tile.Coordinate.X + _X; var absoluteY = organism.Tile.Coordinate.Y + _Y; if (absoluteX < 0 || absoluteY < 0 || absoluteX >= tiles.GetLength(0) || absoluteY >= tiles.GetLength(1)) return false; return tiles[absoluteX, absoluteY].IsPassable; }
public virtual void HandleCollision(Organism self, GameObject other, float deltaTime) { if (Game1.Debug == self) Debug.WriteLine("[HandleCollision] " + StartIndex); for (int i = StartIndex; i < _updates.Count; i++) { i += _updates[i].Update(self, deltaTime); } if (Game1.Debug == self) Debug.WriteLine("[HandleCollision][FINISHED]"); }
public int Update(Organism self, float deltaTime) { self.Remember(_memoryLocation, _value); if (Game1.Debug == self) { Debug.WriteLine("[MEM][{0}] = {1}", _memoryLocation.ToString("X2"), _value.ToString("X2")); } return 0; }
public void SetValues(RootCharacterController c, WeaponClass w, int n, int cN1, int cN2, int b, int e, SpFunctions s, clavisher cl, Vector3 p) { bTime = b; eTime = e; controller = c; weapon = w; numb = n; clavNumb1 = cN1; clavNumb2 = cN2; activity = weapon.moveset [numb]; stats = controller.gameObject.GetComponent<Organism> (); sp = s; clav = cl; pos = new Vector3 (p.x, p.y, p.z); }
public void Kill(Organism o) { o.IsDead = true; LivingOrganisms--; o.gameObject.SetActive(false); if (LivingOrganisms <= 0) { // Last log of the simulation. SimHandler.Statistics().Log(); SimHandler.Control().Stop(); } }
public static Organism[] GenPhase(int orgMax) { Organism[] orgsList = new Organism[orgMax]; Random randNum = new Random(); for (int n = 0; n < orgMax; n++) { orgsList[n].oAttack = randNum.Next(1, 6); orgsList[n].oDefence = randNum.Next(1, 6); orgsList[n].oHealth = randNum.Next(1, 6); orgsList[n].oName = NameGen(orgsList[n].oAttack, orgsList[n].oDefence, orgsList[n].oHealth); Thread.Sleep(1000/orgsList.Length); } return orgsList; }
public int Update(Organism self, float deltaTime) { var speed = self.Velocity.Length(); if (speed < DesiredSpeed) { var direction = new Vector2((float)Game1.Random.NextDouble()*2f - 1f,(float)Game1.Random.NextDouble()*2f - 1f); direction.Normalize(); direction *= DesiredSpeed * deltaTime; self.Force = (direction/deltaTime)*self.Mass; } return 0; }
public int Update(Organism self, float deltaTime) { var currentValue = self.Remember<byte>(_memoryLocation); var newValue = (byte)(currentValue + _value); self.Remember(_memoryLocation, newValue); if (Game1.Debug == self) { Debug.WriteLine("[MEM][{0}] += {1} ({2})", _memoryLocation.ToString("X2"), _value.ToString("X2"), newValue.ToString("X2")); } return 0; }
public void SetValues(RootCharacterController c, WeaponClass w, int n, int b, int cN, SpFunctions s, clavisher cl) { bTime = b; controller = c; weapon = w; numb = n; claveNumb = cN; activity = weapon.moveset [numb]; stats = controller.gameObject.GetComponent<Organism> (); stats.shield = this; sp = s; clav = cl; time = 0; rigid = controller.gameObject.GetComponent<Rigidbody2D>(); animNumb = 0; }
public Sight(Organism source, double range, double legWidth) { this.source = source; this.range = range; this.legWidth = legWidth; boundaries = new Point[3]; for (int i = 0; i < 3; i++) { boundaries[i] = new Point(); } calculateBoundaries(); }
public int Update(Organism self, float deltaTime) { var value = self.Remember<byte>(_memoryLocation); var equals = value != _value; if (Game1.Debug == self) { Debug.WriteLine("[MEM][{0}({1})] != {2} ({3}) SKIP {4}", _memoryLocation.ToString("X2"), value, _value.ToString("X2"), equals, _skipSize); } return @equals ? _skipSize : 0; }
public override Organism[] recombine(Organism a, Organism b) { IList<Organism> offsprings = new List<Organism>(); var _50p = new Probability(0.5); var _1p = new Probability(0.01); for (var i = 0; i < nbrChild; ++i) { Organism o = a.createEmpty(); Extension e; // 50% chance to inherit the base extension from one of the parents. if (_50p.test()) e = a.genotype.getRootElement(); else e = b.genotype.getRootElement(); o.genotype.setRootElement(e.localClone()); // The structure recombination is done only for the first level. var nExtensions = Math.Min(a.genotype.getRootElement().getNumberOfChildExtensions(), b.genotype.getRootElement().getNumberOfChildExtensions()); IEnumerator<Extension> t1 = (IEnumerator <Extension>) a.genotype.getRootElement().getChildsEnumerator(); IEnumerator<Extension> t2 = (IEnumerator <Extension>) b.genotype.getRootElement().getChildsEnumerator(); while (t1.MoveNext() && t2.MoveNext()){ if (_50p.test()) o.genotype.getRootElement().addExtension((Extension)t1.Current.deepClone()); else o.genotype.getRootElement().addExtension((Extension)t2.Current.deepClone()); } // Rare mutation that extends plate size. if (_1p.test()) { Mutation m = new Mutation(); //m.addGeneticModifier(new Multiplication(new Set(new[] { "scale" }), new Set(new[] { "Plate" }), 1.5)); o.mutate(m); } offsprings.Add(o); } return offsprings.ToArray<Organism>(); }
void Start() { Matrix matrix = new Matrix(new Vector2(3,5), CellType.none); matrix.Insert(CellType.eye, new Vector2(1,0)); matrix.Insert(CellType.core, new Vector2(1,1)); matrix.Insert(CellType.eye, new Vector2(1,2)); matrix.Insert(CellType.propulsor, new Vector2(1,3)); matrix.Insert(CellType.propulsor, new Vector2(2,3)); matrix.Insert(CellType.propulsor, new Vector2(0,3)); matrix.Insert(CellType.propulsor, new Vector2(1,4)); matrix.Insert(CellType.propulsor, new Vector2(2,4)); matrix.Insert(CellType.propulsor, new Vector2(0,4)); GameObject organismGO = organismCreator.Generate(matrix); organismGO.transform.parent = this.transform; cameraFollow.target = organismGO.transform; cameraFollow.organism = organismGO.rigidbody2D; organism = organismGO.GetComponent<Organism>(); }
public int Update(Organism self, float deltaTime) { if (self.Energy > EnergyThreshold) { var spawnDistance = self.Radius*2; var spawnDirection = self.Position - new Vector2(Game1.Width*0.5f, Game1.Height*0.5f); spawnDirection.Normalize(); spawnDirection = -spawnDirection; var energy = self.TakeEnergy(self.Energy * _childSize); var child = new Organism(new DNA(self.DNA), energy, self.Position + spawnDirection * spawnDistance); ObjectManager.Instance.Add(child); if (Game1.Debug == self) Debug.WriteLine("[ParthenoGenesis][Birth]" + child.Position); return _skipOnBirth; } return _defaultSkip; }
public override void HandleCollision(Organism self, GameObject other, float deltaTime) { StartIndex = 0; var prey = other as Organism; if (prey.Radius < self.Radius) { var distance = (self.Position - other.Position).Length(); if (distance > self.Radius) { StartIndex = _tooFarGoto; self.Remember(_targetMemoryLocation, prey); } else { var relativism = self.DNA.RelatedPercent(prey.DNA, _dnaSampleSize); if (relativism < _relationThreshold) { if (Game1.Debug == self) Debug.WriteLine("[EatOrganisms][CloseEnough] " + relativism); } else { if (Game1.Debug == self) Debug.WriteLine("[EatOrganisms][IEatYou] " + relativism); self.GiveEnergy(prey.TakeEnergy(self.Energy*deltaTime)); } } } else { StartIndex = _biggerGoto; self.Forget(_targetMemoryLocation); } base.HandleCollision(self, other, deltaTime); }
public override void HandleCollision(Organism self, GameObject other, float deltaTime) { if (Game1.Debug == self) Debug.WriteLine("[EatFood][Collision] " + other.Position); StartIndex = 0; var food = other as Food; if (other.Alive) { var distance = (self.Position - other.Position).Length(); if (distance < self.Radius + other.Bounds.Width*0.5f) { if (Game1.Debug == self) Debug.WriteLine("[EatFood][Eating]"); self.GiveEnergy(food.Energy); other.Die(true); } else { if (Game1.Debug == self) Debug.WriteLine("[EatFood][TooFar]"); self.Remember(_targetMemoryLocation, food); StartIndex = _tooFarGoto; } } else { if (Game1.Debug == self) Debug.WriteLine("[EatFood][WasDead]"); StartIndex = _deadGoto; } base.HandleCollision(self, other, deltaTime); }
public override Organism Cross(Organism a, Organism b, Random r) { if (a.genotypeRepresentation != genotypeRepresentation || b.genotypeRepresentation != genotypeRepresentation) { throw new NotImplementedException("Reprezentacja genotypu nie zgadza sie z metodą krzyzowania"); } uint?[] genotype = new uint?[a.TSPcities.Length]; int i = a.TSPcities.Length; bool[] used = new bool[a.TSPcities.Length]; uint indexFROM = 0; uint valueTO = a.genotype[indexFROM]; bool readFromA = false; genotype[indexFROM] = valueTO; // wpisuje pierwsza wartość used[indexFROM] = true; i--; //Console.WriteLine("------"); //Console.WriteLine(GenotypeToString(a.genotype)); //Console.WriteLine(GenotypeToString(b.genotype)); //Console.WriteLine(GenotypeToString(genotype)); while (i > 0) { indexFROM = genotype[indexFROM].Value; // ustawiam następny indeks // skąd czytać następną - a czy b? if (readFromA) { valueTO = a.genotype[indexFROM]; } else { valueTO = b.genotype[indexFROM]; } //Console.WriteLine("Nastepny index FROM: " + indexFROM + " czytam z " + (readFromA ? "A" : "B") + " valueTO: " + valueTO); // jeśli została nam ostatnia krawędz, to musi ona prowadzić do 0 if (i == 1) { valueTO = 0; //Console.WriteLine("Nastepny index FROM: " + indexFROM + " czytam z " + (readFromA ? "A" : "B") + " valueTO: " + valueTO +" FIX ostatnia krawedz"); } else { // jeśli okazuje się, że robimy cykl, to biore inna nieuzyta krawedz if (used[valueTO]) { //Console.WriteLine($"valueTo = {valueTO} jest w genotypie - szukam nowej"); valueTO = FindNotUsedEdge(genotype, used, indexFROM, a, b); //Console.WriteLine("Nastepny index FROM: " + indexFROM + " czytam z " + (readFromA ? "A" : "B") + " valueTO: " + valueTO + " FIX"); } } if (i > 1 && used[valueTO]) { throw new Exception("nadpisuje"); } genotype[indexFROM] = valueTO; used[indexFROM] = true; //Console.WriteLine(GenotypeToString(genotype)); i--; readFromA = !readFromA; } //Console.WriteLine("-----------"); Organism o = new Organism(a.TSPcities, a.genotypeRepresentation); for (int j = 0; j < genotype.Length; j++) { o.genotype[j] = genotype[j].Value; } return(o); }
private void Peel(Organism organism) { // ... }
/***** MONOBEHAVIOUR FUNCTIONS *****/ private void Start() { selfOrganism = GetComponent <Organism>(); }
public void Apply(Organism self) { self.Color = _color; }
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { int[] outputColumns = param.GetParam <int[]>("Output").Value; int proteinIdColumnInd = param.GetParam <int>("Protein IDs").Value; string[] proteinIds = mdata.StringColumns[proteinIdColumnInd]; int[] intensityCols = param.GetParam <int[]>("Intensities").Value; if (intensityCols.Length == 0) { processInfo.ErrString = "Please select at least one column containing protein intensities."; return; } // variable to hold all intensity values List <double[]> columns = new List <double[]>(); string[] inputNames = new string[intensityCols.Length]; string[] sampleNames = new string[intensityCols.Length]; for (int col = 0; col < intensityCols.Length; col++) { double[] values; if (intensityCols[col] < mdata.ColumnCount) { values = ArrayUtils.ToDoubles(mdata.Values.GetColumn(intensityCols[col])); inputNames[col] = mdata.ColumnNames[intensityCols[col]]; } else { values = mdata.NumericColumns[intensityCols[col] - mdata.ColumnCount]; inputNames[col] = mdata.NumericColumnNames[intensityCols[col] - mdata.ColumnCount]; } sampleNames[col] = new Regex(@"^(?:(?:LFQ )?[Ii]ntensity )?(.*)$").Match(inputNames[col]).Groups[1].Value; columns.Add(values); } // average over columns if this option is selected if (param.GetParamWithSubParams <int>("Averaging mode").Value == 3) { double[] column = new double[mdata.RowCount]; for (int row = 0; row < mdata.RowCount; row++) { double[] values = new double[intensityCols.Length]; for (int col = 0; col < intensityCols.Length; col++) { values[col] = columns[col][row]; } column[row] = ArrayUtils.Median(ExtractValidValues(values, false)); } // delete the original list of columns columns = new List <double[]> { column }; sampleNames = new[] { "" }; } // revert logarithm if necessary if (param.GetParamWithSubParams <bool>("Logarithmized").Value) { double[] logBases = new[] { 2, Math.E, 10 }; double logBase = logBases[param.GetParamWithSubParams <bool>("Logarithmized").GetSubParameters().GetParam <int>("log base").Value]; foreach (double[] t in columns) { for (int row = 0; row < mdata.RowCount; row++) { if (t[row] == 0) { processInfo.ErrString = "Are the columns really logarithmized?\nThey contain zeroes!"; } t[row] = Math.Pow(logBase, t[row]); } } } double[] mw = mdata.NumericColumns[param.GetParam <int>("Molecular masses").Value]; // define whether the molecular masses are given in Da or kDa if (ArrayUtils.Median(mw) < 250) // most likely kDa { for (int i = 0; i < mw.Length; i++) { mw[i] *= 1000; } } double[] detectabilityNormFactor = mw; if (param.GetParamWithSubParams <bool>("Detectability correction").Value) { detectabilityNormFactor = mdata.NumericColumns[ param.GetParamWithSubParams <bool>("Detectability correction").GetSubParameters().GetParam <int>("Correction factor") .Value]; } // the normalization factor needs to be nonzero for all proteins // check and replace with 1 for all relevant cases for (int row = 0; row < mdata.RowCount; row++) { if (detectabilityNormFactor[row] == 0 || double.IsNaN(detectabilityNormFactor[row])) { detectabilityNormFactor[row] = 1; } } // detect the organism Organism organism = DetectOrganism(proteinIds); // c value the amount of DNA per haploid genome, see: http://en.wikipedia.org/wiki/C-value double cValue = (organism.genomeSize * basePairWeight) / avogadro; // find the histones int[] histoneRows = FindHistones(proteinIds, organism); // write a categorical column indicating the histones string[][] histoneCol = new string[mdata.RowCount][]; for (int row = 0; row < mdata.RowCount; row++) { histoneCol[row] = (ArrayUtils.Contains(histoneRows, row)) ? new[] { "+" } : new string[0]; } mdata.AddCategoryColumn("Histones", "", histoneCol); // initialize the variables for the annotation rows string[] sampleNameRow = new string[mdata.ColumnCount]; string[] inputNameRow = new string[mdata.ColumnCount]; double[] totalProteinRow = new double[mdata.ColumnCount]; double[] totalMoleculesRow = new double[mdata.ColumnCount]; string[][] organismRow = new string[mdata.ColumnCount][]; // populate the organismRow variable with empty strings as defaults (not null, which may cause errors when writing the annotations in the end.) for (int i = 0; i < organismRow.Length; i++) { organismRow[i] = new[] { "N/A" }; } double[] histoneMassRow = new double[mdata.ColumnCount]; double[] ploidyRow = new double[mdata.ColumnCount]; double[] cellVolumeRow = new double[mdata.ColumnCount]; double[] normalizationFactors = new double[columns.Count]; // calculate normalization factors for each column for (int col = 0; col < columns.Count; col++) { string sampleName = sampleNames[col]; double[] column = columns[col]; // normalization factor to go from intensities to copies, // needs to be determined either using the total protein or the histone scaling approach double factor; switch (param.GetParamWithSubParams <int>("Scaling mode").Value) { case 0: // total protein amount double mwWeightedNormalizedSummedIntensities = 0; for (int row = 0; row < mdata.RowCount; row++) { if (!double.IsNaN(column[row]) && !double.IsNaN(mw[row])) { mwWeightedNormalizedSummedIntensities += (column[row] / detectabilityNormFactor[row]) * mw[row]; } } factor = param.GetParamWithSubParams <int>("Scaling mode").GetSubParameters().GetParam <double>( "Protein amount per cell [pg]").Value *1e-12 * avogadro / mwWeightedNormalizedSummedIntensities; break; case 1: // histone mode double mwWeightedNormalizedSummedHistoneIntensities = 0; foreach (int row in histoneRows) { if (!double.IsNaN(column[row]) && !double.IsNaN(mw[row])) { mwWeightedNormalizedSummedHistoneIntensities += (column[row] / detectabilityNormFactor[row]) * mw[row]; } } double ploidy = param.GetParamWithSubParams <int>("Scaling mode").GetSubParameters().GetParam <double>("Ploidy").Value; factor = (cValue * ploidy * avogadro) / mwWeightedNormalizedSummedHistoneIntensities; break; default: factor = 1; break; } normalizationFactors[col] = factor; } // check averaging mode if (param.GetParamWithSubParams <int>("Averaging mode").Value == 1) // same factor for all { double factor = ArrayUtils.Mean(normalizationFactors); for (int i = 0; i < normalizationFactors.Length; i++) { normalizationFactors[i] = factor; } } if (param.GetParamWithSubParams <int>("Averaging mode").Value == 2) // same factor in each group { if (param.GetParamWithSubParams <int>("Averaging mode").GetSubParameters().GetParam <int>("Grouping").Value == -1) { processInfo.ErrString = "No grouping selected."; return; } string[][] groupNames = mdata.GetCategoryRowAt( param.GetParamWithSubParams <int>("Averaging mode").GetSubParameters().GetParam <int>("Grouping").Value); string[] uniqueGroupNames = Unique(groupNames); int[] grouping = new int[columns.Count]; for (int i = 0; i < columns.Count; i++) { if (intensityCols[i] >= mdata.ColumnCount) // Numeric annotation columns cannot be grouped { grouping[i] = i; continue; } if (ArrayUtils.Contains(uniqueGroupNames, groupNames[i][0])) { grouping[i] = ArrayUtils.IndexOf(uniqueGroupNames, groupNames[i][0]); continue; } grouping[i] = i; } Dictionary <int, List <double> > factors = new Dictionary <int, List <double> >(); for (int i = 0; i < columns.Count; i++) { if (factors.ContainsKey(grouping[i])) { factors[grouping[i]].Add(normalizationFactors[i]); } else { factors.Add(grouping[i], new List <double> { normalizationFactors[i] }); } } double[] averagedNormalizationFactors = new double[columns.Count]; for (int i = 0; i < columns.Count; i++) { List <double> factor; factors.TryGetValue(grouping[i], out factor); averagedNormalizationFactors[i] = ArrayUtils.Mean(factor); } normalizationFactors = averagedNormalizationFactors; } // loop over all selected columns and calculate copy numbers for (int col = 0; col < columns.Count; col++) { string sampleName = sampleNames[col]; double[] column = columns[col]; double factor = normalizationFactors[col]; double[] copyNumbers = new double[mdata.RowCount]; double[] concentrations = new double[mdata.RowCount]; // femtoliters double[] massFraction = new double[mdata.RowCount]; double[] moleFraction = new double[mdata.RowCount]; double totalProtein = 0; // picograms double histoneMass = 0; // picograms double totalMolecules = 0; for (int row = 0; row < mdata.RowCount; row++) { if (!double.IsNaN(column[row]) && !double.IsNaN(mw[row])) { copyNumbers[row] = (column[row] / detectabilityNormFactor[row]) * factor; totalMolecules += copyNumbers[row]; totalProtein += (copyNumbers[row] * mw[row] * 1e12) / avogadro; // picograms if (ArrayUtils.Contains(histoneRows, row)) { histoneMass += (copyNumbers[row] * mw[row] * 1e12) / avogadro; // picograms } } } double totalVolume = (totalProtein / (param.GetParam <double>("Total cellular protein concentration [g/l]").Value)) * 1000; // femtoliters for (int row = 0; row < mdata.RowCount; row++) { if (!double.IsNaN(column[row]) && !double.IsNaN(mw[row])) { concentrations[row] = ((copyNumbers[row] / (totalVolume * 1e-15)) / avogadro) * 1e9; // nanomolar massFraction[row] = (((copyNumbers[row] * mw[row] * 1e12) / avogadro) / totalProtein) * 1e6; // ppm moleFraction[row] = (copyNumbers[row] / totalMolecules) * 1e6; // ppm } } string suffix = (sampleName == "") ? "" : " " + sampleName; if (ArrayUtils.Contains(outputColumns, 0)) { mdata.AddNumericColumn("Copy number" + suffix, "", copyNumbers); } if (ArrayUtils.Contains(outputColumns, 1)) { mdata.AddNumericColumn("Concentration [nM]" + suffix, "", concentrations); } if (ArrayUtils.Contains(outputColumns, 2)) { mdata.AddNumericColumn("Abundance (mass/total mass) [*10^-6]" + suffix, "", massFraction); } if (ArrayUtils.Contains(outputColumns, 3)) { mdata.AddNumericColumn("Abundance (molecules/total molecules) [*10^-6]" + suffix, "", moleFraction); } double[] rank = ArrayUtils.Rank(copyNumbers); double[] relativeRank = new double[mdata.RowCount]; double validRanks = mdata.RowCount; for (int row = 0; row < mdata.RowCount; row++) { // remove rank for protein with no copy number information if (double.IsNaN((copyNumbers[row])) || copyNumbers[row] == 0) { rank[row] = double.NaN; validRanks--; // do not consider as valid } // invert ranking, so that rank 0 is the most abundant protein rank[row] = mdata.RowCount - rank[row]; } for (int row = 0; row < mdata.RowCount; row++) { relativeRank[row] = rank[row] / validRanks; } if (ArrayUtils.Contains(outputColumns, 4)) { mdata.AddNumericColumn("Copy number rank" + suffix, "", rank); } if (ArrayUtils.Contains(outputColumns, 5)) { mdata.AddNumericColumn("Relative copy number rank" + suffix, "", relativeRank); } if (intensityCols[col] < mdata.ColumnCount && param.GetParamWithSubParams <int>("Averaging mode").Value != 3) { inputNameRow[intensityCols[col]] = inputNames[col]; sampleNameRow[intensityCols[col]] = sampleNames[col]; totalProteinRow[intensityCols[col]] = Math.Round(totalProtein, 2); totalMoleculesRow[intensityCols[col]] = Math.Round(totalMolecules, 0); organismRow[intensityCols[col]] = new[] { organism.name }; histoneMassRow[intensityCols[col]] = Math.Round(histoneMass, 4); ploidyRow[intensityCols[col]] = Math.Round((histoneMass * 1e-12) / cValue, 2); cellVolumeRow[intensityCols[col]] = Math.Round(totalVolume, 2); // femtoliters } } // Summary annotation row if (param.GetParamWithSubParams <int>("Averaging mode").Value != 3 && ArrayUtils.Contains(outputColumns, 6)) { mdata.AddNumericRow("Total protein [pg/cell]", "", totalProteinRow); mdata.AddNumericRow("Total molecules per cell", "", totalMoleculesRow); mdata.AddCategoryRow("Organism", "", organismRow); mdata.AddNumericRow("Histone mass [pg/cell]", "", histoneMassRow); mdata.AddNumericRow("Ploidy", "", ploidyRow); mdata.AddNumericRow("Cell volume [fl]", "", cellVolumeRow); } // Summary matrix if (param.GetParamWithSubParams <int>("Averaging mode").Value != 3 && ArrayUtils.Contains(outputColumns, 7)) { supplTables = new IMatrixData[1]; IMatrixData supplTab = PerseusFactory.CreateMatrixData(); supplTab.ColumnNames = new List <string>(); supplTab.Values.Init(totalProteinRow.Length, 0); supplTab.SetAnnotationColumns(new List <string> { "Sample", "Input Column" }, new List <string[]>() { sampleNameRow, inputNameRow }, new List <string>() { "Organism" }, new List <string[][]>() { organismRow }, new List <string>() { "Total protein [pg/cell]", "Total molecules per cell", "Histone mass [pg/cell]", "Ploidy", "Cell volume [fl]" }, new List <double[]>() { totalProteinRow, totalMoleculesRow, histoneMassRow, ploidyRow, cellVolumeRow }, new List <string>(), new List <double[][]>()); supplTables[0] = supplTab; } }
public OrganismWrapper(Organism org) { _org = org; }
public void SimulateSingleTurn(long experimentId) { if (!this.databaseConnector.DatabaseHasBeenPinged) { throw new InvalidOperationException("Cannot run simulation without having pinged the database."); } //try { using (var sqlConnection = this.databaseConnector.OpenSqlConnection()) { var experimentStatus = sqlConnection.GetExperimentStatus(experimentId); var existingOrganismStates = experimentStatus.LatestExperimentTurnId == null ? new OrganismState[0] : sqlConnection.GetTurnOrganismStates(experimentStatus.LatestExperimentTurnId.Value); var newExperimentTurn = BuildNextExperimentTurn(experimentStatus); var random = new Random(newExperimentTurn.RandomSeed); var newOrganismStates = existingOrganismStates .ToDictionary(organismState => organismState.OrganismId, existingOrganismState => new OrganismState { OrganismId = existingOrganismState.OrganismId, Position = existingOrganismState.Position, Health = existingOrganismState.Health, }); foreach (var existingOrganismState in newOrganismStates.Values.OrderBy(state => state.OrganismId).ToArray()) { // TODO: Think first ReleaseEnergy(newExperimentTurn, existingOrganismState, Experiment.HungerRate); var isInSun = AlienSpaceVector.GetCoordinateDelta(existingOrganismState.Position, newExperimentTurn.SunPosition).Abs() < Experiment.SunRadius; if (isInSun) { AbsorbEnergy(newExperimentTurn, existingOrganismState, Experiment.SunEnergyGift); } if (existingOrganismState.Health <= 0) { newOrganismStates.Remove(existingOrganismState.OrganismId); } } var numberOfOrganismsToCreate = Math.Min((int)newExperimentTurn.ExtraEnergy, Experiment.MaxBirthRate); newExperimentTurn.ExtraEnergy -= numberOfOrganismsToCreate; var newPositions = allPoints .Except(newOrganismStates.Values.Select(state => state.Position)) .Randomize(random) .Take(numberOfOrganismsToCreate); foreach (var newPosition in newPositions) { var newOrganism = new Organism { Red = 0, Green = 1, Blue = 0, }; sqlConnection.SaveOrganism(newOrganism); newOrganismStates[newOrganism.Id] = new OrganismState { OrganismId = newOrganism.Id, Position = newPosition, Health = 1, }; } sqlConnection.SaveExperimentTurn(newExperimentTurn); foreach (var organismState in newOrganismStates.Values) { organismState.ExperimentTurnId = newExperimentTurn.Id; sqlConnection.SaveOrganismState(organismState); } } //} catch (Exception e) { //} }
public StatsEpoch(Algorithm a) { best = a.Best; populationDeviation = a.PopulationDeviation(); time = a.stats.ElapsedSeconds; }
public void ClearUI() { selectedOrganism = new Organism(); }
protected override void Context() { base.Context(); _population = A.Fake <RandomPopulation>().WithName("POP"); A.CallTo(() => _population.NumberOfItems).Returns(7); _baseIndividual = A.Fake <Individual>(); _cloneIndividual = A.Fake <Individual>(); var organism = new Organism(); A.CallTo(() => _cloneIndividual.Organism).Returns(organism); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(40).WithName(CoreConstants.Parameters.WEIGHT)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(50).WithName(CoreConstants.Parameters.HEIGHT)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(60).WithName(CoreConstants.Parameters.BMI)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(70).WithName(CoreConstants.Parameters.AGE)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(80).WithName(Constants.Parameters.GESTATIONAL_AGE)); _constParam1 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("P1"); _constParam2 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("P2"); //create a reference to another parameter to ensure that formula parameter are not overwritten if nothing has changed _forumlaParameter = new PKSimParameter().WithName("P3").WithFormula(new ExplicitFormula("P2*2")); _forumlaParameter.Formula.AddObjectPath(new FormulaUsablePath("..", "P2").WithAlias("P2")); var container1 = new Container { _constParam1, _constParam2, _forumlaParameter }; _indParam1 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("P1"); _indParam2 = DomainHelperForSpecs.ConstantParameterWithValue(2).WithName("P2"); _indParam3 = new PKSimParameter().WithName("P3").WithFormula(new ExplicitFormula("P2*2")); _indParam3.Formula.AddObjectPath(new FormulaUsablePath("..", "P2").WithAlias("P2")); _indParam4 = DomainHelperForSpecs.ConstantParameterWithValue(4).WithName("P4"); var container2 = new Container { _indParam1, _indParam2, _indParam3, _indParam4 }; A.CallTo(() => _executionContext.Clone(_baseIndividual)).Returns(_cloneIndividual); A.CallTo(() => _population.FirstIndividual).Returns(_baseIndividual); //put explicit formula first A.CallTo(() => _population.AllVectorialParameters(_entityPathResolver)).Returns(new[] { _forumlaParameter, _constParam1, _constParam2 }); A.CallTo(() => _cloneIndividual.GetAllChildren <IParameter>()).Returns(new[] { _indParam1, _indParam2, _indParam3, _indParam4 }); A.CallTo(() => _entityPathResolver.PathFor(_constParam1)).Returns("PATH1"); A.CallTo(() => _entityPathResolver.PathFor(_constParam2)).Returns("PATH2"); A.CallTo(() => _entityPathResolver.PathFor(_forumlaParameter)).Returns("PATH3"); A.CallTo(() => _entityPathResolver.PathFor(_indParam1)).Returns("PATH1"); A.CallTo(() => _entityPathResolver.PathFor(_indParam2)).Returns("PATH2"); A.CallTo(() => _entityPathResolver.PathFor(_indParam3)).Returns("PATH3"); A.CallTo(() => _entityPathResolver.PathFor(_indParam4)).Returns("PATH4"); A.CallTo(() => _population.AllValuesFor("PATH1")).Returns(new[] { 10d, 11, 12, 13, 14, 15, 16 }); A.CallTo(() => _population.AllValuesFor("PATH2")).Returns(new[] { 20d, 21, 22, 23, 24, 25, 26 }); A.CallTo(() => _population.AllValuesFor("PATH3")).Returns(new[] { 40d, 42, 44, 46, 48, 50, 52 }); _templateIndividual1.Name = "POP-3"; _addIndividualCommand = A.Fake <IPKSimCommand>(); A.CallTo(() => _individualTask.AddToProject(_cloneIndividual, false, false)).Returns(_addIndividualCommand); A.CallTo(() => _executionContext.AddToHistory(A <ICommand> ._)) .Invokes(x => _overallCommand = x.GetArgument <ICommand>(0)); }
public void CloneTest() { Organism clone = _original.Clone(_trainingRoom.TrainingRoomSettings); Assert.IsTrue(clone.Equals(_original)); }
uint FindNotUsedEdge(uint?[] genotype, bool[] used, uint actualIndexFrom, Organism a, Organism b) { //Console.WriteLine("--- Szukanie nieużytej krawędzi"); for (uint i = 0; i < genotype.Length; i++) { // nie może być z samego do siebie if (i == actualIndexFrom) { //Console.WriteLine($"{i} - z samego do siebie nie"); continue; } // jeśli jest to miasto gdzie już jest coś wpisane - też nie mogę if (used[i]) { //Console.WriteLine($"{i} - used"); continue; } // jeśli jest to miasto, które nie jest wpisane, to sprawdzam jeszcze czy nie ma go już w genotypie i wtedy mogę tam iść if (!HasCity(genotype, i)) { //Console.WriteLine($"{i} - ok"); return(i); } } throw new Exception("Nie ma wolnej krawędzi"); }
private void SpawnTutorialHumanCell(Vector2 spawnPos) { humanCell = HumanCell.InstantiateHumanCell(spawnPos); humanCell.GetComponent <OrganismDuplication>().enabled = false; }
public void FeedsTo(Organism organism) { Console.WriteLine($"{organism.Name} feeds by owner {Name}"); }
protected virtual void ApplyDamage(Organism o) { o.DamageOrganism(damage); }
public void ChangeStateTest() { //checks that an Alive object with 5 Neighbors will become !Alive Organism org = new Organism() { Body = 'm', Neighbors = new List <char>() { { 'r' }, { '[' }, { '4' }, { '`' }, { 'f' } } }; Assert.AreEqual(true, org.Alive); Assert.AreEqual(5, org.NeighborCount); org.ChangeState(); Assert.AreEqual(false, org.Alive); //checks that a !Alive object with 2 Neighbors will remain !Alive Organism deadOrg = new Organism() { Neighbors = new List <char>() { { 'w' }, { 't' } } }; Assert.AreEqual(false, deadOrg.Alive); Assert.AreEqual(' ', deadOrg.Body); Assert.AreEqual(2, deadOrg.NeighborCount); deadOrg.ChangeState(); Assert.AreEqual(false, deadOrg.Alive); Assert.AreEqual(' ', deadOrg.Body); //checks that a !Alive object with 3 Neighbors will become Alive //and be assigned a body which is not ' ' Organism liveOrg = new Organism() { Neighbors = new List <char>() { { 'p' }, { '9' }, { '#' } } }; Assert.AreEqual(false, liveOrg.Alive); Assert.AreEqual(' ', liveOrg.Body); Assert.AreEqual(3, liveOrg.NeighborCount); liveOrg.ChangeState(); Assert.AreEqual(true, liveOrg.Alive); Assert.AreNotEqual(' ', liveOrg.Body); //checks that an Alive object with 1 Neighbor will become !Alive Organism orgKill = new Organism() { Body = 'k', Neighbors = new List <char>() { { 'x' } } }; Assert.AreEqual(true, orgKill.Alive); Assert.AreEqual(1, orgKill.NeighborCount); orgKill.ChangeState(); Assert.AreEqual(false, orgKill.Alive); //checks that an Alive object with 2 Neighbors will remain Alive Organism orgForever = new Organism() { Body = 'o', Neighbors = new List <char>() { { '4' }, { 'e' } } }; Assert.AreEqual(true, orgForever.Alive); Assert.AreEqual(2, orgForever.NeighborCount); orgForever.ChangeState(); Assert.AreEqual(true, orgForever.Alive); }
/// <summary> /// Creates a new plant world boundary given the owning /// plant and the plant's unique ID. /// </summary> /// <param name="plant">The plant used to initialize the world boundary.</param> /// <param name="id">The plant's Unique ID</param> internal PlantWorldBoundary(Organism plant, string id) : base(plant, id) { }
private void Cut(Organism organism) { // ... }
private bool Equals(Organism o) { return(o != null && name.Equals(o.name)); }
public void setTarget(Organism t) { target = t; }
/***** POOL FUNCTIONS *****/ public static Projectile InstantiateProjectileLight(Vector2 spawnPosition, Quaternion spawnRotation, Organism newTarget) { ProjectileLight projectileLightToSpawn = ProjectileLightPool.Instance.Get(); projectileLightToSpawn.transform.position = spawnPosition; projectileLightToSpawn.transform.rotation = spawnRotation; projectileLightToSpawn.gameObject.SetActive(true); projectileLightToSpawn.OnObjectToSpawn(); projectileLightToSpawn.SetTarget(newTarget); return(projectileLightToSpawn); }
public void Apply(Organism self) { self.Color = _color; }
/***** MONOBEHAVIOUR FUNCTIONS *****/ private void Start() { selfOrganism = GetComponent <Organism>(); orgMovement = GetComponent <OrganismMovement>(); }
/***** GETTERS/SETTERS *****/ public void SetTarget(Organism newTarget) { target = newTarget; }
protected virtual void KillProjectile() { Hide(); target = null; StopDelayKillCoroutine(); }
/// <summary> /// Creates a new animal world boundary for a given animal /// </summary> /// <param name="animal">The actual class representing the creature.</param> /// <param name="ID">The unique ID of the creature.</param> internal AnimalWorldBoundary(Organism animal, string ID) : base(animal, ID) { }
public static Individual CreateIndividual(string speciesName = "Species") { var originData = new OriginData { SubPopulation = new SubPopulation(), Species = new Species { DisplayName = speciesName, Id = speciesName }.WithName(speciesName), Gender = new Gender().WithName("Gender"), Population = new SpeciesPopulation().WithName("Population"), }; var pvv = new ParameterValueVersion().WithName("PVVName"); var category = new ParameterValueVersionCategory().WithName("CategoryName"); category.Add(pvv); originData.SubPopulation.AddParameterValueVersion(pvv); var organism = new Organism().WithName(Constants.ORGANISM).WithId("OrganismId"); var organLiver = new Organ().WithName(CoreConstants.Organ.LIVER).WithId("LiverId"); organLiver.OrganType = OrganType.TissueOrgansNotInGiTract; var periportal = new Compartment().WithName(CoreConstants.Compartment.PERIPORTAL).WithId("PeriportalId"); periportal.Add(new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithId("PeriportalIntracellular")); var pericentral = new Compartment().WithName(CoreConstants.Compartment.PERICENTRAL).WithId("PericentralId"); pericentral.Add(new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithId("PericentralIntracellular")); organLiver.Add(periportal); organLiver.Add(pericentral); var organKidney = new Organ().WithName(CoreConstants.Organ.KIDNEY).WithId("KidneyId"); organKidney.OrganType = OrganType.TissueOrgansNotInGiTract; organKidney.Add(new Compartment { Visible = true }.WithName(CoreConstants.Compartment.PLASMA).WithId("KidneyPlasma")); var lumen = new Organ().WithName("GiTract").WithId("GiTract"); lumen.OrganType = OrganType.Lumen; var duodenum = new Compartment().WithName("Duodenum").WithId("Duodenum"); var caecum = new Compartment().WithName("Caecum").WithId("Caecum"); var dimension = Constants.Dimension.NO_DIMENSION; var parameterLiver = new PKSimParameter().WithName("PLiver").WithId("PLiverId").WithFormula(new ExplicitFormula("1").WithId("1")).WithDimension(dimension); parameterLiver.Info = new ParameterValueMetaData { DefaultValue = 1 }; var parameterKidney = new PKSimParameter().WithName("PKidney").WithId("PKidneyId").WithFormula(new ExplicitFormula("2").WithId("2")).WithDimension(dimension); parameterKidney.Info = new ParameterValueMetaData { DefaultValue = 2 }; var parameterOrganism = new PKSimParameter().WithName(ParameterInOrganism).WithId("POrganismId").WithFormula(new ExplicitFormula("3").WithId("3")).WithDimension(dimension); parameterOrganism.Info = new ParameterValueMetaData { DefaultValue = 3 }; organLiver.Add(parameterLiver); organKidney.Add(parameterKidney); organism.Add(organLiver); organism.Add(organKidney); organism.Add(lumen); organism.Add(parameterOrganism); lumen.Add(duodenum); lumen.Add(caecum); var individual = new Individual { OriginData = originData }.WithName("Individual").WithId("IndividualId"); individual.Add(organism); return(individual); }
public void DuringTurn() { int deltaX = (int)Input.GetAxisRaw("Horizontal"); int deltaY = (int)Input.GetAxisRaw("Vertical"); // If the player is not trying to move orthogonally, check for diagonal movement if (deltaX == 0 && deltaY == 0) { int upRight = (int)Input.GetAxisRaw("/ Diagonal"); int upLeft = (int)Input.GetAxisRaw("\\ Diagonal"); if (upRight != 0) { deltaX = upRight; deltaY = upRight; } else if (upLeft != 0) { deltaX = -upLeft; deltaY = upLeft; } } // If movement or a directional attack is being attempted if (deltaX != 0 || deltaY != 0) { Organism victim = GameManager.Level.GetOrganism(position.x + deltaX, position.y + deltaY); if (victim != null) { AttemptAttack(deltaX, deltaY); } else { AttemptMove(deltaX, deltaY); } EndTurn(); } // If the player is trying to attack based on mouse targeting else if (Input.GetAxisRaw("Fire") == 1) { // Find the mouse position and round it to a world position Vector2 target = Camera.main.ScreenToWorldPoint(Input.mousePosition); int targetX = (int)(target.x + 0.5f); int targetY = (int)(target.y + 0.5f); Organism victim = GameManager.Level.GetOrganism(targetX, targetY); // Attack if a valid organism is found and it isn't us if (victim != null && !(victim is Player)) { if (AttemptAttack(victim)) { EndTurn(); } } } // If the player is trying to use stairs else if (Input.GetAxisRaw("Use Stairs") == 1) { if (position == GameManager.Level.Upstairs) { GameManager.Manager.LoadNextFloor(); } } // If the player is trying to eat a corpse/pick up an item else if (Input.GetAxisRaw("Start / Consume") == 1) { Item item = GameManager.Level.GetItem(position.x, position.y); if (item != null) { item.InteractWith(this); } EndTurn(); } else if (Input.GetAxisRaw("Wait") == 1) { EndTurn(); } }
public void takeDamage(Organism attacker, float amount) { _health -= amount; if (_health <= 0) { state = State.Dead; attacker.setState(State.Idle); attacker.setTarget(null); if (!_flyingOff) { flyOff(); } } }
public static Individual CreateIndividual() { var originData = new OriginData(); originData.SubPopulation = new SubPopulation(); originData.Species = new Species().WithName("Species"); originData.Gender = new Gender().WithName("Gender"); originData.SpeciesPopulation = new SpeciesPopulation().WithName("Population"); var pvv = new ParameterValueVersion().WithName("PVVName"); var category = new ParameterValueVersionCategory().WithName("CategoryName"); category.Add(pvv); originData.SubPopulation.AddParameterValueVersion(pvv); var organism = new Organism().WithName("Organism").WithId("OrganismId"); var organLiver = new Organ().WithName(CoreConstants.Organ.Liver).WithId("LiverId"); organLiver.OrganType = OrganType.Liver; var periportal = new Compartment().WithName(CoreConstants.Compartment.Periportal).WithId("PeriportalId"); periportal.Add(new Container().WithName(CoreConstants.Compartment.Intracellular).WithId("PeriportalIntracellular")); var pericentral = new Compartment().WithName(CoreConstants.Compartment.Pericentral).WithId("PericentralId"); pericentral.Add(new Container().WithName(CoreConstants.Compartment.Intracellular).WithId("PericentralIntracellular")); organLiver.Add(periportal); organLiver.Add(pericentral); var organKidney = new Organ().WithName(CoreConstants.Organ.Kidney).WithId("KidneyId"); organKidney.OrganType = OrganType.Kidney; organKidney.Add(new Compartment { Visible = true }.WithName(CoreConstants.Compartment.Plasma).WithId("KidneyPlasma")); var lumen = new Organ().WithName("GiTract").WithId("GiTract"); lumen.OrganType = OrganType.Lumen; var duodenum = new Compartment().WithName("Duodenum").WithId("Duodenum"); var caecum = new Compartment().WithName("Caecum").WithId("Caecum"); var dimension = Constants.Dimension.NO_DIMENSION; var parameterLiver = new PKSimParameter().WithName("PLiver").WithId("PLiverId").WithFormula(new ExplicitFormula("1").WithId("1")).WithDimension(dimension); parameterLiver.Info = new ParameterValueMetaData { DefaultValue = 1 }; var parameterKidney = new PKSimParameter().WithName("PKidney").WithId("PKidneyId").WithFormula(new ExplicitFormula("2").WithId("2")).WithDimension(dimension); parameterKidney.Info = new ParameterValueMetaData { DefaultValue = 2 }; var parameterOrganism = new PKSimParameter().WithName(ParameterInOrganism).WithId("POrganismId").WithFormula(new ExplicitFormula("3").WithId("3")).WithDimension(dimension); parameterOrganism.Info = new ParameterValueMetaData { DefaultValue = 3 }; organLiver.Add(parameterLiver); organKidney.Add(parameterKidney); organism.Add(organLiver); organism.Add(organKidney); organism.Add(lumen); organism.Add(parameterOrganism); lumen.Add(duodenum); lumen.Add(caecum); var individual = new Individual { OriginData = originData }.WithName("Individual").WithId("IndividualId"); individual.Add(organism); return(individual); }
public int Update(Organism self, float deltaTime) { return _jumpSize; }
private void setNeighborsIn(INeighborhoodBase neighborhood, string neighborhoodName, Organism organism) { var flatNeighborhood = _flatNeighborhoodRepository.NeighborhoodFrom(neighborhoodName); neighborhood.FirstNeighbor = neighborFrom(flatNeighborhood.FirstNeighborId, organism); neighborhood.SecondNeighbor = neighborFrom(flatNeighborhood.SecondNeighborId, organism); }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } ((Fhir.R4.Models.BackboneElement) this).SerializeJson(writer, options, false); if (Target != null) { writer.WritePropertyName("target"); Target.SerializeJson(writer, options); } if (Type != null) { writer.WritePropertyName("type"); Type.SerializeJson(writer, options); } if (Interaction != null) { writer.WritePropertyName("interaction"); Interaction.SerializeJson(writer, options); } if (Organism != null) { writer.WritePropertyName("organism"); Organism.SerializeJson(writer, options); } if (OrganismType != null) { writer.WritePropertyName("organismType"); OrganismType.SerializeJson(writer, options); } if (AmountQuantity != null) { writer.WritePropertyName("amountQuantity"); AmountQuantity.SerializeJson(writer, options); } if (AmountRange != null) { writer.WritePropertyName("amountRange"); AmountRange.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(AmountString)) { writer.WriteString("amountString", (string)AmountString !); } if (_AmountString != null) { writer.WritePropertyName("_amountString"); _AmountString.SerializeJson(writer, options); } if (AmountType != null) { writer.WritePropertyName("amountType"); AmountType.SerializeJson(writer, options); } if ((Source != null) && (Source.Count != 0)) { writer.WritePropertyName("source"); writer.WriteStartArray(); foreach (Reference valSource in Source) { valSource.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
public virtual void Mutate(Organism o, Random r) { throw new NotImplementedException("implement Mutate"); }