Пример #1
0
 public SolutionAgg()
 {
     atomIndices = new IndexList();
     solEq = null;
     solArea = -1;
     solType = SolutionType.UNKNOWN;
 }
Пример #2
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="project"/> is null.
		/// </exception>
		public Generator(Project project, SolutionType type)
		{
			if (project == null)
				throw new ArgumentNullException("project");

			solutionGenerator = CreateSolutionGenerator(project, type);
		}
Пример #3
0
 /// <summary>
 /// Konstruktor bezparametrowy na potrzeby serializacji
 /// </summary>
 public Solution()
 {
     id = null;
     timeoutOccured = false;
     type = SolutionType.Ongoing;
     computationsTime = 0;
     data = new byte[0];
 }
Пример #4
0
        public async Task <ActionResult> CreateSolution(SolutionType solution)
        {
            if (solution == null)
            {
                return(BadRequest());
            }

            await _solutionRepo.Create(solution);

            return(new JsonResult("Success"));
        }
Пример #5
0
        /// <summary>
        /// Konstruktor obiektów Solution
        /// </summary>
        /// <param name="_id">Id podproblemu nadane przez Task Solver</param>
        /// <param name="_timeoutOccured">Czy wystąpił timeout</param>
        /// <param name="_type">Typ rozwiązania</param>
        /// <param name="_computationsTime">Sumaryczny czas obliczeń przez wątki</param>
        /// <param name="_data">Dane rozwiązania</param>
        public Solution(UInt64? _id, Boolean _timeoutOccured, SolutionType _type, UInt64 _computationsTime, byte[] _data)
        {
            if (_data == null)
                throw new System.ArgumentNullException();

            id = _id;
            timeoutOccured = _timeoutOccured;
            type = _type;
            computationsTime = _computationsTime;
            data = _data;
        }
Пример #6
0
        private int GetLeft(SolutionType approach, MatrixRowSummary summary)
        {
            switch (approach)
            {
            case SolutionType.EvenOut:
                return(summary.Row + 1);

            default:
                return(default(int));
            }
        }
Пример #7
0
        public void AddSolutionType(string TypeName, string TypeRemark)
        {
            SolutionType solutionType = new SolutionType
            {
                Type   = TypeName,
                Remark = (TypeRemark == null ? "无" : TypeRemark)
            };

            db.SolutionTypes.Add(solutionType);
            db.SaveChanges();
            return;
        }
Пример #8
0
        public Solution(string solutionName, SolutionType solutionType, int numberOfReplicates = 3)
        {
            SolutionName = solutionName;
            SolutionType = solutionType;

            NumberOfReplicates = numberOfReplicates;

            for (int i = 0; i < numberOfReplicates; i++)
            {
                Replicates.Add(new Replicate());
            }
        }
Пример #9
0
        public List <BuildRecord> GetAvailableBuilds(PlatformType Platform, SolutionType Solution, RoleType Role, int?FirstBuildsCount = null)
        {
            var FilterBuilder = new FilterDefinitionBuilder <BuildRecord>();
            var Filter        = FilterBuilder.Eq("Platform", Platform.ToString()) &
                                FilterBuilder.Eq("Solution", Solution.ToString()) &
                                FilterBuilder.Eq("GameType", Role.ToString());

            var SortObj = Builders <BuildRecord> .Sort.Descending("datetime");

            var AvailableBuilds = SelectAvailableBuildsSortedAndLimited(Filter, SortObj, FirstBuildsCount);

            return(AvailableBuilds);
        }
Пример #10
0
        private int GenerateTreeFromMatrix(SolutionType solutionType, List <RowTree> trees, int i, ushort[,] matrix)
        {
            switch (solutionType)
            {
            case SolutionType.Sparse:
            case SolutionType.Unoptimized:
                trees.Add(mSlicer.SliceMatrix(i, matrix));
                return(trees.Count - 1);

            default:
                return(-1);
            }
        }
Пример #11
0
        public Request(SolutionType type, int ID, double allTime)
        {
            this.type = type;
            this.ID   = ID;

            this.allTime = allTime;
            this.curTime = this.allTime;
            // acceptance = true;
            // cost = 0;
            //       timeInQueue;
            //     timeProcess;
            // ID++;
        }
Пример #12
0
        private int GenerateTreeFromArray(SolutionType solutionType, List <RowTree> trees, ushort[] input)
        {
            switch (solutionType)
            {
            case SolutionType.Sparse:
            case SolutionType.Unoptimized:
                trees.Add(mSlicer.SliceRow(input));
                return(trees.Count - 1);

            default:
                return(-1);
            }
        }
Пример #13
0
        public override Dictionary <Guid, StorePackage> GetPackages(StoreContext context)
        {
            Dictionary <Guid, StorePackage> packages = new Dictionary <Guid, StorePackage>();
            WebClient wc = new WebClient();
            string    repositoryURLResolved = GetResolvedRepositoryURL(context.Web);

            wc.UseDefaultCredentials = true;
            wc.Encoding = Encoding.UTF8;

            byte[] content = wc.DownloadData(repositoryURLResolved);

            string utfString = Encoding.UTF8.GetString(content);

            string repositoryXML = wc.DownloadString(repositoryURLResolved);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(repositoryXML);

            foreach (XmlNode packageNode in doc.GetElementsByTagName("Package"))
            {
                StorePackage package = new StorePackage();

                string       title           = packageNode["Title"].InnerText;
                string       description     = packageNode["Description"].InnerText;
                string       id              = packageNode.Attributes["ID"].InnerText;
                string       authorname      = packageNode["AuthorName"].InnerText;
                string       authorURL       = packageNode["AuthorURL"].InnerText;
                string       readmeURL       = packageNode["ReadMeURL"].InnerText;
                string       packageURL      = packageNode["PackageURL"].InnerText;
                string       packageFileName = packageNode["SolutionFileName"].InnerText;
                string       setupFeatureID  = packageNode["SetupFeatureID"].InnerText;
                SolutionType type            = (SolutionType)Enum.Parse(typeof(SolutionType), packageNode["SolutionType"].InnerText);


                package.Title            = title;
                package.ID               = id;
                package.Description      = description;
                package.AuthorName       = authorname;
                package.AuthorURL        = authorURL;
                package.ReadMeURL        = readmeURL;
                package.PackageURL       = packageURL;
                package.SetupFeatureID   = setupFeatureID;
                package.SolutionFileName = packageFileName;
                package.SolutionType     = type;

                packages.Add(new Guid(id), package);
            }

            return(packages);
        }
Пример #14
0
        protected float GetVariableValue(Variable variable)
        {
            float result;

            if (SolutionType.GetType() == typeof(BinaryRealSolutionType))
            {
                result = (float)((BinaryReal)variable).Value;
            }
            else
            {
                result = (float)((Real)variable).Value;
            }
            return(result);
        }
        private double GetVariableValue(Variable variable)
        {
            double result;

            if (SolutionType.GetType() == typeof(BinaryRealSolutionType))
            {
                result = ((BinaryReal)variable).Value;
            }
            else
            {
                result = ((Real)variable).Value;
            }
            return(result);
        }
Пример #16
0
        // расчет времени на обработку заявки
        double GetServiceTime(SolutionType type)
        {
            R = new Random();
            double r = R.NextDouble();

            if (type == (SolutionType)0)
            {
                return(-1 / (Math.Log(1 - r, Math.E)));
            }
            else
            {
                return(-1 / ((0.5 + (int)(SolutionType)type / 10) * Math.Log(1 - r, Math.E)));
            }
        }
Пример #17
0
        public MaximumStableSet(ISolver solver, IGraph graph, Func <Node, double> weight = null)
        {
            Graph = graph;
            if (weight == null)
            {
                weight = n => 1.0;
            }
            Weight = weight;

            Problem problem = new Problem();

            problem.Mode = OptimizationMode.Maximize;
            foreach (Node n in graph.Nodes())
            {
                Variable v = problem.GetVariable(n);
                v.Type = VariableType.Binary;
                problem.Objective.Coefficients[v] = weight(n);
            }
            foreach (Arc a in graph.Arcs())
            {
                Node u = graph.U(a);
                Node v = graph.V(a);
                if (u != v)
                {
                    problem.Constraints.Add(problem.GetVariable(u) + problem.GetVariable(v) <= 1);
                }
            }

            Solution solution = solver.Solve(problem);

            SolutionType = solution.Type;
            Debug.Assert(SolutionType != SolutionType.Unbounded);
            if (solution.Valid)
            {
                Nodes = new HashSet <Node>();
                foreach (var kv in solution.Primal)
                {
                    if (kv.Value > 0.5)
                    {
                        Node n = (Node)kv.Key.Id;
                        Nodes.Add(n);
                    }
                }
            }
            else
            {
                Nodes = null;
            }
        }
Пример #18
0
        internal static string ToSerializedValue(this SolutionType value)
        {
            switch (value)
            {
            case SolutionType.QuickSolution:
                return("QuickSolution");

            case SolutionType.DeepInvestigation:
                return("DeepInvestigation");

            case SolutionType.BestPractices:
                return("BestPractices");
            }
            return(null);
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SolutionType = await _context.SolutionType.SingleOrDefaultAsync(m => m.SolutionTypeId == id);

            if (SolutionType == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #20
0
        private static int GetBranch(SolutionType approach, MatrixRowSummary summary)
        {
            switch (approach)
            {
            case SolutionType.DeadEnd:
            case SolutionType.Redirect:
                return(summary.Clusters[0].First);

            case SolutionType.EvenAll:
            case SolutionType.EvenOut:
                return(summary.Row);

            default:
                return(default(int));
            }
        }
Пример #21
0
 public MatrixRowSolution SetupPrimaryLevel(
     SolutionType solutionType,
     MatrixRowSummary summary,
     ushort rowDenominator,
     int treeIndex)
 {
     return(new MatrixRowSolution
     {
         Approach = solutionType,
         RowDenominator = rowDenominator,
         Branch = GetBranch(solutionType, summary),
         Left = GetLeft(solutionType, summary),
         Domain = GetDomain(solutionType, summary),
         Tree = treeIndex,
     });
 }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SolutionType = await _context.SolutionType.FindAsync(id);

            if (SolutionType != null)
            {
                _context.SolutionType.Remove(SolutionType);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #23
0
        /// <summary>
        /// Run a specific solution for a given day.
        /// </summary>
        /// <param name="day">The day.</param>
        /// <param name="type">The solution type.</param>
        /// <param name="part">The solution part.</param>
        public static void Run(int day, SolutionType type, int part)
        {
            var solutionType = types[day];

            var classAttribute = SolutionClassAttribute.GetAttribute(solutionType);

            var instance = Activator.CreateInstance(solutionType);

            var methods = solutionType.GetMethods()
                          .Where(m => SolutionMethodAttribute.GetAttribute(m) != null)
                          .ToDictionary(x => SolutionMethodAttribute.GetAttribute(x).Part);

            if (methods.ContainsKey(part))
            {
                methods[part].Invoke(instance, null);
            }
        }
        private double[] GetVariableValues(Solution solution)
        {
            double[] x = new double[3];

            if (SolutionType.GetType() == typeof(BinaryRealSolutionType))
            {
                x[0] = ((BinaryReal)solution.Variable[0]).Value;
                x[1] = ((BinaryReal)solution.Variable[1]).Value;
                x[2] = ((BinaryReal)solution.Variable[2]).Value;
            }
            else
            {
                x[0] = ((Real)solution.Variable[0]).Value;
                x[1] = ((Real)solution.Variable[1]).Value;
                x[2] = ((Real)solution.Variable[2]).Value;
            }
            return(x);
        }
Пример #25
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionDryingMaterial", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.name          = (string)info.GetValue("Name", typeof(string));
                this.isUserDefined = (bool)info.GetValue("IsUserDefined", typeof(bool));

                this.absoluteDryMaterial = CompositeSubstance.RecallSubstance(info);

                this.moisture     = Substance.RecallSubstance(info, "MoistureName");
                this.materialType = (MaterialType)info.GetValue("MaterialType", typeof(MaterialType));
                this.solutionType = (SolutionType)info.GetValue("SolutionType", typeof(SolutionType));
                this.duhringLines = (CurveF[])RecallArrayObject("DuhringLines", typeof(CurveF[]));
            }
        }
Пример #26
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (project != null)
            {
                ValidateSettings();

                try
                {
                    SolutionType solutionType = (SolutionType)cboSolutionType.SelectedIndex;
                    Generator    generator    = new Generator(project, solutionType);
                    string       destination  = txtDestination.Text;

                    GenerationResult result = generator.Generate(destination, chkSortUsing.Checked, chkXMLDocFood.Checked, Settings.Default.CompagnyName, Settings.Default.CopyrightHeader, Settings.Default.Author);
                    if (result == GenerationResult.Success)
                    {
                        if (object.Equals(cboLanguage.SelectedItem, "C# extented"))
                        {
                            // TO DO : ICSharpCode.NRefactory.CSharp. FormattingOptionsFactory

                            // TO DO : Merge old and new files!
                        }

                        MessageBox.Show(Strings.CodeGenerationCompleted,
                                        Strings.CodeGeneration, MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else if (result == GenerationResult.Error)
                    {
                        MessageBox.Show(Strings.CodeGenerationFailed,
                                        Strings.Error, MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else // Cancelled
                    {
                        this.DialogResult = DialogResult.None;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Strings.UnknownError,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #27
0
        private int GetDomain(SolutionType approach, MatrixRowSummary summary)
        {
            switch (approach)
            {
            case SolutionType.EvenAll:
            {
                return(Solver.WrapRange(0, summary.NoOfNonZeroPercents - 1, summary.NoOfStates));
            }

            case SolutionType.EvenOut:
                return(Solver.WrapRange(
                           summary.Row + 1,
                           summary.Row - 1,
                           summary.NoOfStates));

            default:
                return(default(int));
            }
        }
Пример #28
0
        public ShenzhenTypes(ModuleDefinition module)
        {
            Module  = module;
            BuiltIn = module.TypeSystem;

            GameLogic      = new GameLogicType(module);
            Globals        = new GlobalsType(module);
            Index2         = new Index2Type(module);
            L              = new LType(module);
            MessageThread  = new MessageThreadType(module);
            MessageThreads = new MessageThreadsType(module);
            Optional       = new OptionalType(module);
            Puzzle         = new PuzzleType(module);
            Puzzles        = new PuzzlesType(module);
            Terminal       = new TerminalType(module);
            TextureManager = new TextureManagerType(module);
            Traces         = new TracesType(module);

            Solution = new SolutionType(module, Traces);
        }
Пример #29
0
        public ActionResult EditSolutionType(SolutionTypeViewModel solutionType)
        {
            if (ModelState.IsValid)
            {
                SolutionType type = _solutionTypeService.GetSolutionType(solutionType.ID);
                type.Type = solutionType.Type.Trim();

                try
                {
                    _solutionTypeService.SaveSolutionType();
                }
                catch (Exception ex)
                {
                    return(View(solutionType).WithError(ex.Message));
                }
            }
            else
            {
                return(View(solutionType).WithError("Invalid Data"));
            }

            return(RedirectToAction("SolutionTypes").WithSuccess("Solution type " + solutionType.Type + " updated successfully."));
        }
Пример #30
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (project != null)
            {
                ValidateSettings();

                try
                {
                    SolutionType solutionType = (SolutionType)cboSolutionType.SelectedIndex;
                    Generator    generator    = new Generator(project, solutionType);
                    string       destination  = txtDestination.Text;

                    GenerationResult result = generator.Generate(destination);
                    if (result == GenerationResult.Success)
                    {
                        MessageBox.Show(Strings.CodeGenerationCompleted,
                                        Strings.CodeGeneration, MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else if (result == GenerationResult.Error)
                    {
                        MessageBox.Show(Strings.CodeGenerationFailed,
                                        Strings.Error, MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else                     // Cancelled
                    {
                        this.DialogResult = DialogResult.None;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Strings.UnknownError,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #31
0
        public ActionResult CreateSolutionType(SolutionTypeViewModel solutionType)
        {
            if (ModelState.IsValid)
            {
                SolutionType newType = new SolutionType();
                newType.Type        = solutionType.Type.Trim();
                newType.DateCreated = DateTime.Now;
                try
                {
                    _solutionTypeService.CreateSolutionType(newType);
                    _solutionTypeService.SaveSolutionType();
                }
                catch (Exception ex)
                {
                    return(View(solutionType).WithError(ex.Message));
                }
            }
            else
            {
                return(View(solutionType).WithError("Invalid data"));
            }

            return(RedirectToAction("SolutionTypes").WithSuccess("Solution type" + solutionType.Type + " created successfully."));
        }
Пример #32
0
		protected virtual SolutionGenerator CreateSolutionGenerator(Project project, SolutionType type)
		{
			return new VSSolutionGenerator(project, type);
		}
Пример #33
0
 /// <summary>
 /// Konstruktor obiektów Solution
 /// </summary>
 /// <param name="_timeoutOccured">Czy wystąpił timeout</param>
 /// <param name="_type">Typ rozwiązania</param>
 /// <param name="_computationsTime">Sumaryczny czas obliczeń przez wątki</param>
 /// <param name="_data">Dane rozwiązania</param>
 public Solution(Boolean _timeoutOccured, SolutionType _type, UInt64 _computationsTime, byte[] _data)
     : this(null, _timeoutOccured, _type, _computationsTime, _data)
 {
 }
Пример #34
0
 public Solution(float[] fs)
 {
     solutions = fs; type = SolutionType.Some;
 }
Пример #35
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="solution">solution</param>
 public XReal(Solution solution)
 {
     type          = solution.Type;
     this.solution = solution;
 }
Пример #36
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="project"/> is null.
		/// </exception>
		public VSSolutionGenerator(Project project, SolutionType version) : base(project)
		{
			Version = version;
		}
Пример #37
0
 /// <exception cref="ArgumentNullException">
 /// <paramref name="model"/> is null.
 /// </exception>
 public CSharpProjectGenerator(Model model, SolutionType solutionType) : base(model)
 {
     this.solutionType = solutionType;
 }
Пример #38
0
 public Solution(SolutionType _type)
 {
     type = _type;
 }
Пример #39
0
        internal static void Main()
        {
            Console.SetWindowSize(Console.LargestWindowWidth - 3, Console.LargestWindowHeight - 3);
            ShowWindow(GetConsoleWindow(), 3); //maximize

            ConsoleKeyInfo readKey;

            Console.WriteLine("C# or F# :>");

            do
            {
                readKey = Console.ReadKey(true);
            }while (readKey.Key != ConsoleKey.C && readKey.Key != ConsoleKey.F);

            SolutionType solutionType = (readKey.Key == ConsoleKey.C) ? SolutionType.C : SolutionType.F;

            LoadProblems(solutionType);

            do
            {
                Logger.Clear();
                Logger.WriteLine(Yellow, "Project Euler Solutions");
                Logger.WriteLine(Yellow, "  http://www.projecteuler.net");
                Logger.WriteLine();
                Logger.WriteLine(Yellow, "  Using {0}# solutions", solutionType);
                Logger.WriteLine();

                Logger.Write(White, "Enter problem number (l to list, c to check all): ");
                string str = Console.ReadLine();

                if (str == "l")
                {
                    ListProblems();
                }
                else if (str == "c")
                {
                    CheckSolutions();
                }
                else
                {
                    int problemNumber;
                    int.TryParse(str, out problemNumber);

                    BaseProblem problem = StartProblem(problemNumber);

                    Logger.Clear();
                    Logger.Write(Yellow, "Problem: ");
                    Logger.WriteLine(White, problem.Number);
                    Logger.WriteLine();
                    Logger.WriteLine(Yellow, "Date Set");
                    Logger.WriteLine(White, problem.DateSet.ToLongDateString());
                    Logger.WriteLine();
                    Logger.WriteLine(Yellow, "Title");
                    Logger.WriteLine(White, problem.Title);
                    Logger.WriteLine();
                    Logger.WriteLine(Yellow, "Description");
                    Logger.WriteLine(White, problem.Description);
                    Logger.WriteLine();
                    Logger.Write(Yellow, "Expected Answer: ");

                    if (problem.ExpectedAnswer != null)
                    {
                        Logger.WriteLine(White, problem.ExpectedAnswer.Value);
                    }
                    else
                    {
                        Logger.WriteLine(Red, "Unknown");
                    }

                    Logger.WriteLine();
                    TimerBlock timer = new TimerBlock();

                    BaseSolution solution;

                    if (solutions.TryGetValue(problem.Number, out solution))
                    {
                        long answer;

                        using (timer.Time())
                        {
                            answer = solution.GetAnswer();
                        }

                        Logger.Write(Yellow, "Answer:          ");
                        Logger.WriteLine(White, answer);
                        Logger.WriteLine();
                        Logger.Write(Yellow, "Time Taken:      ");
                        Logger.WriteLine(White, timer.LastLap);
                    }
                    else
                    {
                        Logger.Write(Red, "No Solution Found");
                    }
                }

                Logger.WriteLine();
                Logger.WriteLine();
                Logger.WriteLine(ConsoleColor.Gray, "Press any key to continue...");
                readKey = Console.ReadKey();
            }while (readKey.Key != ConsoleKey.Escape);
        }
Пример #40
0
		/// <exception cref="ArgumentNullException">
		/// <paramref name="model"/> is null.
		/// </exception>
		public CSharpProjectGenerator(ClassModel model, SolutionType solutionType) : base(model)
		{
			this.solutionType = solutionType;
		}