ipopt为什么不能正确优化-非线性站点分配?

时间:2019-11-21 06:02:48

标签: pyomo

我目前正在优化涉及2个起点和2个终点的路线分配。每条路线的运费为$ / t。但是,始发点有设定的落旗费,一旦分配了吨,便会激活该费。这给问题增加了一些非线性,促使我在pyomo中使用Ipopt求解器。我已经为下面的目标值设置了成本函数。

由于某些原因,尽管降旗成本对货运成本构成了阻碍,但它始终会同时打开两个原点。我不确定问题是否正确设置?或者,如果Ipopt适合此类问题。

sites = ['A','B']
phys = {'A':100,'B':100}
demand = {'F':50,'G':10}
dest = ['F','G']

routes = [(s,d) for s in sites for d in dest]
ops_costs = {'A':1000, 'B':1000}
freight_costs = {('A','F'): 9, ('B','F'): 8.6, ('A','G'):10, ('B','G'):12}

model = ConcreteModel()
model.x = Var(sites,dest,within=NonNegativeReals)

obj2={}
for s in sites:
    obj2[s] = sum(model.x[s,d] for d in dest)

model.freight = sum(freight_costs[s,d]*model.x[s,d] for (s,d) in routes)
model.flagfall = sum((ops_costs[s]*obj2[s])/(obj2[s]+0.0001) for s in sites)
value = Objective(expr=model.freight+model.flagfall,sense=minimize)

model.cons = ConstraintList()
for s in sites:
    site_alloc = 0
    for d in dest:
        site_alloc = site_alloc + model.x[s,d]
    model.cons.add(site_alloc<=phys[s])

for d in dest:
    demand_alloc = 0
    for s in sites:
        demand_alloc = demand_alloc + model.x[s,d]
    model.cons.add(demand_alloc==demand[d])

SolverFactory('ipopt').solve(model, tee=True)

1 个答案:

答案 0 :(得分:0)

看来您的问题最好由MINLP提出,在这种情况下,您将需要使用Bonmin,Couenne或其他合适的求解器。