我正试图将一些数据转化为优化问题的PYOMO模型
materials = ['steel', 'alum', 'carbon', 'cheese']
每种材料都有两个特性-密度和导电性,其值定义如下
density = { 'steel' : 1.2,
'alum' : 0.8,
'carbon': 1.8,
'cheese': 0.7}
conductivity = {'steel' : 6.4,
'alum' : 3.1,
'carbon': 4.4,
'cheese': 0.3}
目标函数计算2块矩形板的重量,如下所示:
Objective function = Area_1 * thickness_1 * density_1 + Area_2 * thickness_2 * density_2
其中,面积_1、厚度_1和密度_1是板1的面积、厚度和密度
每个板的面积和厚度都是固定的。但是密度值取决于解算器为获得最佳结果而选择的材质。该模型还有一个定义如下的约束:
(conductivity_1/thickness_1) + (conductivity_2/thickness_2) => 22
因此,当解算器为板选择密度值时,它还必须选择相同材料的电导率值
如果有人能帮我解决这个问题,我将不胜感激。我也欢迎你有不同的想法来解决这个问题。多谢各位
下面是一个我认为符合您所有问题的示例模型
一旦您将第二个索引设置为板材
P = {1, 2, 3}
,在这种情况下,对于3个板材,我们需要对决策变量进行双重索引,以表示将材料m
分配给板材p
。在本例中,4种材料,3种板材这里还有许多其他的约束条件,但我添加的这些约束条件回答了您关于骨料导电性的问题。请注意,我还添加了一个约束,以确保为每个板指定1种且仅指定1种材质。根据模型中的其他约束条件,您可能需要/可能不需要此选项,但它可以很好地防止虚假答案。这也是使用
pyomo
中的函数-规则组合的“for-every”约束样式的一个示例结果。。。铝和奶酪三明治…:)
产量:
相关问题 更多 >
编程相关推荐