manbet体育手机客户端


facility_vb.vb


“Copyright 2019, G狗万app足彩urobi Optimization, LLC”“设施位置:一家公司目前将其产品从5个狗万滚球球工厂运到4个仓库。该公司正在考虑关闭一些工厂以降低成本。为了减少运输和固定成本,公司应该关闭哪些工厂?狗万滚球球“基于Frontline Systems的一个例子:‘http://www.solver.com/disfacility.手机万博登录htm’经许可使用。”进口系统进口Gurobi类facility_vb共享子Main()尝试在成千上万的仓库需求单位的需求双()= New双(){14日,15日,18日20}的工厂生产能力在昏暗的身份双()= New双(){20日,22日,17日,19日,18日}的固定成本为每个工厂昏暗FixedCosts双()= New双(){12000,15000, 17000, 13000, 16000 _}的单位运输成本每千暗TransCosts双新双(,)(,)={{4000、2000、3000、2500、4500},_{2500、2600、3400、3000、4000},_{1200、1800、2600、4100、3000},_{2200、2600、3100、3700、3200}}的工厂和仓库昏暗nPlants整数的数量=能力。长度昏暗的nwarehouse作为整数=需求。Length ' Model Dim env As New GRBEnv() Dim Model As New GRBModel(env) Model。ModelName = "facility" '工厂开放决策变量:如果工厂p是开放的,则open(p) == 1。if (p = 0 To nPlants - 1 open(p) = 1){} / /设置参数AddVar(0,1,固定成本(p), GRB。二进制,“开放”& p)下的运输运输决策变量:从“植物p w昏暗的仓库运输作为GRBVar (,) = New GRBVar (nPlants nWarehouses - 1——1){}为整数= 0 w nWarehouses - 1为整数p = 0 nPlants运输(w、p) = - 1模型。AddVar(0,伽马射线爆发。INFINITY, _ TransCosts(w, p), GRB.CONTINUOUS, _ "Trans" & p & "." & w) Next Next ' The objective is to minimize the total fixed and variable costs model.ModelSense = GRB.MINIMIZE ' Production constraints ' Note that the right-hand limit sets the production to zero if ' the plant is closed For p As Integer = 0 To nPlants - 1 Dim ptot As GRBLinExpr = 0 For w As Integer = 0 To nWarehouses - 1 ptot.AddTerm(1.0, transport(w, p)) Next model.AddConstr(ptot <= Capacity(p) * open(p), "Capacity" & p) Next ' Demand constraints For w As Integer = 0 To nWarehouses - 1 Dim dtot As GRBLinExpr = 0 For p As Integer = 0 To nPlants - 1 dtot.AddTerm(1.0, transport(w, p)) Next model.AddConstr(dtot = Demand(w), "Demand" & w) Next ' Guess at the starting point: close the plant with the highest ' fixed costs; open all others ' First, open all plants For p As Integer = 0 To nPlants - 1 open(p).Start = 1.0 Next ' Now close the plant with the highest fixed cost Console.WriteLine("Initial guess:") Dim maxFixed As Double = -GRB.INFINITY For p As Integer = 0 To nPlants - 1 If FixedCosts(p) > maxFixed Then maxFixed = FixedCosts(p) End If Next For p As Integer = 0 To nPlants - 1 If FixedCosts(p) = maxFixed Then open(p).Start = 0.0 Console.WriteLine("Closing plant " & p & vbLf) Exit For End If Next ' Use barrier to solve root relaxation model.Parameters.Method = GRB.METHOD_BARRIER ' Solve model.Optimize() ' Print solution Console.WriteLine(vbLf & "TOTAL COSTS: " & model.ObjVal) Console.WriteLine("SOLUTION:") For p As Integer = 0 To nPlants - 1 If open(p).X > 0.99 Then Console.WriteLine("Plant " & p & " open:") For w As Integer = 0 To nWarehouses - 1 If transport(w, p).X > 0.0001 Then Console.WriteLine(" Transport " & _ transport(w, p).X & _ " units to warehouse " & w) End If Next Else Console.WriteLine("Plant " & p & " closed!") End If Next ' Dispose of model and env model.Dispose() env.Dispose() Catch e As GRBException Console.WriteLine("Error code: " & e.ErrorCode & ". " & e.Message) End Try End Sub End Class