公告:1)网站程序升级:Q2A升级到1.8.6,Wordpress升级到5.7.2
2)修复了头像加载慢与提交问题反应慢等问题
2021-06-16

欢迎来到 Mathematica 问答社区

提问时请贴上文本代码

语法高亮:在编辑器中点击

被禁止的话题:广告破解

请阅读:《提问的智慧》

备用域名:mma.ooo

支持LaTex数学公式
行内公式标识符:\$ 或“$\backslash ($”+“$\backslash )$”,
行间公式标识符:\$\$ 或 “$\backslash [$”+“$\backslash ]$”

社区建议QQ群:365716997

分类

+1 投票
905 浏览
Maximize[{700*y1 + 600*y2 + 400*y3 + 350*y4 + 150*y5,
  x1 - x11 - x12 - x13 == 0,
  x1 - 0.1*z1 - 0.15*z2 == 0,
  x2 - x21 - x22 - x23 == 0,
  x2 - 0.2*z1 - 0.18*z2 == 0,
  x3 - x31 - x32 - x33 == 0,
  x3 - 0.2*z1 - 0.18*z2 == 0,
  x7 - x71 - x72 - x73 == 0,
  x7 - 0.12*z1 - 0.08*z2 == 0,
  x8 - x81 - x82 - x83 == 0,
  x8 - 0.2*z1 - 0.19*z2 == 0,
  x9 - x91 - x92 - x93 == 0,
  x9 - 0.13*z1 - 0.12*z2 == 0,
  x4 - x41 - x42 == 0,
  x4 - 0.6*x13 - 0.52*x23 - 0.45*x33 == 0,
  x5 - x51 - x52 == 0,
  x5 - 0.28*x73 - 0.2*x83 == 0,
  x6 - x61 - x62 == 0,
  x6 - 0.68*x73 - 0.75*x83 == 0,
  y1 - x11 - x21 - x31 - x41 - x51 == 0,
  y2 - x12 - x22 - x32 - x42 - x52 == 0,
  y3 - x61 - x71 - x81 - x91 == 0,
  y4 - x62 - x72 - x82 - x92 == 0,
  y5 - 0.5*x93 == 0,
  z1 + z2 <= 45000,
  x13 + x23 + x33 <= 10000,
  x73 + x83 <= 8000,
  4*x11 + 14*x21 + 24*x31 - 21*x41 - 11*x51 <= 0,
  -6*x12 + 4*x22 + 14*x32 - 31*x42 - 21*x52 <= 0,
  -0.4*x81 + 0.5*x61 - 0.95*x91 <= 0,
  x62 - 4*x92 == 0,
  3*x72 - 10*x82 == 0,
  4*x82 - 3*x62 == 0,
  z1 <= 20000,
  z2 <= 30000,
  y5 >= 500,
  y5 <= 1000,
  y1 - 0.4*y2 >= 0},
 {y1, y2, y3, y4, y5, x1, x11, x12, x13, z1, z2, x2, x21, x22, x23,
  x3, x31, x32, x33, x7, x71, x72, x73, x8, x81, x82, x83, x9, x91,
  x92, x93, x4, x41, x42, x5, x51, x52, x6, x61, x62}
 ]



lingo上可以算出来,mathematica却不行,请问是什么问题?

用户: 1386cc (16 分)
修改于 用户:xzczd

1个回答

+4 投票

这问题好久没见人问过了呢。Lingo默认全体变量大于等于0,而Mathematica不是这样。

 

    var = {y1, y2, y3, y4, y5, x1, x11, x12, x13, z1, z2, x2, x21, x22, x23, x3, 
       x31, x32, x33, x7, x71, x72, x73, x8, x81, x82, x83, x9, x91, x92, x93, x4, x41, x42, 
       x5, x51, x52, x6, x61, x62};
    Maximize[Rationalize[{700*y1 + 600*y2 + 400*y3 + 350*y4 + 150*y5, 
        x1 - x11 - x12 - x13 == 0, x1 - 0.1*z1 - 0.15*z2 == 0, x2 - x21 - x22 - x23 == 0, 
        x2 - 0.2*z1 - 0.18*z2 == 0, x3 - x31 - x32 - x33 == 0, x3 - 0.2*z1 - 0.18*z2 == 0, 
        x7 - x71 - x72 - x73 == 0, x7 - 0.12*z1 - 0.08*z2 == 0, x8 - x81 - x82 - x83 == 0, 
        x8 - 0.2*z1 - 0.19*z2 == 0, x9 - x91 - x92 - x93 == 0, x9 - 0.13*z1 - 0.12*z2 == 0, 
        x4 - x41 - x42 == 0, x4 - 0.6*x13 - 0.52*x23 - 0.45*x33 == 0, x5 - x51 - x52 == 0, 
        x5 - 0.28*x73 - 0.2*x83 == 0, x6 - x61 - x62 == 0, x6 - 0.68*x73 - 0.75*x83 == 0, 
        y1 - x11 - x21 - x31 - x41 - x51 == 0, y2 - x12 - x22 - x32 - x42 - x52 == 0, 
        y3 - x61 - x71 - x81 - x91 == 0, y4 - x62 - x72 - x82 - x92 == 0, y5 - 0.5*x93 == 0, 
        z1 + z2 <= 45000, x13 + x23 + x33 <= 10000, x73 + x83 <= 8000, 
        4*x11 + 14*x21 + 24*x31 - 21*x41 - 11*x51 <= 
         0, -6*x12 + 4*x22 + 14*x32 - 31*x42 - 21*x52 <= 0, -0.4*x81 + 0.5*x61 - 0.95*x91 <= 
         0, x62 - 4*x92 == 0, 3*x72 - 10*x82 == 0, 4*x82 - 3*x62 == 0, z1 <= 20000, 
        z2 <= 30000, y5 >= 500, y5 <= 1000, y1 - 0.4*y2 >= 0, var >= 0 // Thread} // Flatten,
       0], var, WorkingPrecision -> 16]
    (* {2.004460*10^7, {y1 -> 6269.456, y2 -> 15673.639, y3 -> 15442.00000, y4 -> 0, 
      y5 -> 500.0000000000000, x1 -> 5750.00000, x11 -> 4107.347, x12 -> 1642.653, x13 -> 0, 
      z1 -> 20000.0000000000, z2 -> 25000.0000, x2 -> 8500.00000, x21 -> 0, x22 -> 8500.0000,
       x23 -> 0, x3 -> 8500.00000, x31 -> 210.1089, x32 -> 3273.699, x33 -> 5016.192, 
      x7 -> 4400.00000, x71 -> 0, x72 -> 0.*10^-6, x73 -> 4400.00000, x8 -> 8750.00000, 
      x81 -> 5150.00000, x82 -> 0.*10^-6, x83 -> 3600.00000, x9 -> 5600.00000, 
      x91 -> 4600.00000, x92 -> 0.*10^-7, x93 -> 1000.000000, x4 -> 2257.286, x41 -> 0, 
      x42 -> 2257.2862, x5 -> 1952.000000, x51 -> 1952.000000, x52 -> 0, x6 -> 5692.00000, 
      x61 -> 5692.00000, x62 -> 0.*10^-6}} *)

 

用户: xzczd (2.1k 分)
修改于 用户:xzczd
但是进行了让变量进行了非负的操作后,里面的解还是有负数的啊,例如x92 -> -6.55113*10^-14,这就是个负数啊,虽然它趋于0了
只是数值误差而已,升精度就行了,具体看编辑。
谢谢!!!目前完美解决了,好人一生平安~
...