private DominationResult Dominates(DoubleArray left, DoubleArray right, BoolArray maximizations) { bool leftIsBetter = false, rightIsBetter = false; for (int i = 0; i < left.Length; i++) { if (IsDominated(left[i], right[i], maximizations[i])) { rightIsBetter = true; } else if (IsDominated(right[i], left[i], maximizations[i])) { leftIsBetter = true; } if (leftIsBetter && rightIsBetter) { break; } } if (leftIsBetter && !rightIsBetter) { return(DominationResult.Dominates); } if (!leftIsBetter && rightIsBetter) { return(DominationResult.IsDominated); } return(DominationResult.IsNonDominated); }
/// <summary> /// Writes the allocations deallocs. /// </summary> /// <param name="allocs">The allocs.</param> public static void WriteAllocationsDeallocs(Caching.BlockCache provider, List <ulong> allocs) { // We can now group them now for each block. for (int i = 0; i < allocs.Count;) { // We obtain the allocation block. uint offset; ulong allocAddress = BlockHelper.GetAllocationBlock(provider.BlockSize, allocs[i], out offset); // We read it and gain access to it. BoolArray array = new BoolArray(provider.Read(BlockType.AllocationBlock, allocAddress)); // We write first data. array.Change(offset); // Continue while we can in this block. i++; for (; i < allocs.Count; i++) { // We quite if not the same block. if (allocAddress != BlockHelper.GetAllocationBlock(provider.BlockSize, allocs[i], out offset)) { break; } // Otherwise write. array.Change(offset); } // We need to write it now. provider.Write(BlockType.AllocationBlock, allocAddress, array.Data); } }
private void Start() { if (Instance != null) { Debug.LogError("ERROR: More than one PersistentManager in scene"); } else { Instance = this; } LoadScene(startScene); SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.sceneUnloaded += SceneManager_sceneUnloaded; highScores = new int[Constants.LevelCount]; // Initialize jagged array diamonds = new BoolArray[Constants.LevelCount]; for (int i = 0; i < diamonds.Length; i++) { diamonds[i] = new BoolArray(); } // TODO: Clear the save data - for debugging, remove later //ClearData(); }
protected override void OnEvaluatorChanged() { base.OnEvaluatorChanged(); Evaluator.QualitiesParameter.ActualNameChanged += new System.EventHandler(QualitiesParameter_ActualNameChanged); Maximization = new BoolArray(Evaluator.Maximization.ToArray()); ParameterizeOperators(); }
public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) { var result = new JSMEncoding(); int nrOfResources = p1.JobSequenceMatrix.Count; int nrOfJobs = p1.JobSequenceMatrix[0].Length; //Determine randomly which jobindexes persist var persist = new BoolArray(nrOfJobs); for (int i = 0; i < persist.Length; i++) { persist[i] = random.Next(2) == 1; } bool dominantParent = random.Next(2) == 1; JSMEncoding parent1 = dominantParent ? p1 : p2; JSMEncoding parent2 = dominantParent ? p2 : p1; //Fill childmatrix with values for (int resIndex = 0; resIndex < nrOfResources; resIndex++) { result.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, nrOfJobs)); int parent2index = 0; for (int jobIndex = 0; jobIndex < nrOfJobs; jobIndex++) { if (persist[parent1.JobSequenceMatrix[resIndex][jobIndex]]) result.JobSequenceMatrix[resIndex][jobIndex] = parent1.JobSequenceMatrix[resIndex][jobIndex]; else { while (persist[parent2.JobSequenceMatrix[resIndex][parent2index]]) parent2index++; result.JobSequenceMatrix[resIndex][jobIndex] = parent2.JobSequenceMatrix[resIndex][parent2index]; parent2index++; } } } return result; }
private void UpdateRealizations() { var realizations = new ItemList <BoolArray>(RealizationsSize); var rand = new MersenneTwister(); for (var i = 0; i < RealizationsSize; i++) { var newRealization = new BoolArray(Probabilities.Length); var countOnes = 0; do { countOnes = 0; for (var j = 0; j < Probabilities.Length; j++) { newRealization[j] = Probabilities[j] < rand.NextDouble(); if (newRealization[j]) { countOnes++; } } // only generate realizations with at least 4 cities visited } while (countOnes < 4 && Probabilities.Length > 3); realizations.Add(newRealization); } Realizations = realizations; }
private void EnsureNodeCapacity(int requiredCapacity, int inputCount) { // Grow _ancestorNodeBitmap as necessary. if (requiredCapacity > _ancestorNodeBitmap.Length) { // For the new capacity, select the lowest power of two that is above the required capacity; // this limits the number of capacity increases as the required capacity increases. int newCapacity = MathUtils.CeilingToPowerOfTwo(requiredCapacity); // Allocate new bitmaps with the new capacity. _ancestorNodeBitmap = new BoolArray(newCapacity); } // Grow _nodeDepthMatrix as necessary. if (requiredCapacity > _nodeDepthMatrix.Length) { int newLength = MathUtils.CeilingToPowerOfTwo(requiredCapacity); int prevLength = _nodeDepthMatrix.Length; Array.Resize(ref _nodeDepthMatrix, newLength); for (int i = prevLength; i < newLength; i++) { _nodeDepthMatrix[i] = new List <int>(inputCount); } } }
public BinaryVector(BoolArray elements) : this(elements.Length) { for (int i = 0; i < array.Length; i++) { array[i] = elements[i]; } }
public void BoundsTests() { for (int len = 1; len < 258; len++) { var arr = new BoolArray(len); Assert.Throws <IndexOutOfRangeException>(() => { bool b = arr[-1]; }); Assert.Throws <IndexOutOfRangeException>(() => { bool b = arr[arr.Length]; }); Assert.False(arr[^ 1]);
/// <summary> /// Scans one allocation block. /// </summary> /// <param name="address">The allocation block address.</param> /// <returns></returns> AllocationBlockInfo ScanBlock(ulong address) { AllocationBlockInfo value; if (inspectedFreeBlocks.TryGetValue(address, out value)) { return(value); } BoolArray array = new BoolArray(provider.Read(BlockType.AllocationBlock, address)); // We first check for all written (fast). if (array.IsAllTrue) { value = new AllocationBlockInfo(address, new List <uint>()); inspectedFreeBlocks.Add(address, value); return(value); } List <uint> freeBlocks = new List <uint>(); // We search through all (optimized search, may optimize even better in future. // If this will be a bottle neck, we can fix the array outside and than search // through it using ulong* pointer (no need to repeat this every time)). for (uint i = 0; i < provider.BlockSize / 8; i++) { // We chaeck 8-bytes at one for all full. if (array.IsULongFull(i)) { continue; } // For all free. if (array.IsULongFree(i)) { for (uint j = i * 64; j < (i + 1) * 64; j++) { freeBlocks.Add(j + 1); } continue; } // We now check by byte. for (uint j = i * 64; j < (i + 1) * 64; j++) { if (!array[j]) { freeBlocks.Add(j + 1); } } } value = new AllocationBlockInfo(address, freeBlocks); inspectedFreeBlocks.Add(address, value); return(value); }
public void Test_InitTrue() { const int len = 123; var arr = new BoolArray(123, true); for (int i = 0; i < len; i++) { Assert.IsTrue(arr[i]); } }
public static BoolArray[] InitDiamondArray() { BoolArray[] array = new BoolArray[Constants.LevelCount]; for (int i = 0; i < array.Length; i++) { array[i].Diamonds = new bool[Constants.DiamondCount]; } return(array); }
public BoolArray[] Diamonds; // [Level, Diamond] public SaveData() { HighScores = new int[Constants.LevelCount]; Diamonds = new BoolArray[Constants.LevelCount]; for (int i = 0; i < Diamonds.Length; i++) { Diamonds[i] = new BoolArray(); Diamonds[i].Diamonds = new bool[Constants.DiamondCount]; } }
private void EnsureNodeCapacity(int capacity) { if (capacity > _visitedNodeBitmap.Length) { // For the new capacity, select the lowest power of two that is above the required capacity. capacity = MathUtils.CeilingToPowerOfTwo(capacity); // Allocate new bitmap with the new capacity. _visitedNodeBitmap = new BoolArray(capacity); } }
private void EnsureNodeCapacity(int requiredCapacity) { if (requiredCapacity > _ancestorNodeBitmap.Length) { // For the new capacity, select the lowest power of two that is above the required capacity; // this limits the number of capacity increases as the required capacity increases. requiredCapacity = MathUtils.CeilingToPowerOfTwo(requiredCapacity); // Allocate new bitmaps with the new capacity. _ancestorNodeBitmap = new BoolArray(requiredCapacity); _visitedNodeBitmap = new BoolArray(requiredCapacity); } }
public void BoolArrayMemberMarshalsCorrectly() { var obj = new BoolArray(); obj.Elements[0] = true; obj.Elements[1] = true; var result = Functions.PassThrough(obj); Assert.Equal(obj.Elements[0], result.Elements[0]); Assert.Equal(obj.Elements[1], result.Elements[1]); Assert.Equal(obj.Elements[2], result.Elements[2]); }
protected bool Equals(KitchenSinkPortable other) { return(Bool == other.Bool && BoolArray.SequenceEqual(other.BoolArray) && ByteArray.SequenceEqual(other.ByteArray) && Byte == other.Byte && CharArray.SequenceEqual(other.CharArray) && Char == other.Char && ShortArray.SequenceEqual(other.ShortArray) && Short == other.Short && IntArray.SequenceEqual(other.IntArray) && Int == other.Int && LongArray.SequenceEqual(other.LongArray) && Long == other.Long && FloatArray.SequenceEqual(other.FloatArray) && Float.Equals(other.Float) && DoubleArray.SequenceEqual(other.DoubleArray) && Double.Equals(other.Double) && string.Equals(String, other.String) && StringArray.SequenceEqual(other.StringArray) ); }
public void BoolArrayMemberMarshalsCorrectly() { Skip.If(IntPtr.Size < 8, "Known x86 issue - crashes the whole testhost"); var obj = new BoolArray(); obj.Elements[0] = true; obj.Elements[1] = true; var result = Functions.PassThrough(obj); Assert.Equal(obj.Elements[0], result.Elements[0]); Assert.Equal(obj.Elements[1], result.Elements[1]); Assert.Equal(obj.Elements[2], result.Elements[2]); }
protected bool Equals(KitchenSinkDataSerializable other) { return(BoolArray.SequenceEqual(other.BoolArray) && Bool == other.Bool && ByteArray.SequenceEqual(other.ByteArray) && Byte == other.Byte && CharArray.SequenceEqual(other.CharArray) && Char == other.Char && ShortArray.SequenceEqual(other.ShortArray) && Short == other.Short && IntArray.SequenceEqual(other.IntArray) && Int == other.Int && LongArray.SequenceEqual(other.LongArray) && Long == other.Long && FloatArray.SequenceEqual(other.FloatArray) && Float.Equals(other.Float) && DoubleArray.SequenceEqual(other.DoubleArray) && Double.Equals(other.Double) && string.Equals(Chars, other.Chars) && string.Equals(String, other.String) && StringArray.SequenceEqual(other.StringArray) && Equals(Serializable, other.Serializable) && Equals(Portable, other.Portable) && Equals(Data, other.Data) && DateTime.Equals(other.DateTime)); }
public static void MyClassInitialize(TestContext testContext) { random = new MersenneTwister(); coordinates = new DoubleMatrix(ProblemSize, 2); distances = new DistanceMatrix(ProblemSize, ProblemSize); for (var i = 0; i < ProblemSize; i++) { coordinates[i, 0] = random.Next(ProblemSize * 10); coordinates[i, 1] = random.Next(ProblemSize * 10); } for (var i = 0; i < ProblemSize - 1; i++) { for (var j = i + 1; j < ProblemSize; j++) { distances[i, j] = Math.Round(Math.Sqrt(Math.Pow(coordinates[i, 0] - coordinates[j, 0], 2) + Math.Pow(coordinates[i, 1] - coordinates[j, 1], 2))); distances[j, i] = distances[i, j]; } } probabilities = new DoubleArray(ProblemSize); for (var i = 0; i < ProblemSize; i++) { probabilities[i] = random.NextDouble(); } realizations = new ItemList <BoolArray>(RealizationsSize); for (var i = 0; i < RealizationsSize; i++) { var countOnes = 0; var newRealization = new BoolArray(ProblemSize); while (countOnes < 4) //only generate realizations with at least 4 cities visited { countOnes = 0; for (var j = 0; j < ProblemSize; j++) { newRealization[j] = random.NextDouble() < probabilities[j]; if (newRealization[j]) { countOnes++; } } } realizations.Add(newRealization); } tour = new Permutation(PermutationTypes.RelativeUndirected, ProblemSize, random); }
public SymbolicRegressionMultiObjectiveProblem() : base(new RegressionProblemData(), new SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { Parameters.Add(new FixedValueParameter <DoubleLimit>(EstimationLimitsParameterName, EstimationLimitsParameterDescription)); EstimationLimitsParameter.Hidden = true; ApplyLinearScalingParameter.Value.Value = true; Maximization = new BoolArray(new bool[] { true, false }); MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth; MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; RegisterEventHandlers(); ConfigureGrammarSymbols(); InitializeOperators(); UpdateEstimationLimits(); }
public void Test_InitFalse() { const int len = 123; var arr = new BoolArray(123); for (int i = 0; i < len; i++) { Assert.IsFalse(arr[i]); } arr = new BoolArray(123, false); for (int i = 0; i < len; i++) { Assert.IsFalse(arr[i]); } }
public void InitFalse() { const int len = 123; var arr = new BoolArray(len); for (int i = 0; i < len; i++) { Assert.False(arr[i]); } arr = new BoolArray(len, false); for (int i = 0; i < len; i++) { Assert.False(arr[i]); } }
public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) { var result = new JSMEncoding(); int nrOfResources = p1.JobSequenceMatrix.Count; int nrOfJobs = p1.JobSequenceMatrix[0].Length; //Determine randomly which jobindexes persist var persist = new BoolArray(nrOfJobs); for (int i = 0; i < persist.Length; i++) { persist[i] = random.Next(2) == 1; } bool dominantParent = random.Next(2) == 1; JSMEncoding parent1 = dominantParent ? p1 : p2; JSMEncoding parent2 = dominantParent ? p2 : p1; //Fill childmatrix with values for (int resIndex = 0; resIndex < nrOfResources; resIndex++) { result.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, nrOfJobs)); int parent2index = 0; for (int jobIndex = 0; jobIndex < nrOfJobs; jobIndex++) { if (persist[parent1.JobSequenceMatrix[resIndex][jobIndex]]) { result.JobSequenceMatrix[resIndex][jobIndex] = parent1.JobSequenceMatrix[resIndex][jobIndex]; } else { while (persist[parent2.JobSequenceMatrix[resIndex][parent2index]]) { parent2index++; } result.JobSequenceMatrix[resIndex][jobIndex] = parent2.JobSequenceMatrix[resIndex][parent2index]; parent2index++; } } } return(result); }
public SymbolicClassificationMultiObjectiveProblem() : base(new ClassificationProblemData(), new SymbolicClassificationMultiObjectiveMeanSquaredErrorTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { Parameters.Add(new FixedValueParameter <DoubleLimit>(EstimationLimitsParameterName, EstimationLimitsParameterDescription)); Parameters.Add(new ValueParameter <ISymbolicClassificationModelCreator>(ModelCreatorParameterName, "", new AccuracyMaximizingThresholdsModelCreator())); ApplyLinearScalingParameter.Value.Value = false; EstimationLimitsParameter.Hidden = true; Maximization = new BoolArray(new bool[] { false, false }); MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth; MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; RegisterEventHandlers(); ConfigureGrammarSymbols(); InitializeOperators(); UpdateEstimationLimits(); }
private static void TestSingleBitFlipsOn(int len) { for (int i = 0; i < len; i++) { var arr = new BoolArray(len); arr[i] = true; // Test all leading bits. for (int j = 0; j < i; j++) { Assert.IsFalse(arr[j]); } // Test flipped bit. Assert.IsTrue(arr[i]); // Test all following bits. for (int j = i + 1; j < len; j++) { Assert.IsFalse(arr[j]); } } }
//for each row, average any columns that have the same groupId if numRepeat=-1 public static ShoMatrix AverageColSubsetsInSameGroup(this ShoMatrix M, Matrix <string, string, string> groupIds, out ShoMatrix numInstancesPerGroup, ParallelOptions parallelOptions, int repeatNum) { M.CheckEqualColKeys(groupIds.ColKeys.ToList()); Helper.CheckCondition(groupIds.RowCount == 1, "group ids should have only one row"); List <string> uniqueGroupIds = groupIds.Unique().ToList(); int G = uniqueGroupIds.Count; DoubleArray averagedResults = new DoubleArray(M.RowCount, G); DoubleArray numInstancesPerGroupArray = ShoUtils.DoubleArrayZeros(1, G); BoolArray haveProcessedGroupG = new BoolArray(1, G); for (int g = 0; g < G; g++) { string gId = uniqueGroupIds[g]; List <int> theseCols = new List <int>(); for (int n = 0; n < groupIds.ColCount; n++) { if (groupIds[0, n] == uniqueGroupIds[g]) { if (repeatNum < 0 || !haveProcessedGroupG[g])//averaging, or else it is the right repeat { theseCols.Add(n); haveProcessedGroupG[g] = true; } } } DoubleArray avgValues = M.DoubleArray.GetCols(theseCols).Mean(DimOp.OverCol); averagedResults.SetCol(g, avgValues); numInstancesPerGroupArray[0, g] = theseCols.Count(); } numInstancesPerGroup = new ShoMatrix(numInstancesPerGroupArray, new List <string>() { "count" }, uniqueGroupIds, double.NaN); return(new ShoMatrix(averagedResults, M.RowKeys, uniqueGroupIds, double.NaN)); }
public static void MyClassInitialize(TestContext testContext) { random = new MersenneTwister(); coordinates = new DoubleMatrix(ProblemSize, 2); distances = new DistanceMatrix(ProblemSize, ProblemSize); for (var i = 0; i < ProblemSize; i++) { coordinates[i, 0] = random.Next(ProblemSize * 10); coordinates[i, 1] = random.Next(ProblemSize * 10); } for (var i = 0; i < ProblemSize - 1; i++) { for (var j = i + 1; j < ProblemSize; j++) { distances[i, j] = Math.Round(Math.Sqrt(Math.Pow(coordinates[i, 0] - coordinates[j, 0], 2) + Math.Pow(coordinates[i, 1] - coordinates[j, 1], 2))); distances[j, i] = distances[i, j]; } } probabilities = new DoubleArray(ProblemSize); for (var i = 0; i < ProblemSize; i++) { probabilities[i] = random.NextDouble(); } realizations = new ItemList<BoolArray>(RealizationsSize); for (var i = 0; i < RealizationsSize; i++) { var countOnes = 0; var newRealization = new BoolArray(ProblemSize); while (countOnes < 4) { //only generate realizations with at least 4 cities visited countOnes = 0; for (var j = 0; j < ProblemSize; j++) { newRealization[j] = random.NextDouble() < probabilities[j]; if (newRealization[j]) countOnes++; } } realizations.Add(newRealization); } tour = new Permutation(PermutationTypes.RelativeUndirected, ProblemSize, random); }
public virtual void Read(BinaryReader br, uint entryCount) { Name = br.ReadCString(); TypeId = br.ReadUInt16BE(); FileMask = new BoolArray(br, entryCount); }
public override IOperation Apply() { BoolArray maximization = MaximizationParameter.ActualValue; ItemArray <DoubleArray> qualities = QualitiesParameter.ActualValue; if (qualities == null) { throw new InvalidOperationException(Name + ": No qualities found."); } IScope scope = ExecutionContext.Scope; int populationSize = scope.SubScopes.Count; List <ScopeList> fronts = new List <ScopeList>(); Dictionary <IScope, List <int> > dominatedScopes = new Dictionary <IScope, List <int> >(); int[] dominationCounter = new int[populationSize]; ItemArray <IntValue> rank = new ItemArray <IntValue>(populationSize); for (int pI = 0; pI < populationSize - 1; pI++) { IScope p = scope.SubScopes[pI]; if (!dominatedScopes.ContainsKey(p)) { dominatedScopes[p] = new List <int>(); } for (int qI = pI + 1; qI < populationSize; qI++) { DominationResult test = Dominates(qualities[pI], qualities[qI], maximization); if (test == DominationResult.Dominates) { dominatedScopes[p].Add(qI); dominationCounter[qI] += 1; } else if (test == DominationResult.IsDominated) { dominationCounter[pI] += 1; if (!dominatedScopes.ContainsKey(scope.SubScopes[qI])) { dominatedScopes.Add(scope.SubScopes[qI], new List <int>()); } dominatedScopes[scope.SubScopes[qI]].Add(pI); } if (pI == populationSize - 2 && qI == populationSize - 1 && dominationCounter[qI] == 0) { rank[qI] = new IntValue(0); AddToFront(scope.SubScopes[qI], fronts, 0); } } if (dominationCounter[pI] == 0) { rank[pI] = new IntValue(0); AddToFront(p, fronts, 0); } } int i = 0; while (i < fronts.Count && fronts[i].Count > 0) { ScopeList nextFront = new ScopeList(); foreach (IScope p in fronts[i]) { if (dominatedScopes.ContainsKey(p)) { for (int k = 0; k < dominatedScopes[p].Count; k++) { int dominatedScope = dominatedScopes[p][k]; dominationCounter[dominatedScope] -= 1; if (dominationCounter[dominatedScope] == 0) { rank[dominatedScope] = new IntValue(i + 1); nextFront.Add(scope.SubScopes[dominatedScope]); } } } } i += 1; fronts.Add(nextFront); } RankParameter.ActualValue = rank; scope.SubScopes.Clear(); for (i = 0; i < fronts.Count; i++) { Scope frontScope = new Scope("Front " + i); foreach (var p in fronts[i]) { frontScope.SubScopes.Add(p); } if (frontScope.SubScopes.Count > 0) { scope.SubScopes.Add(frontScope); } } return(base.Apply()); }
private void UpdateRealizations() { var realizations = new ItemList<BoolArray>(RealizationsSize); var rand = new MersenneTwister(); for (var i = 0; i < RealizationsSize; i++) { var newRealization = new BoolArray(Probabilities.Length); var countOnes = 0; do { countOnes = 0; for (var j = 0; j < Probabilities.Length; j++) { newRealization[j] = Probabilities[j] < rand.NextDouble(); if (newRealization[j]) countOnes++; } // only generate realizations with at least 4 cities visited } while (countOnes < 4 && Probabilities.Length > 3); realizations.Add(newRealization); } Realizations = realizations; }
public BinaryVector(BoolArray elements) : this(elements.Length) { for (int i = 0; i < array.Length; i++) array[i] = elements[i]; }
/// <summary> /// Formats the database with provider. /// </summary> /// <param name="provider">The provider.</param> /// <param name="databaseName">Name of the database, maximum 63 characters long.</param> /// <param name="blockCount">The block count.</param> /// <param name="journalSectorFreq">The journal frequency.</param> /// <param name="journalSize">Size of the journal.</param> /// <param name="journalFrequency">The journal frequency, meaning depends on sector frequency.</param> /// <returns></returns> public unsafe static bool Format(IProvider provider, string databaseName, ulong blockCount, uint journalFrequency) { if (databaseName == null || databaseName == string.Empty || databaseName.Length > 63) { throw new ArgumentException("Database name was either invalid or too long."); } // 1) We first enlarge the provider (must be at least that long). if (!provider.Enlarge(blockCount)) { return(false); } // 2) We create the header node. Block block = new Block(provider.BlockSize); fixed(byte *p = block.Data) { DatabaseHeader *header = (DatabaseHeader *)p; header->BlockSize = provider.BlockSize; header->BlockCount = blockCount; header->HeaderMagic1 = DatabaseHeader.Magic1; header->HeaderMagic2 = DatabaseHeader.Magic2; header->JournalFrequency = journalFrequency; header->RootObjectAddress = 0; // Copy the name. int i; for (i = 0; i < databaseName.Length; i++) { header->DatabaseName[i] = databaseName[i]; } header->DatabaseName[i] = '\0'; } // We write it. provider.Write(0, block.Data); // Make an empty (zero block). block.ZeroMemory(); // The one allocated block. Block fullBlock = new Block(provider.BlockSize); fullBlock.ZeroMemory(); BoolArray fullBlockArray = new BoolArray(fullBlock.Data); fullBlockArray[0] = true; // 3) We clear allocation blocks. for (ulong superBlock = BlockHelper.FirstSuperBlockAddress; superBlock != 0; superBlock = BlockHelper.GetNextSuperBlock(provider.BlockSize, superBlock, blockCount)) { provider.Write(superBlock, block.Data); } for (ulong allocBlock = BlockHelper.FirstSuperBlockAddress + 1; allocBlock != 0; allocBlock = BlockHelper.GetNextAllocationBlock(provider.BlockSize, allocBlock, blockCount)) { if (JournalLog.IsJournalLog(allocBlock + 1, journalFrequency, provider.BlockSize)) { // We write the allocated. provider.Write(allocBlock, fullBlock.Data); // Next block is filled with header. if (allocBlock + 1 < blockCount) { provider.Write(allocBlock + 1, block.Data); } } else { provider.Write(allocBlock, block.Data); } } return(true); }
private DominationResult Dominates(DoubleArray left, DoubleArray right, BoolArray maximizations) { bool leftIsBetter = false, rightIsBetter = false; for (int i = 0; i < left.Length; i++) { if (IsDominated(left[i], right[i], maximizations[i])) rightIsBetter = true; else if (IsDominated(right[i], left[i], maximizations[i])) leftIsBetter = true; if (leftIsBetter && rightIsBetter) break; } if (leftIsBetter && !rightIsBetter) return DominationResult.Dominates; if (!leftIsBetter && rightIsBetter) return DominationResult.IsDominated; return DominationResult.IsNonDominated; }