示例#1
0
        public void FastStatistics(decimal x, int y1, int y2)
        {
            ObservableCollection <KeyValuePair <string, double> > fastCoding = new ObservableCollection <KeyValuePair <string, double> >();

            Golomb g = new Golomb();

            Stopwatch sw = new Stopwatch();


            for (int i = y1 - 1; i <= y2; i++)
            {
                decimal z = Convert.ToDecimal(i);

                if (i == y1 - 1)
                {
                    sw.Restart();
                    g.Encode2(x, 1);
                    sw.Stop();
                }
                else
                {
                    sw.Restart();
                    g.Encode2(x, z);
                    sw.Stop();

                    fastCoding.Add(new KeyValuePair <string, double>(z.ToString(), sw.ElapsedTicks));
                }
            }

            ShowChart(fastCoding);
        }
示例#2
0
        private void ButtonDec_Click(object sender, RoutedEventArgs e)
        {
            decodeResultTxt.Text = "Liczba: ";
            Golomb  g      = new Golomb();
            decimal result = g.Decode(numberDecTxt.Text, Convert.ToDecimal(rangeDecTxt.Text));

            decodeResultTxt.Text += result.ToString();
        }
示例#3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            encodeResultTxt.Text = "Kod: ";

            Golomb g      = new Golomb(Convert.ToDecimal(numberTxt.Text), Convert.ToDecimal(rangeTxt.Text));
            string result = g.Encode();

            encodeResultTxt.Text += result;
        }
示例#4
0
        public void LengthStatistics(decimal x, int y1, int y2)
        {
            ObservableCollection <KeyValuePair <string, int> > lengthCoding = new ObservableCollection <KeyValuePair <string, int> >();

            for (int i = y1; i <= y2; i++)
            {
                Golomb g      = new Golomb(x, i);
                string result = g.Encode();

                lengthCoding.Add(new KeyValuePair <string, int>(i.ToString(), result.Length));
            }

            ShowChart(lengthCoding);
        }
        public override void Display()
        {
            base.Display();

            Output.WriteLine("Encode sum with Golomb");
            Output.WriteLine("");

            var documents = new Documents();

            var golomb = new Golomb();

            documents.WriteByte(FilesEncoded.GolombEncodeSum, golomb.Encoder(documents.ReadAllBytes(Utils.Utils.Archive.SumFile, true)), true, Documents.Information.Golomb);

            Output.WriteLine(System.ConsoleColor.Green, "View the file encoded in: " + Utils.Utils.FilesEncoded.GolombEncodeSum.ToString());

            Input.ReadString("Press [Enter] to navigate home");
            Program.NavigateHome();
        }
        public override void Display()
        {
            base.Display();

            Output.WriteLine("Decoding Alice29.txt with Golomb Encode");
            Output.WriteLine("");

            var documents = new Documents();

            var golomb = new Golomb();

            documents.WriteText(Utils.Utils.FilesDecoded.GolombDecodeAlice, Encoding.ASCII.GetString(golomb.Decode(documents.ReadAllBytes(Utils.Utils.FilesEncoded.GolombEncodeAlice, false))));
            Output.WriteLine(System.ConsoleColor.Green, "View the file decoded in: " + Utils.Utils.FilesDecoded.GolombDecodeAlice.ToString());
            Output.WriteLine("");
            Output.WriteLine("");

            Input.ReadString("Press [Enter] to navigate home");
            Program.NavigateHome();
        }
示例#7
0
		public int Golomb( int n )
		{
			Golomb golomb		= new Golomb( n );
			Solver solver		= golomb.Solver;
			solver.IntObjective.Var		= golomb.MarkList[ golomb.MarkList.Count - 1 ];
			solver.IntObjective.Step	= 1;

			SolutionGoal solution	= new SolutionGoal( solver, solver.IntObjective.Var );

			solver.Solve(	new GoalAnd(
								new IntGenerate( solver,
									golomb.MarkList.ToArray(),
									IntVarSelector.FirstNotBound,
									new IntSearchInstantiateBest() ),
								solution ) );

			int count	= CountSolution( solver );

			return solution.Value;
		}
示例#8
0
        static public void Golomb(int n)
        {
            Golomb golomb = new Golomb(n);
            Solver solver = golomb.Solver;

            solver.IntObjective.Var  = golomb.MarkList[golomb.MarkList.Count - 1];
            solver.IntObjective.Step = 1;

            Objective objective = new Objective();

            objective.Value = int.MaxValue;
            objective.Register(solver.IntObjective);

            solver.Solve(new GoalAnd(new IntGenerate(solver,
                                                     golomb.MarkList.ToArray(),
                                                     IntVarSelector.FirstNotBound,
                                                     new IntSearchInstantiateBest()),
                                     new SolutionGoal(solver, solver.IntObjective, objective, "0")));

            SearchAll(solver);

            Console.Out.WriteLine();
            Console.Out.WriteLine(solver.Time.ToString());
        }