我是CPLEX的初学者,我正在努力在项目中添加更多约束。当我有多个始发地和目的地,并且只有一个产品时,该脚本运行良好。
我想满足每个目的地的更多产品需求,并且我不知道如何写约束。
`{string} Forest = {"A","B","C","D","E"};`
`{string} Destination = {"D1" , "D2"};`
`{string} Products = {"Pinus","Eucalyptus"};`
`float Demand [Destination][Products]= [[3,1],[4,5]];`
`float Distance [Forest][Destination]=[[21,52],[42,12],[25,15],[52,31],[9,42]]; `
`float Stock [Forest][Products]= [[0.94,0],[0,8.62],[0,1.21],[2.6,0],[8.77,0]];`
//Decision Variables
`dvar float+ Delivered [Forest][Destination];`
//Função Objetivo
`minimize`
`sum (u in Forest, c in Destination) Distance[u][c] * Delivered[u][c];`
//Constraints
`subject to {`
` forall (u in Forest)`
` sum (c in Destination)`
` Delivered[u][c] <= Stock [u];`
`forall (c in Destination)`
` sum (u in Forest) `
` Delivered[u][c] >= Demand[c];`
}
我是CPLEX的初学者,我正在努力在项目中添加更多约束。当我有多个始发地和目的地时,该脚本可以很好地工作,而我只想用...
要回答您的问题:您还应该按产品扩展您的决策变量(就像您对需求和库存所做的那样,以便您可以了解每种产品的交付量。
您可以尝试类似的东西