public void LoadBenchmark()
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.ShowDialog();
            string pathToLoad = dialog.FileName;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Benchmark));
                FileStream filestream = new FileStream(pathToLoad, FileMode.Open, FileAccess.Read, FileShare.Read);

                Benchmark benchmark = (Benchmark)serializer.Deserialize(filestream);
                filestream.Close();

                // before setting benchmark, clear the screen
                // clear screen
                global.Verschnittoptimierung.display.Invalidate();

                global.benchmark = benchmark;

                // also create a basic solution
                SolutionManagement solutionManagement = new SolutionManagement();
                solutionManagement.CreateBasicSolution(global, global.benchmark);

                // show benchmark
                Show show = new Show(global);
                show.ShowBenchmark(global.benchmark);

                System.Windows.Forms.MessageBox.Show("Benchmark was loaded successfully.");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Benchmark could not be loaded. Please make sure to select the correct file path.");
            }
        }
 public void DrawNewDisplay()
 {
     if(global.contentToShow.Equals("benchmark"))
     {
         Show show = new Show(global);
         show.ShowBenchmark(global.benchmark);
     }
     else if (global.contentToShow.Equals("solution"))
     {
         Show show = new Show(global);
         show.ShowSolution(global.solution);
     }
 }
        public void SetContentToShow()
        {
            // clear screen
            global.Verschnittoptimierung.display.Invalidate();

            Show show = new Show(global);
            if(global.contentToShow.Equals("benchmark"))
            {
                show.ShowSolution(global.solution);
            }
            else if(global.contentToShow.Equals("solution"))
            {
                show.ShowBenchmark(global.benchmark);
            }
        }
        public void ExecuteStep(int stepType)
        {
            Base global = Base.GetInstance();
            Show show = new Show(global);
            Tools tools = new Tools();

            global.Verschnittoptimierung.Output.Text = "";

            // for testing only
            if (global.Verschnittoptimierung.comboBox1.Text.Equals("Create Board(s) + Objects"))
            {

            }

            // reset displayed values
            if (global.runningProcess.existing == false)
            {
                global.Verschnittoptimierung.cl_evolutionMue.Text = "";
                global.Verschnittoptimierung.cl_evolutionLambda.Text = "";
            }

            switch (global.Verschnittoptimierung.comboBox1.Text)
            {

                // old, not existing anymore. Objects+board created when creating benchmark, including an empty solution
                case "Create Board(s) + Objects":

                    // get board values from user interface
                    float generalBoardHeight = (float)(global.Verschnittoptimierung.boardHeight.Value);
                    float generalBoardWidth = (float)(global.Verschnittoptimierung.boardWidth.Value);
                    if(generalBoardHeight >= generalBoardWidth)
                    {
                        float h = generalBoardWidth;
                        generalBoardWidth = generalBoardHeight;
                        generalBoardHeight = h;
                    }

                    // set global board values in Base/global
                    global.generalBoardHeight = generalBoardHeight;
                    global.generalBoardWidth = generalBoardWidth;

                    CalculateMult();

                    // global.boardGap = Convert.ToInt32(0.1 * global.generalBoardHeight);

                    // create and draw board(s)

                    Creation creation = new Creation();
                    creation.CreateBoards();
                    DrawBoards();
                    break;
                case "Create Benchmark":
                    // 1. step: verify benchmark information
                    if(global.Verschnittoptimierung.boardHeight.Value <= global.Verschnittoptimierung.boardWidth.Value &&
                        global.Verschnittoptimierung.objectsMinNumber.Value <= global.Verschnittoptimierung.objectsMaxNumber.Value)
                    {
                        // before creating benchmark clear the screen
                        // clear screen
                        global.Verschnittoptimierung.display.Invalidate();
                        global.bestSolution = null;
                        global.Verschnittoptimierung.button_useBestSolution.Enabled = false;

                        // create benchmark
                        Benchmark benchmark = new Benchmark();
                        //benchmark.BoardList = new List<Board>();
                        BenchmarkManagement benchmarkManagement = new BenchmarkManagement();
                        benchmarkManagement.CreateBenchmark(global, benchmark);
                        benchmarkManagement.CreateRects(Convert.ToInt32(global.Verschnittoptimierung.objectsMinNumber.Value)
                            , Convert.ToInt32(global.Verschnittoptimierung.objectsMaxNumber.Value), benchmark);
                        global.benchmark = benchmark;
                        // info: benchmark (boards with rects that fit exactly) created

                        // also create a basic solution
                        SolutionManagement solutionManagement = new SolutionManagement();
                        solutionManagement.CreateBasicSolution(global, global.benchmark);

                        show.ShowBenchmark(global.benchmark);
                    }
                    else
                    {
                        // not enough information entered or too much information entered
                        System.Windows.Forms.MessageBox.Show("Not enough information specified or wrong information. Check the min, max fields.");
                        /*
                        FolderBrowserDialog fbd = new FolderBrowserDialog();
                    DialogResult result = fbd.ShowDialog();

                    string[] files = Directory.GetFiles(fbd.SelectedPath);
                    System.Windows.Forms.MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
                    */
                    }
                    break;
                case "Fill":
                    // lock fill radio buttons
                    tools.LockFillButtons();

                    // get type from what was entered
                    int type = 0;

                    // check if no process exists, create one
                    if(global.runningProcess.existing == false)
                    {
                        global.runningProcess.type = 0;

                        global.runningProcess.existing = true;
                        global.runningProcess.state = 0;
                        // 0 = single step, 1 = all remaining steps
                        global.runningProcess.stepType = stepType;
                        global.runningProcess.firstStep = true;

                        /*
                        // background worker
                        global.Verschnittoptimierung.backgroundWorker1.RunWorkerAsync();
                        */
                    }
                    // if a process exists, but of another process type
                    else if(global.runningProcess.existing == true && global.runningProcess.type != type)
                    {
                        global.Verschnittoptimierung.Output.Text = "Another process is already running. Please complete this process first.";
                        break;
                    }

                    // if a process exists of the same type
                    else if(global.runningProcess.existing == true && global.runningProcess.type == type)
                    {
                        // check if the process is running or waiting
                        // if waiting, do another step or all steps
                        if(global.runningProcess.state == 0)
                        {
                            // set params and reactivate process
                                // single step or all steps
                            global.runningProcess.stepType = stepType;
                            /*
                                // process makes the next step or all remaining steps, depending on stepType
                            global.runningProcess.autoResetEvent.Set();
                            */
                        }
                        // if running
                        else if(global.runningProcess.state == 1)
                        {
                            global.Verschnittoptimierung.Output.Text = "The process is already running. Please wait.";
                            break;
                        }
                    }

                    // check if a valid solution + benchmark exist

                    if(global.solution != null && global.benchmark != null && global.solution.benchmark != null
                        && global.solution.BoardList != null && global.solution.BoardList.Count > 1)
                    {
                        show.ShowSolution(global.solution);

                        int selection = 1;

                        // greedy 1
                        if(selection == 1)
                        {
                            Fill fill = new Fill();
                            if(global.Verschnittoptimierung.radioButton_BestFit.Checked)
                            {
                                fill.Greedy(false, new Solution());
                            }
                            if(global.Verschnittoptimierung.radioButton_FirstFit.Checked)
                            {
                                global.Verschnittoptimierung.Output.Text = "@info: \"First Fit\" not implemented";
                                global.runningProcess.existing = false;
                            }

                        }

                    }
                    else
                    {
                        global.Verschnittoptimierung.Output.Text = "At least one global element is null. Cannot fill.";
                        tools.UnlockFillButtons();
                    }

                    // unlock fill radio buttons
                    if(global.runningProcess.existing == false)
                    {
                        tools.UnlockFillButtons();
                    }

                    break;
                case "Evolutionary Algorithm":
                    // lock EvAlg entry
                    tools.LockEvAlgButtons();

                    // set entered evAlg values
                    global.mue = Convert.ToInt32(global.Verschnittoptimierung.evAlg_mue.Value);
                    global.multForLambda = Convert.ToInt32(global.Verschnittoptimierung.evAlg_mult.Value);
                    global.lambda = global.mue * global.multForLambda;
                    global.mutationRate = (float)global.Verschnittoptimierung.evAlg_mutationRate.Value;
                    tools.SaveSelectedGreedies();
                    global.tournamentPopulation = global.Verschnittoptimierung.checkBox_greedyTournamentPopulation.Checked;
                    global.tournamentGreediesOnly = global.Verschnittoptimierung.checkBox_greedyTournamentProceduresOnly.Checked;

                    // 1. verification
                    // check if a valid solution + benchmark exist

                    if (global.solution != null && global.benchmark != null && global.solution.benchmark != null
                        && global.solution.BoardList != null && global.solution.BoardList.Count > 1)
                    {
                        // check if 'emptySolution' exists (the unchanged basic solution)
                        if (global.emptySolution == null)
                        {
                            global.Verschnittoptimierung.Output.Text = "global.emptySolution is null";
                            break;
                        }
                        // check parameters entered at evolutionary algorithm
                        int numberGreedies = tools.GetNumberSelectedGreedies();
                        if ((!(numberGreedies > 2) || (numberGreedies < global.mue) || numberGreedies < global.multForLambda) &&
                            !(global.tournamentPopulation && global.tournamentGreediesOnly))
                        {
                            global.Verschnittoptimierung.Output.Text = "You need to select more greedy procedures.";
                            tools.UnlockEvAlgButtons();
                            break;
                        }
                        if (global.mutationRate > (global.emptySolution.BoardList.Count - 1))
                        {
                            global.Verschnittoptimierung.Output.Text = "The mutation rate cannot be larger than the number of boards.";
                            tools.UnlockEvAlgButtons();
                            break;
                        }

                        // check if no process exists, create one
                        if (global.runningProcess.existing == false)
                        {
                            global.runningProcess.type = 1;

                            global.runningProcess.existing = true;
                            global.runningProcess.state = 0;
                            // 0 = single step, 1 = all remaining steps
                            global.runningProcess.stepType = stepType;
                            global.runningProcess.firstStep = true;

                            // set display values
                            global.Verschnittoptimierung.cl_evolutionMue.Text = global.mue.ToString();
                            global.Verschnittoptimierung.cl_evolutionLambda.Text = global.lambda.ToString();

                        }
                        // if a process exists, but of another process type
                        else if (global.runningProcess.existing == true && global.runningProcess.type != 1)
                        {
                            global.Verschnittoptimierung.Output.Text = "Another process is already running. Please complete this process first.";
                            break;
                        }

                        // if a process exists of the same type
                        else if (global.runningProcess.existing == true && global.runningProcess.type == 1)
                        {
                            // check if the process is running or waiting
                            // if waiting, do another step or all steps
                            if (global.runningProcess.state == 0)
                            {
                                // set params and reactivate process
                                // single step or all steps
                                global.runningProcess.stepType = stepType;
                            }
                            // if running
                            else if (global.runningProcess.state == 1)
                            {
                                global.Verschnittoptimierung.Output.Text = "The process is already running. Please wait.";
                                break;
                            }
                        }

                        // 2. execute
                        EvolutionaryAlgorithm evolutionaryAlgorithm = new EvolutionaryAlgorithm();
                        evolutionaryAlgorithm.BombingAlgorithm();
                    }
                    else
                    {
                        global.Verschnittoptimierung.Output.Text = "At least one global element is null. Cannot use EvAlg.";
                        tools.UnlockEvAlgButtons();
                    }

                    // unlock EvAlg entry
                    if (global.runningProcess.existing == false)
                    {
                        tools.UnlockEvAlgButtons();
                    }

                    break;
                default:
                    break;
            }

            /*
            //global.Verschnittoptimierung.display.;
            using (Graphics g = global.Verschnittoptimierung.display.CreateGraphics())
            {
                using (Pen pen = new Pen(Color.Black, 2))
                {
                    Brush brush = new SolidBrush(Color.DarkBlue);
                    g.TranslateTransform(global.Verschnittoptimierung.display.AutoScrollPosition.X, global.Verschnittoptimierung.display.AutoScrollPosition.Y);
                    g.DrawRectangle(pen, 100, 100, 100, 200);
                }
            }
            */
        }
        public void LoadSolution()
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.ShowDialog();
            string pathToLoad = dialog.FileName;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Solution));
                FileStream filestream = new FileStream(pathToLoad, FileMode.Open, FileAccess.Read, FileShare.Read);

                Solution solution = (Solution)serializer.Deserialize(filestream);
                filestream.Close();

                // before setting solution and benchmark, clear the screen
                // clear screen
                global.Verschnittoptimierung.display.Invalidate();

                global.solution = solution;

                // also set global benchmark to the benchmark of the solution
                global.benchmark = solution.benchmark;

                // cl values
                ClassificationNumbers clNumbers = new ClassificationNumbers(global);
                clNumbers.GetAndShowAllClassificationNumbers();

                // show solution
                Show show = new Show(global);
                show.ShowSolution(global.solution);

                System.Windows.Forms.MessageBox.Show("Solution was loaded successfully.");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Solution could not be loaded. Please make sure to select the correct file path.");
            }
        }
예제 #6
0
 private void button_useBestSolution_Click(object sender, EventArgs e)
 {
     Base global = Base.GetInstance();
     if(global.runningProcess.existing == true)
     {
         global.Verschnittoptimierung.Output.Text = "Process running. Please finish this process first.";
     }
     else if(global.solution != null && global.bestSolution != null)
     {
         Show show = new Show(global);
         Tools tools = new Tools();
         global.solution = tools.CloneSolution(global.bestSolution);
         show.ShowSolution(global.solution);
         ClassificationNumbers classificationNumbers = new ClassificationNumbers(global);
         classificationNumbers.GetAndShowAllClassificationNumbers();
         button_useBestSolution.Enabled = false;
     }
 }
예제 #7
0
        public Solution Greedy(Boolean evolution, Solution solutionEvo)
        {
            Base global = Base.GetInstance();
            Solution solution;
            if(evolution)
            {
                solution = solutionEvo;
            }
            else
            {
                solution = global.solution;
            }

            ClassificationNumbers classificationNumbers = new ClassificationNumbers(global);

            // preparations
            if(!evolution)
            {
                global.runningProcess.state = 1;
            }
            Tools tools = new Tools();

            // START one time:
            if (evolution || global.runningProcess.firstStep)
            {
                // next rect to pick of the list: the first one (default)
                if(!evolution)
                {
                    global.runningProcess.nextStep = 0;
                }
                else
                {
                    global.nextStepGreedyEvo = 0;
                }

                global.positionsManaged = new List<Position>();
                global.positionsValid = new List<Position>();

                if((global.Verschnittoptimierung.radioButton_largestSideInc.Checked && !evolution) ||
                    (evolution && global.selectedGreedy == 1) ||
                    (evolution && global.selectedGreedy == 2) ||
                    (evolution && global.selectedGreedy == 9) ||
                    (evolution && global.selectedGreedy == 10)
                    )
                {
                    // sort rects from min largest side to max largest side
                    tools.QuickSortRectByLargestSizeInc(0,
                        solution.BoardList[solution.BoardList.Count - 1].RectList.Count - 1, solution.BoardList[solution.BoardList.Count - 1].RectList);
                }
                else if((global.Verschnittoptimierung.radioButton_largestSideDec.Checked && !evolution) ||
                    (evolution && global.selectedGreedy == 3) ||
                    (evolution && global.selectedGreedy == 4) ||
                    (evolution && global.selectedGreedy == 11) ||
                    (evolution && global.selectedGreedy == 12)
                    )
                {
                    // sort rects from min largest side to max largest side
                    tools.QuickSortRectByLargestSideDec(0,
                        solution.BoardList[solution.BoardList.Count - 1].RectList.Count - 1, solution.BoardList[solution.BoardList.Count - 1].RectList);
                }
                else if((global.Verschnittoptimierung.radioButton_sizeInc.Checked) ||
                    (evolution && global.selectedGreedy == 5) ||
                    (evolution && global.selectedGreedy == 6) ||
                    (evolution && global.selectedGreedy == 13) ||
                    (evolution && global.selectedGreedy == 14)
                    )
                {
                    // sort rects from min size to max size
                    tools.QuickSortRectBySizeInc(0,
                        solution.BoardList[solution.BoardList.Count - 1].RectList.Count - 1, solution.BoardList[solution.BoardList.Count - 1].RectList);
                }
                else if((global.Verschnittoptimierung.radioButton_sizeDec.Checked) ||
                    (evolution && global.selectedGreedy == 7) ||
                    (evolution && global.selectedGreedy == 8) ||
                    (evolution && global.selectedGreedy == 15) ||
                    (evolution && global.selectedGreedy == 16)
                    )
                {
                    // sort rects from max size to min size
                    tools.QuickSortRectBySizeDec(0,
                        solution.BoardList[solution.BoardList.Count - 1].RectList.Count - 1, solution.BoardList[solution.BoardList.Count - 1].RectList);
                }
                if(!evolution)
                {
                    global.runningProcess.firstStep = false;
                }
            }
            // END one time

            // for each rect on collectionBoard
            for (int i = (evolution ? global.nextStepGreedyEvo : global.runningProcess.nextStep);
                i < solution.BoardList[solution.BoardList.Count - 1].RectList.Count;)
            {
                if(!evolution)
                {
                    global.runningProcess.state = 1;
                }

                // sort boards from max free space to least free space
                List<int> boardNrSorted = tools.SortBoardsBySize(solution.BoardList);

                // for each board try to place the rect
                for (int j = 0; j < boardNrSorted.Count - 1; j++)
                {
                    // try place the rect
                    // 1. is the space as area enough for the board? (without finding a specific place)
                    // calculate boardSizeEffective
                    int boardSizeEffective = solution.BoardList[boardNrSorted[j]].size;
                    for (int k = 0; k < solution.BoardList[boardNrSorted[j]].RectList.Count; k++)
                    {
                        boardSizeEffective -= solution.BoardList[boardNrSorted[j]].RectList[k].size;
                    }
                    if (boardSizeEffective < solution.BoardList[solution.BoardList.Count - 1].RectList[i].size)
                    {
                        // rect is too large, cannot be placed on any of the boards.
                        // has to remain on the collectionBoard
                        if(!evolution)
                        {
                            classificationNumbers.GetAndShowAllClassificationNumbers();
                        }
                        break;
                    }

                    // 2. try to place the rect in the selected board
                    // clone the rect
                    Rect rect = new Rect();
                    rect.edgeLeftUp = new MyPoint();
                    rect.edgeRightDown = new MyPoint();
                    rect.rectID = solution.BoardList[solution.BoardList.Count - 1].RectList[i].rectID;
                    rect.size = solution.BoardList[solution.BoardList.Count - 1].RectList[i].size;
                    rect.width = solution.BoardList[solution.BoardList.Count - 1].RectList[i].width;
                    rect.height = solution.BoardList[solution.BoardList.Count - 1].RectList[i].height;
                    /*
                    rect.edgeLeftUp.x = solution.BoardList[solution.BoardList.Count - 1].RectList[i].edgeLeftUp.x;
                    rect.edgeLeftUp.y = solution.BoardList[solution.BoardList.Count - 1].RectList[i].edgeLeftUp.y;
                    rect.edgeRightDown.x = solution.BoardList[solution.BoardList.Count - 1].RectList[i].edgeRightDown.x;
                    rect.edgeRightDown.y = solution.BoardList[solution.BoardList.Count - 1].RectList[i].edgeRightDown.y;
                    */

                    // reset values in global
                    global.positionsManaged = new List<Position>();
                    global.positionsValid = new List<Position>();
                    global.bestPositionSet = false;

                    // TODO: this part(vertical, then horizontal / or only one if equal) should be moved to GetValidPos()
                    // first vertical, then horizontal
                    if (rect.width == rect.height)
                    {
                        rect.edgeLeftUp.x = 0;
                        rect.edgeLeftUp.y = rect.height;
                        rect.edgeRightDown.x = rect.width;
                        rect.edgeRightDown.y = 0;

                        GetValidPositions(solution.BoardList[boardNrSorted[j]].RectList, rect, evolution);
                    }
                    else
                    {
                        // 1. vertical
                        if (rect.width > rect.height)
                        {
                            int helper = rect.width;
                            rect.width = rect.height;
                            rect.height = helper;
                        }
                        rect.edgeLeftUp.x = 0;
                        rect.edgeLeftUp.y = rect.height;
                        rect.edgeRightDown.x = rect.width;
                        rect.edgeRightDown.y = 0;

                        GetValidPositions(solution.BoardList[boardNrSorted[j]].RectList, rect, evolution);
                        // 2. horizontal
                        if (rect.height > rect.width)
                        {
                            int helper = rect.width;
                            rect.width = rect.height;
                            rect.height = helper;
                        }
                        rect.edgeLeftUp.x = 0;
                        rect.edgeLeftUp.y = rect.height;
                        rect.edgeRightDown.x = rect.width;
                        rect.edgeRightDown.y = 0;

                        GetValidPositions(solution.BoardList[boardNrSorted[j]].RectList, rect, evolution);
                    }

                    // select the best position of the valid ones
                    SelectBestPosition(evolution);

                    Boolean rectPlaced = false;

                    if (global.bestPositionSet == true)
                    {
                        // 1. show valid positions

                        // 2. show best position

                        // 3. place best position
                        rect.edgeLeftUp.x = global.bestPosition.edgeLeftUp.x;
                        rect.edgeLeftUp.y = global.bestPosition.edgeLeftUp.y;
                        rect.edgeRightDown.x = global.bestPosition.edgeRightDown.x;
                        rect.edgeRightDown.y = global.bestPosition.edgeRightDown.y;

                        solution.BoardList[boardNrSorted[j]].RectList.Add(rect);
                        //solution.BoardList[solution.BoardList.Count - 1].RectList.Remove(rect);
                        solution.BoardList[solution.BoardList.Count - 1].RectList.RemoveAt(i);

                        // ....
                        rectPlaced = true;
                        // show can't be called from here

                        if(!evolution)
                        {
                            // check for best solution and set if necessary
                            tools.CheckForBestSolution();

                            // show solution
                            Show show = new Show(global);
                            show.ShowSolution(global.solution);
                        }
                    }

                    // last rect tried?
                    if (solution.BoardList[solution.BoardList.Count - 1].RectList.Count == 0 ||
                        (solution.BoardList[solution.BoardList.Count - 1].RectList.Count - 1) < (evolution ? global.nextStepGreedyEvo : global.runningProcess.nextStep))
                    {
                        if(!evolution)
                        {
                            global.runningProcess.existing = false;
                            global.runningProcess.state = 0;
                            classificationNumbers.GetAndShowAllClassificationNumbers();
                        }
                        break;
                    }

                    if (rectPlaced)
                    {
                        if(!evolution)
                        {
                            global.runningProcess.state = 0;
                            classificationNumbers.GetAndShowAllClassificationNumbers();
                        }
                        break;
                    }
                    if (!rectPlaced)
                    {
                        if(!evolution)
                        {
                            global.runningProcess.nextStep++;
                        }
                        else
                        {
                            global.nextStepGreedyEvo++;
                        }
                        i++;

                        if ((solution.BoardList[solution.BoardList.Count - 1].RectList.Count - 1) < (evolution ? global.nextStepGreedyEvo : global.runningProcess.nextStep))
                        {
                            if(!evolution)
                            {
                                global.runningProcess.existing = false;
                                global.runningProcess.state = 0;
                                classificationNumbers.GetAndShowAllClassificationNumbers();
                            }
                            break;
                        }
                    }
                }

                if(!evolution && global.runningProcess.stepType == 0)
                {
                    global.runningProcess.state = 0;
                    classificationNumbers.GetAndShowAllClassificationNumbers();
                    break;
                }
            }
            if(!evolution)
            {
                global.runningProcess.state = 0;
                classificationNumbers.GetAndShowAllClassificationNumbers();
            }
            return solution;
        }
        // used after the first step and after each regular step
        public void EndStepBombingAlgorithm()
        {
            Base global = Base.GetInstance();
            // set new population and delete the rest
            global.populationSmall = SelectBestXElements();
            global.populationLarge = new List<PopulationElement>();
            // set best population element of the new population
            global.bestPopulationElement = SelectBestElement(false);

            if (global.solution != global.bestPopulationElement.solution)
            {
                global.changeCounter = 0;
            }
            else
            {
                global.changeCounter++;
            }

            global.solution = global.bestPopulationElement.solution;

            // check for best solution and set if necessary
            Tools tools = new Tools();
            tools.CheckForBestSolution();

            ClassificationNumbers classificationNumbers = new ClassificationNumbers(global);
            classificationNumbers.GetAndShowAllClassificationNumbers();
            Show show = new Show(global);
            show.ShowSolution(global.solution);

            // show/update fitness chart
            global.evolutionStep++;
            global.Verschnittoptimierung.fitnessChart.Series["best"].Points.AddXY(global.evolutionStep, global.populationSmall[0].fitnessValue);
            global.Verschnittoptimierung.fitnessChart.Series["worst"].Points.AddXY(global.evolutionStep, global.populationSmall[global.populationSmall.Count - 1].fitnessValue);

            // hide running process display
            global.Verschnittoptimierung.processRunning_gear.Visible = false;
            global.Verschnittoptimierung.processRunning_label.Visible = false;
        }
예제 #9
0
        public void Reset()
        {
            Base global = Base.GetInstance();

            // reset all rects
            for(int i=0; i<global.solution.BoardList.Count -1; i++)
            {
                while(global.solution.BoardList[i].RectList.Count != 0)
                {
                    global.solution.BoardList[global.solution.BoardList.Count - 1].RectList.Add(global.solution.BoardList[i].RectList[0]);
                    global.solution.BoardList[i].RectList.RemoveAt(0);
                }
            }
            // reset running process/fill values
            global.runningProcess.existing = false;
            global.positionsManaged = new List<Position>();
            global.positionsValid = new List<Position>();
            global.bestPositionSet = false;

            Show show = new Show(global);
            show.ShowSolution(global.solution);

            global.mue = 0;
            global.lambda = 0;
            global.Verschnittoptimierung.fitnessValue.Text = "";
            ClassificationNumbers classificationNumbers = new ClassificationNumbers(global);
            classificationNumbers.GetAndShowAllClassificationNumbers();
            UnlockFillButtons();
            UnlockEvAlgButtons();

            Tools tools = new Tools();
            tools.CleanFitnessChart();

            global.Verschnittoptimierung.processRunning_gear.Visible = false;
            global.Verschnittoptimierung.processRunning_label.Visible = false;
        }