QQ登录

只需要一步,快速开始

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

【分段函数】【多周期】【最大值问题】

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

2

主题

7

听众

6

积分

升级  1.05%

该用户从未签到

自我介绍
自信的孩纸
跳转到指定楼层
1#
发表于 2012-11-28 17:58 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
各位零友,谁知道怎么把下面的代码改成多个周期的y值之和最小吗?
比如说6个周期,自变量x(1)~x(6)始终在【200,1500】之间,求y(1)+y(2)+y(3)+y(4)+y(5)+y(6)最值。
代码如下
Model:
SETS:
Points/1..4/: b, c, y, z;        ! 端点数为4,即分段数为3;
ENDSETS
DATA:
b=0 500 1000 1500;
c=0 5000 9000 12000;
y=,,,0;        ! 增加的虚拟变量y(4)=0;
ENDDATA
Max= 4.8*x11 + 4.8*x21 + 5.6*x12 + 5.6*x22 - @sum(Points: c*z);
x11+x12 < x + 500;
x21+x22 < 1000;
0.5*x11 - 0.5*x21 > 0;  
0.4*x12 - 0.6*x22 > 0;
@sum(Points: b*z)=x;
@for(Points(i)|i#eq#1: z(i) <= y(i));
@for(Points(i)|i#ne#1: z(i) <= y(i-1)+y(i));
@sum(Points: y)=1;
@sum(Points: z)=1;
@for(Points: @bin(y));
end
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
olh2008 实名认证       

88

主题

42

听众

1万

积分

船长

  • TA的每日心情
    开心
    2018-9-1 14:36
  • 签到天数: 86 天

    [LV.6]常住居民II

    邮箱绑定达人 优秀斑竹奖 新人进步奖 发帖功臣 最具活力勋章 元老勋章 原创写作奖 风雨历程奖

    群组Latex研学群

    群组数学建模

    群组Mathematica研究小组

    群组LINGO

    群组Matlab讨论组

    你说到了周期及自变量和目标函数,但是没有说具体的函数表达式。光看你的代码也不清楚你建的模型,你能不能仔细描述一下你的问题?
    回复

    使用道具 举报

    ustb_zxc        

    2

    主题

    7

    听众

    6

    积分

    升级  1.05%

    该用户从未签到

    自我介绍
    自信的孩纸
    olh2008 发表于 2012-11-28 22:31
    你说到了周期及自变量和目标函数,但是没有说具体的函数表达式。光看你的代码也不清楚你建的模型,你能不能 ...

    【问题补充】分段函数如下所示:
    y=10*x              0<x<=500
    y=8*x+1000   500<x<=1000
    y=-x+9000  1000<x<=1500
    在period(1..6)6个周期中,x>=a,a=(300,800,1300,1400,600,900),求@sum(y)的最大值。
    回复

    使用道具 举报

    sorjor        

    2

    主题

    9

    听众

    485

    积分

    升级  61.67%

  • TA的每日心情
    开心
    2015-10-29 00:36
  • 签到天数: 75 天

    [LV.6]常住居民II

    自我介绍
    智能优化,多目标优化

    邮箱绑定达人

    你第一个模型好像是个例子,你下面的模型可以通过lingo10以上的版本中的子模型来求解。

    程序如下(我不知道我有没有正确的理解你的模型)

    model:
    sets:
    ys/1..6/:a;
    endsets

    data:
    a=300 800 1300 1400 600 900;
    enddata


    submodel obj1:
    x>=a(1);
    y=@if(x#LE#500,10*x,@if(x#LE#1000,8*x+1000,-x+9000));
    max=y;
    endsubmodel

    submodel obj2:
    x>=a(2);
    y=@if(x#LE#500,10*x,@if(x#LE#1000,8*x+1000,-x+9000));
    max=y;
    endsubmodel

    submodel obj3:
    x>=a(3);
    y=@if(x#LE#500,10*x,@if(x#LE#1000,8*x+1000,-x+9000));
    max=y;
    endsubmodel

    submodel obj4:
    x>=a(4);
    y=@if(x#LE#500,10*x,@if(x#LE#1000,8*x+1000,-x+9000));
    max=y;
    endsubmodel

    submodel obj5:
    x>=a(5);
    y=@if(x#LE#500,10*x,@if(x#LE#1000,8*x+1000,-x+9000));
    max=y;
    endsubmodel

    submodel obj6:
    x>=a(6);
    y=@if(x#LE#500,10*x,@if(x#LE#1000,8*x+1000,-x+9000));
    max=y;
    endsubmodel

    calc:
    @write('a=300时的解',@newline(1));
    @solve(obj1);

    @write('a=800时的解',@newline(1));
    @solve(obj2);

    @write('a=1300时的解',@newline(1));
    @solve(obj3);

    @write('a=1400时的解',@newline(1));
    @solve(obj4);

    @write('a=600时的解',@newline(1));
    @solve(obj5);

    @write('a=900时的解',@newline(1));
    @solve(obj6);

    endcalc
    end
    已有 1 人评分体力 收起 理由
    wujianjack2 + 50 前辈!回答解答很给力!

    总评分: 体力 + 50   查看全部评分

    回复

    使用道具 举报

    sorjor        

    2

    主题

    9

    听众

    485

    积分

    升级  61.67%

  • TA的每日心情
    开心
    2015-10-29 00:36
  • 签到天数: 75 天

    [LV.6]常住居民II

    自我介绍
    智能优化,多目标优化

    邮箱绑定达人

    运行结果如下:
    a=300时的解
      Linearization components added:
          Constraints:          30
          Variables:            16
          Integers:             12

      Global optimal solution found.
      Objective value:                              9000.000
      Objective bound:                              9000.000
      Infeasibilities:                              0.000000
      Extended solver steps:                               3
      Total solver iterations:                            22


                           Variable           Value        Reduced Cost
                                  X        1000.000            0.000000
                                  Y        9000.000            0.000000
                              A( 1)        300.0000            0.000000
                              A( 2)        800.0000            0.000000
                              A( 3)        1300.000            0.000000
                              A( 4)        1400.000            0.000000
                              A( 5)        600.0000            0.000000
                              A( 6)        900.0000            0.000000

                                Row    Slack or Surplus      Dual Price
                                  1        700.0000            0.000000
                                  2        0.000000            1.000000
                                  3        9000.000            1.000000

    a=800时的解
      Linearization components added:
          Constraints:          30
          Variables:            16
          Integers:             12

      Global optimal solution found.
      Objective value:                              9000.000
      Objective bound:                              9000.000
      Infeasibilities:                              0.000000
      Extended solver steps:                               2
      Total solver iterations:                             8


                           Variable           Value        Reduced Cost
                                  X        1000.000            0.000000
                                  Y        9000.000            0.000000
                              A( 1)        300.0000            0.000000
                              A( 2)        800.0000            0.000000
                              A( 3)        1300.000            0.000000
                              A( 4)        1400.000            0.000000
                              A( 5)        600.0000            0.000000
                              A( 6)        900.0000            0.000000

                                Row    Slack or Surplus      Dual Price
                                  1        200.0000            0.000000
                                  2        0.000000            1.000000
                                  3        9000.000            1.000000

    a=1300时的解
      Linearization components added:
          Constraints:          30
          Variables:            16
          Integers:             12

      Global optimal solution found.
      Objective value:                              7700.000
      Objective bound:                              7700.000
      Infeasibilities:                              0.000000
      Extended solver steps:                               0
      Total solver iterations:                             0


                           Variable           Value        Reduced Cost
                                  X        1300.000            0.000000
                                  Y        7700.000            0.000000
                              A( 1)        300.0000            0.000000
                              A( 2)        800.0000            0.000000
                              A( 3)        1300.000            0.000000
                              A( 4)        1400.000            0.000000
                              A( 5)        600.0000            0.000000
                              A( 6)        900.0000            0.000000

                                Row    Slack or Surplus      Dual Price
                                  1        0.000000           -1.000000
                                  2        0.000000            1.000000
                                  3        7700.000            1.000000

    a=1400时的解
      Linearization components added:
          Constraints:          30
          Variables:            16
          Integers:             12

      Global optimal solution found.
      Objective value:                              7600.000
      Objective bound:                              7600.000
      Infeasibilities:                              0.000000
      Extended solver steps:                               0
      Total solver iterations:                             0


                           Variable           Value        Reduced Cost
                                  X        1400.000            0.000000
                                  Y        7600.000            0.000000
                              A( 1)        300.0000            0.000000
                              A( 2)        800.0000            0.000000
                              A( 3)        1300.000            0.000000
                              A( 4)        1400.000            0.000000
                              A( 5)        600.0000            0.000000
                              A( 6)        900.0000            0.000000

                                Row    Slack or Surplus      Dual Price
                                  1        0.000000           -1.000000
                                  2        0.000000            1.000000
                                  3        7600.000            1.000000

    a=600时的解
      Linearization components added:
          Constraints:          30
          Variables:            16
          Integers:             12

      Global optimal solution found.
      Objective value:                              9000.000
      Objective bound:                              9000.000
      Infeasibilities:                              0.000000
      Extended solver steps:                               2
      Total solver iterations:                             8


                           Variable           Value        Reduced Cost
                                  X        1000.000            0.000000
                                  Y        9000.000            0.000000
                              A( 1)        300.0000            0.000000
                              A( 2)        800.0000            0.000000
                              A( 3)        1300.000            0.000000
                              A( 4)        1400.000            0.000000
                              A( 5)        600.0000            0.000000
                              A( 6)        900.0000            0.000000

                                Row    Slack or Surplus      Dual Price
                                  1        400.0000            0.000000
                                  2        0.000000            1.000000
                                  3        9000.000            1.000000

    a=900时的解
      Linearization components added:
          Constraints:          30
          Variables:            16
          Integers:             12

      Global optimal solution found.
      Objective value:                              9000.000
      Objective bound:                              9000.000
      Infeasibilities:                              0.000000
      Extended solver steps:                               2
      Total solver iterations:                             8


                           Variable           Value        Reduced Cost
                                  X        1000.000            0.000000
                                  Y        9000.000            0.000000
                              A( 1)        300.0000            0.000000
                              A( 2)        800.0000            0.000000
                              A( 3)        1300.000            0.000000
                              A( 4)        1400.000            0.000000
                              A( 5)        600.0000            0.000000
                              A( 6)        900.0000            0.000000

                                Row    Slack or Surplus      Dual Price
                                  1        100.0000            0.000000
                                  2        0.000000            1.000000
                                  3        9000.000            1.000000

    已有 1 人评分体力 收起 理由
    wujianjack2 + 10 详细的结果说明,很贴心!

    总评分: 体力 + 10   查看全部评分

    回复

    使用道具 举报

    1

    主题

    4

    听众

    190

    积分

    升级  45%

  • TA的每日心情
    开心
    2017-8-31 10:52
  • 签到天数: 35 天

    [LV.5]常住居民I

    群组Matlab讨论组

    群组C 语言讨论组

    群组物联网工程师培训

    回复

    使用道具 举报

    0

    主题

    7

    听众

    96

    积分

    升级  95.79%

  • TA的每日心情
    开心
    2014-9-14 10:39
  • 签到天数: 33 天

    [LV.5]常住居民I

    自我介绍
    建模 学习

    群组2013年数学建模国赛备

    回复

    使用道具 举报

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

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

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

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

    蒙公网安备 15010502000194号

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

    GMT+8, 2025-8-17 06:08 , Processed in 0.685989 second(s), 88 queries .

    回顶部