示例#1
0
文件: Cutting.cs 项目: tgr484/Diploma
 /// <summary>
 /// Создание карты первый подходящий (первоначальное размещение), затем ее оптимизируем
 /// </summary>
 public void create_ffd_cutting_map()
 {
     detailList.update_work_list();
     //Пока не обработаны все делати
     while (!detailList.check_empty_wl())
     {
         Cutting_Pattern cp            = new Cutting_Pattern(M, L);
         int             currentDetail = 0;
         //Флаг перехода к следующей детали
         bool next = false;
         while (!next)
         {
             if (cp.add_detail(detailList.work_list[currentDetail])) //Если можно добавить текущую деталь
             {
                 detailList.work_list[currentDetail].cb--;
                 continue;
             }
             else
             {
                 if (cp.h == 0 || cp.h < detailList.work_list[detailList.work_list.Count - 1].l)
                 {
                     next = true;
                 }
                 else
                 {
                     if (currentDetail < detailList.work_list.Count - 1)
                     {
                         currentDetail++;
                     }
                     else
                     {
                         next = true;
                     }
                 }
             }
         }
         cuttintgPatternList.Add(cp);
     }
 }
示例#2
0
文件: Cutting.cs 项目: tgr484/Diploma
        public void S_task()
        {
            detailList.reset_cb();
            detailList.update_work_list();
            calc_y_first();
            cuttintgPatternList.Clear();


            while (!detailList.check_empty_wl())
            {
                detailList.sort_by__y();
                calc_barier();
                Cutting_Pattern cp = new Cutting_Pattern(M, L);
                double          _f;
                double          fi;
                double          old_barier  = 0;
                int             place_count = 1;
                int             prev        = 0;
                detailList.current_detail = 0;
                bool was_step_back = false;
                while (cp.h >= detailList.calc_min() && !detailList.check_empty_wl())
                {
                    if (cp.h < detailList.work_list[detailList.current_detail].l && !was_step_back)
                    {
                        detailList.next();
                        continue;
                    }
                    _f = detailList.work_list[detailList.current_detail]._y * cp.h;
                    if (_f >= barier) // step forward //запатчтил остаток
                    {
                        if (detailList.work_list[detailList.current_detail].cb >= place_count)
                        {
                            for (int i = 0; i < place_count; ++i)
                            {
                                cp.add_detail(detailList.work_list[detailList.current_detail]);
                            }
                            detailList.work_list[detailList.current_detail].cb -= place_count;
                        }
                        else
                        {
                            for (int i = 0; i < detailList.work_list[detailList.current_detail].cb; ++i)
                            {
                                cp.add_detail(detailList.work_list[detailList.current_detail]);
                            }
                            detailList.work_list[detailList.current_detail].cb = 0;
                        }
                        fi         = detailList.work_list[detailList.current_detail].y * cp.map[detailList.work_list[detailList.current_detail].i];
                        old_barier = barier;
                        prev       = detailList.current_detail;
                        barier    -= fi;
                        detailList.next();
                        was_step_back = false;
                        place_count   = 1;
                    }
                    else // step back
                    {
                        if (was_step_back)
                        {
                            barier *= 0.8;
                            continue;
                        }
                        detailList.current_detail = prev;
                        try
                        {
                            cp.remove_detail(detailList.work_list[detailList.current_detail]);
                        }
                        catch
                        {
                            detailList.current_detail--;
                            cp.remove_detail(detailList.work_list[detailList.current_detail]);
                        }
                        detailList.work_list[detailList.current_detail].cb += place_count;
                        barier = old_barier;
                        place_count++;
                        was_step_back = true;
                    }
                }
                cuttintgPatternList.Add(cp);

                if (!detailList.check_empty_wl())
                {
                    calc_y();
                }
                //else
            }
        }