public void CreateNew() { Solutions.Clear(); Title = string.Format(R.solutionCollection, ++counter); Filename = null; Modified = false; }
/// <summary> /// Initialize/reset the integration method /// </summary> /// <param name="behaviors">Truncation behaviors</param> public virtual void Initialize(BehaviorList <BaseTransientBehavior> behaviors) { // Initialize variables Time = 0.0; _savetime = 0.0; Delta = 0.0; Order = 1; Prediction = null; DeltaOld.Clear(0.0); Solutions.Clear((Vector <double>)null); // Get parameters BaseParameters = Parameters.Get <IntegrationParameters>(); // Register default truncation methods _transientBehaviors = behaviors; if (BaseParameters.TruncationMethod.HasFlag(IntegrationParameters.TruncationMethods.PerDevice)) { Truncate += TruncateDevices; } if (BaseParameters.TruncationMethod.HasFlag(IntegrationParameters.TruncationMethods.PerNode)) { Truncate += TruncateNodes; } // Last point was START so the current point is the point after a breakpoint (start) Break = true; }
public List <Interval> Solve() { Solutions.Clear(); int k = 0; Moore(X, ref k); Count = k; return(Solutions); }
public override void Solve() { Solutions.Clear(); AlreadyFoundCloseds = new HashSet <Vector2Int>(); NextElements = new Queue <Vector2Int>(); allcloseds = new Dictionary <Vector2Int, int>(); uniquehiddens = new HashSet <Vector2Int>(); hiddensinorder = new List <Vector2Int>(); Vector2Int first = closedrefs.First().Key; AlreadyFoundCloseds.Add(first); SolveNext(first); }
protected void OnDataModified(object sender, EventArgs e) { try { _timer.Stop(); Solutions.Clear(); FillResultGrid(); _timer.Start(); } catch (Exception ex) { _log.Error(ex.ToString()); } }
public void RefreshSolutions() { if (ProblemId != -1) { var sols = RunCreationClient.Instance.GetSolutions(ProblemId).Select(OKBSolution.Convert).ToList(); foreach (var sol in sols) { sol.DownloadData(); } Solutions.Replace(sols); } else { Solutions.Clear(); } }
public void Reset() { LastRunCognCapacity = -1.0f; Elements.Clear(); Solutions.Clear(); //NumMinPlacementSlots = Constants.MIN_PLACEMENT_SLOTS; //NumMaxPlacementSlots = Constants.TOTAL_NUM_VIEW_SLOTS; //VisibilityReward = Constants.INITIAL_VISIBILITY_REWARD; //WeightImportance = Constants.INITIAL_WEIGHT_IMPORTANCE; //WeightUtility = 1.0f - Constants.INITIAL_WEIGHT_IMPORTANCE; //CognLoadOnsetPenalty = Constants.INITIAL_COGNITIVE_LOAD_ONSET_PENALTY; //CognLoadOnsetPenaltyDecay = Constants.INITIAL_COGNITIVE_LOAD_ONSET_PENALTY_DECAY_TIMESTEPS; }
/// <summary> /// Parsing of the CDKRGraph. This is the main method /// to perform a query. Given the constrains sourceBitSet and targetBitSet /// defining mandatory elements in G1 and G2 and given /// the search options, this method builds an initial set /// of starting nodes (targetBitSet) and parses recursively the /// CDKRGraph to find a list of solution according to /// these parameters. /// </summary> /// <param name="sourceBitSet">constrain on the graph G1</param> /// <param name="targetBitSet">constrain on the graph G2</param> /// <param name="findAllStructure">true if we want all results to be generated</param> /// <param name="findAllMap">true is we want all possible 'mappings'</param> /// <param name="timeManager"></param> /// <exception cref="CDKException"></exception> public void Parse(BitArray sourceBitSet, BitArray targetBitSet, bool findAllStructure, bool findAllMap, TimeManager timeManager) { // initialize the list of solution CheckTimeOut(); // initialize the list of solution Solutions.Clear(); // builds the set of starting nodes // according to the constrains BitArray bitSet = BuildB(sourceBitSet, targetBitSet); // setup options SetAllStructure(findAllStructure); SetAllMap(findAllMap); // parse recursively the CDKRGraph ParseRec(new BitArray(bitSet.Count), bitSet, new BitArray(bitSet.Count)); }
public void Dispose() { workerTokenSrc.Cancel(); StopRlmDbWorkersSessions(); StopRlmDbWorkersCases(); BestSolutions?.Clear(); BestSolutionStaging?.Clear(); Sessions?.Clear(); Rneurons?.Clear(); Solutions?.Clear(); if (SessionsQueueToCreate != null && SessionsQueueToCreate.Count > 0) { Session removedSess; foreach (var item in SessionsQueueToCreate) { SessionsQueueToCreate.TryDequeue(out removedSess); } } if (SessionsQueueToUpdate != null && SessionsQueueToUpdate.Count > 0) { Session removedSess; foreach (var item in SessionsQueueToUpdate) { SessionsQueueToUpdate.TryDequeue(out removedSess); } } DynamicInputs?.Clear(); DynamicOutputs?.Clear(); if (GPUMode) { if (rneuronProcessor is IDisposable) { (rneuronProcessor as IDisposable).Dispose(); } } }
public void OpenExisting(ref string filename) { if (filename == null) { VistaOpenFileDialog ofd = new VistaOpenFileDialog { Title = R.openFileTitle, Filter = R.saveAsFilter, }; bool?result = ofd.ShowDialog(); if (!result.HasValue || !result.Value) { return; } filename = ofd.FileName; } XDocument doc = XDocument.Load(filename); if (!(doc.Root is XElement eltSolutionCollection)) { return; } Solutions.Clear(); Title = Path.GetFileNameWithoutExtension(filename); Filename = filename; foreach (XElement eltSolution in eltSolutionCollection.Elements("Solution")) { Solution solution = Solution.OpenSolution(eltSolution.Attribute("filename")?.Value); SolutionItem solutionItem = AddSolution(solution); solutionItem.IsActive = bool.Parse(eltSolution.Attribute("isActive")?.Value ?? "true"); solutionItem.SelectedConfiguration = eltSolution.Attribute("selectedConfiguration")?.Value; } SelectedConfiguration = eltSolutionCollection.Attribute("configuration")?.Value; Modified = false; }
/// <summary> /// Save a solution for future integrations /// </summary> /// <param name="solution">The solution</param> public void SaveSolution(Vector <double> solution) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } // Now, move the solution vectors around if (Solutions[0] == null) { // No solutions yet, so allocate vectors Solutions.Clear(index => new DenseVector <double>(solution.Length)); Prediction = new DenseVector <double>(solution.Length); solution.CopyTo(Solutions[0]); } else { // Cycle through solutions Solutions.Cycle(); solution.CopyTo(Solutions[0]); } }
public void Solve(Vector2Int[] hiddens) { Solutions.Clear(); int combs = 0; localbitarrays = new BitArray(hiddens.Length, false); BitArray cbitarray = localbitarrays; while (cbitarray.TryIncrementBitArray()) { combs++; List<Vector2Int> ccombination = new List<Vector2Int>(); for (int i = 0; i < hiddens.Length; i++) { if (cbitarray[i]) { ccombination.Add(hiddens[i]); } } if (IsSatisfyingCombination(ccombination, closedrefs)) { Solutions.Add(ccombination); } } //Debug.Log(combs + " combination"); }
public void Clear() { pf = new PolyFunc(); Solutions.Clear(); Log.Clear(); }
public void Solve() { ensureDataLoaded(); Boards.Clear(); Solutions.Clear(); var level = 1; MaxLevelReached = 1; Combinations.Clear(); var totalCombinations = GetTotalCombinations(); Combinations.Add(totalCombinations); var prevCombinations = totalCombinations; var boardSize = Math.Max(_data.Width, _data.Height); while (true) { // get all possible combinations of nr+1 indexes, so that we can filter the possibilities away // nr=0 means the possible combinations are just one of each perpendicular rows or columns // nr=1 means possibilities are weighed against every combination in any two perpendicular rows or columns,etc var piRows = getAllPossibleIndexes(_data.Height, level); filterPossibilities(_colPossibilities, _rowPossibilities, piRows); // filter column possibilities by rows totalCombinations = GetTotalCombinations(); addCombinationNr(totalCombinations); generateBoard(); // generates a board with partial results if (prevCombinations != totalCombinations) { level = 1; } Debug.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}"); Console.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}"); var piCols = getAllPossibleIndexes(_data.Width, level); filterPossibilities(_rowPossibilities, _colPossibilities, piCols); // filter row possibilities by columns totalCombinations = GetTotalCombinations(); if (totalCombinations <= 1) { break; } addCombinationNr(totalCombinations); generateBoard(); // generates a board with partial results if (prevCombinations == totalCombinations) { if (level <= boardSize && level < MaxPuzzleLevel) { level++; if (level > MaxLevelReached) { MaxLevelReached = level; } } else { Debug.WriteLine("Maximum puzzle level reached"); Console.WriteLine("Maximum puzzle level reached. Starting brute force (it will take a while, please wait...)"); break; } } else { level = 1; } Debug.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}"); Console.WriteLine($"Combinations so far: {totalCombinations}, level: {level}, max level reached: {MaxLevelReached}"); prevCombinations = totalCombinations; } // fill all possible solutions from the remaining column and row possibilities generateSolutions(); }
private void Start(object o) { Solutions.Clear(); double dIn = Input.Delta; double dOut = Output.Delta; double k1 = (Input.Negative * dOut / dIn - Output.Negative) / Voltage2; double k2 = dOut / dIn; double r3 = 10_000; double r6 = r3; double r4 = r3 / k1; double r5 = (r3 + r4) * r6 / k2 / r4 - r6; IdealSolution = new SchemeSolution() { R3 = r3, R4 = r4, R5 = r5, R6 = r6 }; List <SchemeSolution> solutions = new List <SchemeSolution>(); for (int i = 0; i < Helper.E24.Count; i++) { r3 = Helper.E24[i] * 10_000; for (int j = 0; j < Helper.E24.Count; j++) { r6 = Helper.E24[j] * 10_000; r4 = r3 / k1; r5 = (r3 + r4) * r6 / k2 / r4 - r6; //var solution = new SchemeSolution() { R3 = r3, R4 = Helper.Round(r4), R5 = Helper.Round(r5), R6 = r6 }; // solutions.Add(solution); var solution = new SchemeSolution() { R3 = r3, R4 = Helper.RoundUp(r4), R5 = Helper.RoundUp(r5), R6 = r6 }; solutions.Add(solution); solution = new SchemeSolution() { R3 = r3, R4 = Helper.RoundDown(r4), R5 = Helper.RoundUp(r5), R6 = r6 }; solutions.Add(solution); solution = new SchemeSolution() { R3 = r3, R4 = Helper.RoundUp(r4), R5 = Helper.RoundDown(r5), R6 = r6 }; solutions.Add(solution); solution = new SchemeSolution() { R3 = r3, R4 = Helper.RoundDown(r4), R5 = Helper.RoundDown(r5), R6 = r6 }; solutions.Add(solution); } } var sorted = solutions.Where(s => { var outNeg = s.UOut(Input.Negative, Voltage2); var outPos = s.UOut(Input.Positive, Voltage2); return(outNeg > 0 && outPos > 0 && Math.Abs(outNeg - Output.Negative) < 0.2 && Math.Abs(outPos - Output.Positive) < 0.2); }).OrderBy(s => Math.Abs(s.UOut(Input.Negative, Voltage2) - Output.Negative) + Math.Abs(s.UOut(Input.Positive, Voltage2) - Output.Positive)); foreach (var solution in sorted) { Solutions.Add(solution); } SelectedSolution = Solutions.First(); }