示例#1
0
        private void fillTableCutAndSimplexMethod(Task task)
        {
            dgvAllCuts.Rows.Clear();
              dgvAllCuts.Columns.Clear();

              dgvAllCuts.Columns.Add("det", "det");
              dgvAllCuts.Columns[0].DefaultCellStyle.BackColor = Color.LightGray;
              for (int i = 0; i < task.AllCuts.Count; i++)
            dgvAllCuts.Columns.Add((i + 1).ToString(), (i + 1).ToString());
              dgvAllCuts.Columns.Add("num", "num");

              String[] str = new String[task.AllCuts.Count + 2];
              str[0] = "det";
              for (int i = 0; i < task.AllCuts.Count; i++)
            str[i + 1] = (i + 1).ToString();
              str[task.AllCuts.Count + 1] = "num";

              dgvAllCuts.Rows.Add(str);
              dgvAllCuts.Rows[0].DefaultCellStyle.BackColor = Color.LightGray;

              List<src.SMethod.Limitation> limits = new List<src.SMethod.Limitation>();
              OrderPair pair = task.order.First();
              while (pair != null) {
            str[0] = pair.Detail.Volume.ToString();
            str[task.AllCuts.Count + 1] = pair.Num.ToString();

            limits.Add(new src.SMethod.Limitation(new double[] { }, pair.Num, src.SMethod.Limitation.Type.Equal));
            for (int i = 0; i < task.AllCuts.Count; i++) {
              str[i + 1] = task.AllCuts[i].CountOf(pair.Detail).ToString();
              limits.Last().equaLine.koeffs.Add(task.AllCuts[i].CountOf(pair.Detail));
            }
            dgvAllCuts.Rows.Add(str);
            pair = task.GetNextOrderPair(pair);
              }
              String[] str2 = new String[task.AllCuts.Count + 2];
              dgvAllCuts.Rows.Add(str2);
              str[0] = "left";
              str[task.AllCuts.Count + 1] = "";

              src.SMethod.EquaLine equa = new src.SMethod.EquaLine(new double[] { }, 0.0);
              for (int i = 0; i < task.AllCuts.Count; i++) {
            str[i + 1] = Math.Round(task.AllCuts[i].Left, 3).ToString().Replace(',', '.');
            equa.koeffs.Add(task.AllCuts[i].Left);
              }

              src.SMethod.Task sTask = new src.SMethod.Task(equa);
              foreach (src.SMethod.Limitation limit in limits)
            sTask.limitations.Add(limit);
              solver = new src.SMethod.SimplexMethodSolver(sTask);

              dgvAllCuts.Rows.Add(str);
              solver.calculateOptimalPlan();
        }
示例#2
0
        private void fillTableCutAndSimplexMethod(Task task)
        {
            dgvAllCuts.Rows.Clear();
            dgvAllCuts.Columns.Clear();

            dgvAllCuts.Columns.Add("det", "det");
            dgvAllCuts.Columns[0].DefaultCellStyle.BackColor = Color.LightGray;
            for (int i = 0; i < task.AllCuts.Count; i++)
            {
                dgvAllCuts.Columns.Add((i + 1).ToString(), (i + 1).ToString());
            }
            dgvAllCuts.Columns.Add("num", "num");

            String[] str = new String[task.AllCuts.Count + 2];
            str[0] = "det";
            for (int i = 0; i < task.AllCuts.Count; i++)
            {
                str[i + 1] = (i + 1).ToString();
            }
            str[task.AllCuts.Count + 1] = "num";

            dgvAllCuts.Rows.Add(str);
            dgvAllCuts.Rows[0].DefaultCellStyle.BackColor = Color.LightGray;

            List <src.SMethod.Limitation> limits = new List <src.SMethod.Limitation>();
            OrderPair pair = task.order.First();

            while (pair != null)
            {
                str[0] = pair.Detail.Volume.ToString();
                str[task.AllCuts.Count + 1] = pair.Num.ToString();

                limits.Add(new src.SMethod.Limitation(new double[] { }, pair.Num, src.SMethod.Limitation.Type.Equal));
                for (int i = 0; i < task.AllCuts.Count; i++)
                {
                    str[i + 1] = task.AllCuts[i].CountOf(pair.Detail).ToString();
                    limits.Last().equaLine.koeffs.Add(task.AllCuts[i].CountOf(pair.Detail));
                }
                dgvAllCuts.Rows.Add(str);
                pair = task.GetNextOrderPair(pair);
            }
            String[] str2 = new String[task.AllCuts.Count + 2];
            dgvAllCuts.Rows.Add(str2);
            str[0] = "left";
            str[task.AllCuts.Count + 1] = "";

            src.SMethod.EquaLine equa = new src.SMethod.EquaLine(new double[] { }, 0.0);
            for (int i = 0; i < task.AllCuts.Count; i++)
            {
                str[i + 1] = Math.Round(task.AllCuts[i].Left, 3).ToString().Replace(',', '.');
                equa.koeffs.Add(task.AllCuts[i].Left);
            }

            src.SMethod.Task sTask = new src.SMethod.Task(equa);
            foreach (src.SMethod.Limitation limit in limits)
            {
                sTask.limitations.Add(limit);
            }
            solver = new src.SMethod.SimplexMethodSolver(sTask);

            dgvAllCuts.Rows.Add(str);
            solver.calculateOptimalPlan();
        }