关于货物物品横竖摆放的问题

货车内宽是2.4米。考虑到最多装载,长宽130×100的货品,应该横竖摆放。

横竖摆放的数量如何自动计算呢?

采用数学公式,计算如下:

横向摆放数=(int)(横长+竖高)*数量/4/横长

竖向摆放数=数量-横向摆放数

结果如下:

横长130160
竖宽10080
公式横向摆放数=(int)(横长+竖高)*数量/4/横长
数量横向摆放竖向摆放横向摆放竖向摆放
10.44230810.3751
20.88461520.752
31.32692321.1252
41.76923131.53
52.21153831.8754
62.65384642.254
73.09615442.6255
83.538462535
93.98076963.3756
104.42307763.757
114.86538574.1257
125.30769274.58
135.7584.8759
146.19230885.259
156.63461595.62510
167.0769239610
177.519231106.37511
187.961538116.7512
198.403846117.12512
208.846154127.513

非常不理想!!

困惑三天,想的解决方法如下(计算两行货物长度最小值):

    struct HangGeshu
    {
        public int hang1ge, hang2ge;
    }
       private HangGeshu getHengshuShuliang(int heng,int shu,int shuliang,Boolean youxianheng)
        {
            HangGeshu hangGeshu = new HangGeshu();
            if (shuliang > 1)
            {
                hangGeshu.hang1ge = shuliang / 2;
                if (youxianheng)
                {
                    hangGeshu.hang1ge++;
                }
                else
                {
                    hangGeshu.hang1ge--;
                }
                hangGeshu.hang2ge = shuliang - hangGeshu.hang1ge;
                //货物横竖摆放,目标长度差值最小 (1 横放 2 竖放)
                int cha0 = Math.Abs(hangGeshu.hang1ge * heng - hangGeshu.hang2ge * shu);
                int chaold = cha0;
                Boolean key = true;
                while (key)
                {
                    cha0 = Math.Abs((hangGeshu.hang1ge-1) * heng - (hangGeshu.hang2ge+1) * shu);
                    if (cha0 < chaold)
                    {
                        chaold = cha0;
                        hangGeshu.hang1ge--;
                        hangGeshu.hang2ge++;
                    }
                    else
                    {
                        key = false;
                    }
                }
                key = true;
                while (key)
                {
                    cha0 = Math.Abs((hangGeshu.hang1ge + 1) * heng - (hangGeshu.hang2ge - 1) * shu);
                    if (cha0 < chaold)
                    {
                        chaold = cha0;
                        hangGeshu.hang1ge++;
                        hangGeshu.hang2ge--;
                    }
                    else
                    {
                        key = false;
                    }
                }
            }
            else
            {
                if (youxianheng)
                {
                    hangGeshu.hang1ge = 1;
                    hangGeshu.hang2ge = 0;
                }
                else
                {
                    hangGeshu.hang1ge = 0;
                    hangGeshu.hang2ge = 1;
                }
            }
            return hangGeshu;
        }
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值