QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2857|回复: 8
打印 上一主题 下一主题

E题代码以及UI界面设计

[复制链接]
字体大小: 正常 放大
478867049        

2

主题

9

听众

53

积分

升级  50.53%

  • TA的每日心情

    2014-11-30 17:11
  • 签到天数: 14 天

    [LV.3]偶尔看看II

    自我介绍
    478867049

    社区QQ达人

    跳转到指定楼层
    1#
    发表于 2014-10-3 17:58 |只看该作者 |正序浏览
    |招呼Ta 关注Ta
    乘用车函数
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace LogisticsPlanningProblem
    {
       public class Car
        {
           public int quantity;
           public double length;
           public double width;
           public double height;
           public double real_width;
           public double real_length;
           //public double real_length_edge;
           //public double real_length_intermediate;
           public int[] maxCarryByLength;//每辆一列最多携带的数量
           public int[] carryNeedTran;//整数部分需要运输的数量
           public int[] canCarryByOneTran;//每辆整车最多携带的数量
           public double[] waste;//一列上浪费的空间
           public int pointer;//分配指针,当前指针未分配
           public int type;
           public int[] remainNeedTran;
           public int remainCarNotAssgined;
           public double[] remainSpace;
            public int no;
           public Car(int no, int type, double length, double width, double height,int quantity)
           {
               this.no = no;
               this.type = height > 1.7 ? 3 : 1;
               this.real_length = length + 0.1;
               this.real_width = width + 0.05;
               this.height = height;
               this.quantity = quantity;
               pointer = 0;
           }
           public Car(int type, int quantity)
           {
               this.type = type;
               this.quantity = quantity;
               switch (type)
               {
                    case 1:
                        length = 4.61;
                        width = 1.7;
                        height = 1.51;
                        break;
                    case 2:
                        length = 3.615;
                       width = 1.605;
                        height = 1.394;
                        break;
                    case 3:
                        length = 4.63;
                        width = 1.785;
                        height = 1.77;
                        break;
                    default:
                        break;
               }
               real_width = width + 0.05;
               real_length = length + 0.1;
               pointer = 0;
               //real_length_intermediate = length + 0.1;
               //real_length_edge = length + 0.05;
           }
           public void CalcRemainSpace(List<Transporter>  Tran)
           {
               remainSpace = new double[Tran.Count];
               for (int i = 0; i < Tran.Count; i++)
               {
                    remainSpace =Tran.real_length - remainCarNotAssgined * real_length;
               }
           }
           public void CalcRemainNeedCar(List<Transporter>  Tran)
           {
               remainNeedTran = new int[Tran.Count];
               remainCarNotAssgined = quantity - pointer;//剩余未分配的车
               
               for (int i = 0; i < Tran.Count; i++)
               {
                    remainNeedTran =(int)(remainCarNotAssgined / canCarryByOneTran);
               }
               CalcRemainSpace(Tran);
           }
           //为每种车计算一列最多携带的数量,需要的车的数目
           public void CalcMaxCarry(List<Transporter> Tran)
           {
               remainNeedTran = new int[Tran.Count];
               maxCarryByLength = new int[Tran.Count];
               carryNeedTran = new int[Tran.Count];
               waste = new double[Tran.Count];
               canCarryByOneTran = newint[Tran.Count];
               remainCarNotAssgined = quantity - pointer;
               for (int i = 0; i < Tran.Count;i++)
               {
                    maxCarryByLength =(int)(Tran.real_length / real_length);
                   if (height < 1.7)
                    {
                        canCarryByOneTran =(maxCarryByLength * (Tran.columnDownCount + Tran.columnUp));
                        
                    }
                    else
                    {
                        canCarryByOneTran =maxCarryByLength;
                    }
                    carryNeedTran = (int)(quantity/ canCarryByOneTran);
                    waste = Tran.real_length% real_length;
                    remainNeedTran =(int)(remainCarNotAssgined / canCarryByOneTran);
               }
           }
        }
    }
    轿运车函数
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace LogisticsPlanningProblem
    {
       public class Transporter
        {
            public double length;
           public double width_up;
           public double width_down;
           //上下列的数量
           public int columnUp;
           public int columnDownCount;
           public int quantity;
           public int remainTran;
           public List<double[]> Space;
           public int[] AssignNo;
           public int type;
           public double real_length;
           public int TranUsed;
           public Transporter(int type, double length, double width_up, doublewidth_down, int columnUp, int columnDown, int quantity)
           {
               Space = new List<double[]>();
               AssignNo = new int[quantity];
               for (int i = 0; i < quantity; i++)
               {
                    AssignNo = 0;
               }
               remainTran = quantity;
               this.quantity = quantity;
               this.type = type;
               this.real_length = length + 0.1;
               this.width_down = width_down;
               this.width_up = width_up;
               this.columnDownCount = columnDown;
               this.columnUp = columnUp;
               for (int i = 0; i < quantity; i++)
                    Space.Add(new double[] {real_length, real_length * (int)(type / 3), real_length, real_length *(int)(type / 2) });
           }
           public Transporter(int type)
           {
                TranUsed = 0;
               this.type = type;
               quantity = 0;
               switch (type)
               {
                    case 1:
                        length = 19;
                        width_up = 2.7;
                        width_down = 2.7;
                       columnUp = 1;
                        columnDownCount = 1;
                        break;
                    case 2:
                        length = 24.3;
                        width_up = 3.5;
                        width_down = 2.7;
                        columnUp = 2;
                        columnDownCount = 1;
                        break;
                    case 3:
                        length = 19;
                        width_up = 3.5;
                        width_down = 3.5;
                        columnUp = 2;
                        columnDownCount = 2;
                        break;
                    default:
                        break;
               }
               real_length = length + 0.1;
           }
           public int MinMod(int[] para)
           {
               return 1;
           }
           public static void main()
           {
           }
        }
    }      
    Hash函数映射Excel表格
    # w: O0 Y/ k9 J. ~8 I! s
    private void ReadExcel_Tran()
           {
               //string strFileName = @"C:\Users\clu2\Desktop\result.xlsx";
               string strFileName = textBoxInputTran.Text;
               inputName = strFileName.Split('\\')[strFileName.Split('\\').Length -1].Split('.')[0];
               if (!File.Exists(strFileName))
               {
                    //MessageBox.Show("Doesnot exist the excel file !");
                    return;
               }
               _Application myExcel = new Microsoft.Office.Interop.Excel.Application();
                myExcel.Visible = false;
               _Workbook myBook = myExcel.Workbooks.Open(strFileName, Type.Missing,
                                Type.Missing,
                                Type.Missing,
                                Type.Missing,
                                Type.Missing,
                               XlSaveAsAccessMode.xlNoChange,
                                Type.Missing,
                                Type.Missing,
                                Type.Missing,
                                Type.Missing,
                                Type.Missing);
               _Worksheet mySheet = (_Worksheet)myBook.Worksheets[1];
               g_Tran = new List<Transporter>();
               int pointerNo = 2;
                while (!(mySheet.get_Range('A' +pointerNo.ToString(), Type.Missing).Value2 == null))
               {
                    int no =Convert.ToInt32(mySheet.get_Range('A' + pointerNo.ToString(),Type.Missing).Value2);
                    String type = mySheet.get_Range('B'+ pointerNo.ToString(), Type.Missing).Value2.ToString();
                    String real_type = type.Split('')[type.Split(' ').Length - 1];
                    double len =mySheet.get_Range('C' + pointerNo.ToString(), Type.Missing).Value2;
                    double wid =Convert.ToDouble(mySheet.get_Range('D' + pointerNo.ToString(),Type.Missing).Value2);
                    double hei =Convert.ToDouble((mySheet.get_Range('E' + pointerNo.ToString(),Type.Missing).Value2));
                    int haveCount =Convert.ToInt32((mySheet.get_Range('F' + pointerNo++.ToString(),Type.Missing).Value2));
                    String t =real_type.Trim().Trim('');
                    if (t.Equals("1-1"))
                    {
                        g_Tran.Add(newTransporter(1, len, wid, hei, 1, 1, haveCount));
                    }
                    else if(t.Equals("1-2"))
                    {
                        g_Tran.Add(newTransporter(2, len, wid, hei, 1, 2, haveCount));
                    }
                    else
                    {
                       g_Tran.Add(newTransporter(3, len, wid, hei, 2, 2, haveCount));
                    }
               }
               myExcel.Workbooks.Close();
               System.Runtime.InteropServices.Marshal.ReleaseComObject(myExcel);
               GC.Collect();
            }
           #endregion
           #region Form Operations
           private void buttonInput_Click(object sender, EventArgs e)
           {
               String path = fileSelector();
               if (path != null && !path.Equals(""))
                   textBoxInputCar.Text = path;
           }
           private void buttonOutput_Click(object sender, EventArgs e)
           {
               String path = fileFolderSelector();
               if (path != null && !path.Equals(""))
                    textBoxOutput.Text = path;
           }
            private String fileSelector()
           {
               OpenFileDialog ofd = new OpenFileDialog();
               ofd.ShowDialog();
               return ofd.FileName;
           }
           private String fileFolderSelector()
           {
               FolderBrowserDialog fbd = new FolderBrowserDialog();
               fbd.ShowDialog();
               return fbd.SelectedPath;
           }
           private void buttonCalc_Click(object sender, EventArgs e)
           {
               //if (radioButton2.Checked)
               //{
               //    int[] val1 = new int[] {(int)numericUpDownA1.Value, (int)numericUpDownA2.Value,(int)numericUpDownA3.Value };
               //    int[] val2 = new int[] {(int)numericUpDownB1.Value, (int)numericUpDownB2.Value,(int)numericUpDownB3.Value };
               //    int[] val3 = new int[] {(int)numericUpDownC1.Value, (int)numericUpDownC2.Value,(int)numericUpDownC3.Value };
               //    int[] val4 = new int[] {(int)numericUpDownD1.Value, (int)numericUpDownD2.Value,(int)numericUpDownD3.Value };
               //    ht.Add('A' + rowPointer++.ToString(),"A");
               //    Do(val1);
               //    ht.Add('A' +rowPointer++.ToString(), "B");
               //    Do(val2);
               //    ht.Add('A' +rowPointer++.ToString(), "C");
               //    Do(val3);
               //    ht.Add('A' +rowPointer++.ToString(), "D");
               //    Do(val4);
               //    ht.Add('A' +rowPointer++.ToString(), "以上为方案1,整车方式");
               //    rowPointer++;
               //    ht.Add('A' +rowPointer++.ToString(), "方案2,卸货方式");
               //    ht.Add('A' +rowPointer++.ToString(), "A");
               //    int[] res1 =DoWithoutRemain(val1);
               //    ht.Add('A' +rowPointer++.ToString(), "B");
               //    int[] res2 =DoWithoutRemain(val2);
               //    ht.Add('A' + rowPointer++.ToString(),"C");
               //    int[] res3 =DoWithoutRemain(val3);
               //    ht.Add('A' +rowPointer++.ToString(), "D");
               //    int[] res4 =DoWithoutRemain(val4);
               //    ht.Add('A' + rowPointer++.ToString(),"一起运输");
               //    int remain0 = res1[0] +res2[0] + res3[0] + res4[0];
               //    MessageBox.Show(res1[1] +" " + res2[1] + " " + res3[1] + " " + res4[1]);
               //    int remain1 = res1[1] +res2[1] + res3[1] + res4[1];
                   
               //    int remain3 = res1[2] +res2[2] + res3[2] + res4[2];
               //    List<Car> ps = newList<Car>();
               //    Do(new int[] { remain0,remain1, remain3 });
               //}
               //else
               //{
               //    Do();
               //}
               ReadExcel_Car();
               ReadExcel_Tran();
               Question5();
               GenerateExcel();
           }
           #endregion
           private void button1_Click(object sender, EventArgs e)
            {
               String path = fileFolderSelector();
               if (path != null && !path.Equals(""))
                    textBoxInputTran.Text = path;
           }
        }
    }

    " l  B" D) p1 \" j$ g* f. j0 n" \$ {5 E" x( O
    " S$ Z' r" z. p, x+ b. {
    # X9 I1 w$ o, N$ E9 a

    $ m( _5 k* s% X' Y/ H7 [8 M# }
    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信

    2

    主题

    11

    听众

    181

    积分

    升级  40.5%

  • TA的每日心情

    2016-9-19 14:13
  • 签到天数: 71 天

    [LV.6]常住居民II

    社区QQ达人

    群组数学建模培训课堂1

    群组数学建模算法之matlab

    群组2016算法集锦(上)

    群组2015国赛优秀论文解析

    群组2016研赛备战群组

    回复

    使用道具 举报

    5

    主题

    7

    听众

    404

    积分

    升级  34.67%

  • TA的每日心情
    奋斗
    2016-9-19 01:13
  • 签到天数: 103 天

    [LV.6]常住居民II

    社区QQ达人

    群组第三届数模基础实训

    群组2013认证赛A题讨论群组

    群组2013认证赛B题讨论群组

    群组2013认证赛C题讨论群组

    群组2013数模夏令营A题

    回复

    使用道具 举报

    shuhongwu        

    2

    主题

    8

    听众

    710

    积分

  • TA的每日心情
    开心
    2014-4-12 11:56
  • 签到天数: 30 天

    [LV.5]常住居民I

    2011挑战赛参赛者

    自我介绍
    数模爱好者

    群组国赛讨论

    478867049 发表于 2014-10-7 20:23 5 |' A+ A% X% n9 N2 l' \
    请读下题意
    # X8 z7 y% K0 q, y) x: y: \
    受层高限制,高度超过1.7米的乘用车只能装在1-1、1-2型下层。type的可选值为1,2,3。而表达式height > 1.7 ? 3 : 1只提供了两个可选值。我是这么理解二者的差异的,你觉得呢?
    回复

    使用道具 举报

    478867049        

    2

    主题

    9

    听众

    53

    积分

    升级  50.53%

  • TA的每日心情

    2014-11-30 17:11
  • 签到天数: 14 天

    [LV.3]偶尔看看II

    自我介绍
    478867049

    社区QQ达人

    深V礼 发表于 2014-10-6 13:48 - u* O, ~# F$ t; M
    楼主好厉害的样子啊

    1 @5 s  K- B, i还好的,小硕一枚
    回复

    使用道具 举报

    478867049        

    2

    主题

    9

    听众

    53

    积分

    升级  50.53%

  • TA的每日心情

    2014-11-30 17:11
  • 签到天数: 14 天

    [LV.3]偶尔看看II

    自我介绍
    478867049

    社区QQ达人

    shuhongwu 发表于 2014-10-7 18:49   Z) h* y: }  \2 m
    乘用车函数4 v0 o: n3 O9 O/ h7 V9 n
    (1)this.type = height > 1.7 ? 3 : 1;  是否需要更改?高度小于1.7m的有型号I和型号II乘用车 ...
    ' P( t6 }4 K3 s. R, r
    请读下题意
    回复

    使用道具 举报

    shuhongwu        

    2

    主题

    8

    听众

    710

    积分

  • TA的每日心情
    开心
    2014-4-12 11:56
  • 签到天数: 30 天

    [LV.5]常住居民I

    2011挑战赛参赛者

    自我介绍
    数模爱好者

    群组国赛讨论

    乘用车函数6 R- t6 ^8 Z' R9 ]  f/ u, E4 x) |' R+ a
    (1)this.type = height > 1.7 ? 3 : 1;  是否需要更改?高度小于1.7m的有型号I和型号II乘用车,而不单单是型号I乘用车。
    8 d1 E6 R6 z  ~& I% r  t* A4 O4 t(2)this.real_length = length + 0.1;  是否需要更改为real_length_intermediate = length + 0.1,real_length_edge = length + 0.15,间距存在于前后或者两列乘用车之间,中间部 分每辆乘用车的real_length应该至少自增0.1,边沿部分每辆乘用车的real_length应该至少自增0.15。
    , Q" Z! g/ h0 V' \( X5 E- o+ M& Q, @(3)remainSpace =Tran.real_length - remainCarNotAssgined * real_length;明显的错误,剩余的空间应该是轿运车的长度减去(已放置乘用车数量乘以对应每辆乘用车的长度)。$ I$ [3 r8 y7 z  F

    0 d" O8 T; K- z, Q0 J( g: q轿运车函数
    ! h* ~) F! w  E- ~+ C3 J(1)this.real_length = length + 0.1; 此处0.1是否需要删除?length自增0.1的意义是什么?
    5 [# ]& L9 q6 q9 B/ `# i8 Y7 a
    6 x0 h' e6 L7 y8 u: a' R0 IHash函数映射Excel表格
    1 R' s- {9 t5 F  `* X8 d(1)g_Tran.Add(newTransporter(2, len, wid, hei, 1, 2, haveCount));应该调整为g_Tran.Add(newTransporter(2, len, wid, hei, 2, 1, haveCount)),因为下、上层分别装载1、2列, 记为1-2型。
    / ?5 ]3 ~: a8 G' q
    回复

    使用道具 举报

    1

    主题

    13

    听众

    182

    积分

    升级  41%

  • TA的每日心情
    开心
    2017-1-12 08:48
  • 签到天数: 58 天

    [LV.5]常住居民I

    自我介绍
    建模爱好者

    社区QQ达人

    群组2014国赛优秀论文解析

    群组2014研究生数学建模竞

    群组国赛讨论

    回复

    使用道具 举报

    深V礼        

    246

    主题

    24

    听众

    8718

    积分

  • TA的每日心情
    慵懒
    2014-11-8 19:08
  • 签到天数: 55 天

    [LV.5]常住居民I

    管理员

    超级版主

    版主

    发帖功臣 新人进步奖 优秀斑竹奖 金点子奖 原创写作奖 最具活力勋章 助人为乐奖 风雨历程奖

    楼主好厉害的样子啊

    点评

    478867049  还好的,小硕一枚  详情 回复 发表于 2014-10-7 20:27
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2026-4-21 19:52 , Processed in 0.771807 second(s), 96 queries .

    回顶部