解决复杂的最小成本问题 [英] Solving a complex minimal cost problem
问题描述
我是Solver的新手,但已经开发了很长时间。 可能是Solver不适合这个(虽然我怀疑它是),所以我想至少看看是否有人认为Solver是适合这项工作的工具。
场景: 客户提出1-x项目进行招标(我们称之为CustomerItems)。 这些商品的供应商会回来,并说明他们可以提供多少便宜的商品(我们称之为QuoteItems)。 供应商可以执行以下操作:
1。假设QuoteItem1履行CustomerItem1,总价格为$ x.xx
2.假设QuoteItem1通过CustomerItemX履行CustomerItem1,总价格为$ x.xx。
当客户回来时,我们希望向他们展示CustomerItems的QuoteItems的最佳(最低)价格组合。 所以我们需要遍历每个QuoteItem,并且对于它实现的每个CustomerItem,看看是否有更好(更便宜)的
组合的QuoteItems来实现那些/那些CustomerItems。
<摘要,我意识到。 这是一个简单的例子。
客户需要CustomerItem1,CustomerItem2和CustomerItem3
Supplier1创建:
QuoteItem1。 总费用为250美元。 CustomerItems涵盖:1和2
QuoteItem2 总费用为80美元。 它涵盖的CustomerItems:3
Supplier2创建:
QuoteItem3。 总费用为200美元。 它涵盖的CustomerItems:1
QuoteItem4 总费用为60美元。 它涵盖的CustomerItems:2
QuoteItem5 总费用为50美元。 它涵盖的CustomerItems:3
Supplier3创建:
QuoteItem6 总费用为315美元。 它包含的CustomerItems:1,2和3
程序需要获取每个QuoteItem,并且对于它涵盖的每个客户类型,看看是否有更便宜的QuoteItem组合满足客户的要求。 如果有更便宜的组合,这个QuoteItem不在运行,
缩小,直到只剩下那些覆盖CustomerItems的QuoteItems。
上面的答案,通过方式,是QuoteItem1和QuoteItem5。
任何帮助将不胜感激。
干杯
Chris Smith
Quirk Software Limited
我使用以下OML独立回应Quirk [只需将手放在
:) ]:
模型[
参数[套,Q, N],
参数[
Reals,Supply [Q,N],Req [N],费用[问]],
决定[
整数[0 ,1,X [Q]],
约束条件[
Foreach [{ i,N},Sum [{q,Q},Supply [q,i] * X [q]]> = Req [i]] ],
目标[ 最小化[TotalCost] - > Sum [{q,Q},Cost [q] * X [q]]] ]
]
这在包含数据的电子表格中运行:
  ;
Item1
Item2
< span style ="font-family:Calibri; font-size:small"> Item3
费用
Quote1
1
1
0
250
Quote2
0
0
1
80
Quote3
1
0
0
200
Quote4
0
1
0
60
Quote5
0
0
1
50
Quote6
1
1
1
315
Req
1
1
1
决策变量(X)决定哪个选择的引号和这个问题不需要是整数。但是,如果需要对问题进行任何扩展,保留它们的整数状态可能是明智的。
问候
迈克
I am new to Solver but have been developing for a long time. It could be that Solver isn't right for this (though I suspect it is), so I wanted to at least see if someone felt Solver was the right tool for the job.
The scenario: A customer puts out 1 - x items for tender (we'll call these CustomerItems). Suppliers of those items come back and can state how cheaply they can supply the items (we'll call these QuoteItems). The supplier can do the following:
1. Say that QuoteItem1 fulfills CustomerItem1 with a total price is $x.xx
2. Say that QuoteItem1 fulfills CustomerItem1 through CustomerItemX, with a total price of $x.xx.
When the customer comes back, we wish to show them the optimal (lowest) price combinations of QuoteItems for the CustomerItems. So we need to loop over each QuoteItem, and for each of the CustomerItems it fulfills, see if there is any better (cheaper) combination of QuoteItems that fulfill that / those CustomerItems.
Abstract, I realize. Thus a simple example.
Customer wants CustomerItem1, CustomerItem2 and CustomerItem3
Supplier1 creates:
QuoteItem1. Total cost is $250. CustomerItems it covers: 1 and 2
QuoteItem2 Total cost is $80. CustomerItems it covers: 3
Supplier2 creates:
QuoteItem3. Total cost is $200. CustomerItems it covers: 1
QuoteItem4 Total cost is $60. CustomerItems it covers: 2
QuoteItem5 Total cost is $50. CustomerItems it covers: 3
Supplier3 creates:
QuoteItem6 Total cost is $315. CustomerItems it covers: 1, 2 and 3
The program needs to take each QuoteItem, and for each of the customeritems it covers, see if there is a cheaper combination of QuoteItems that fulfill the customer's requirements. If there are cheaper combinations, this QuoteItem is out of the running, narrowing down until there are only those QuoteItems remaining which cover the CustomerItems in question.
The answer above, by the way, is QuoteItem1 and QuoteItem5.
Any help would be greatly appreciated.
Cheers
Chris Smith
Quirk Software Limited
I responded independently to Quirk with the following OML [ just keeping my hand in :) ] :
Model [
Parameters [ Sets, Q, N ] ,
Parameters[
Reals, Supply[Q,N] , Req[N] , Cost[Q] ],
Decisions[
Integers[0,1], X[Q] ],
Constraints [
Foreach [ {i,N} , Sum[ {q,Q}, Supply[q,i] * X[q] ] >= Req[i] ] ],
Goals [ Minimize[ "TotalCost" -> Sum[ {q,Q}, Cost[q] * X[q] ] ] ]
]
This runs in a spreadsheet with data:
Item1 Item2 Item3 Cost Quote1 1 1 0 250 Quote2 0 0 1 80 Quote3 1 0 0 200 Quote4 0 1 0 60 Quote5 0 0 1 50 Quote6 1 1 1 315 Req 1 1 1 Decision variables (X) decide which quotes to choose and for this problem do not need to be integers. However, if any extensions to the problem are required it's probably wise to retain their integer status.
Regards
Mike
这篇关于解决复杂的最小成本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!