Quantcast
Viewing all articles
Browse latest Browse all 14011

Unable to resolve KeyError: "Index 'slice(None, None, None)' is not valid for indexed component 'MindtPy_utils.objective_value'"

import pandas as pdimport random as rimport numpy as npimport glpkfrom pyomo.environ import *from amplpy import AMPLdef pyblock(pyp, pytau, pyr, pys):  M = ConcreteModel()  M.m = Set(initialize = list(range(int(len(pyp)))))  M.e = Set(initialize = list(range(int(len(pyr)))))  M.s = Set(initialize = list(range(int(pys))))  M.r = Param(M.e, initialize = pyr)  M.tau = Param(M.m, initialize = pytau)  M.p = Param(M.m, M.e, M.s, initialize = 0)  M.n = Var(M.m, M.e, M.s, domain=NonNegativeIntegers, initialize=0)  def obj(M):    return sum(-log(1-prod((1-pyp[i,j,k])**(M.n[i,j,k]) for j in M.e for k in M.s)) for i in M.m)  M.obj=Objective(rule=obj, sense=minimize)  def fire_rate(M, j, k):    return sum(M.n[i,j,k] for i in M.m) <= M.r[j]  M.fire_rate=Constraint(M.e, M.s, rule = fire_rate)  opt = SolverFactory('mindtpy')  results = opt.solve(    M,    mip_solver = 'cplex',    nlp_solver = 'ipopt',    tee=True  )  # results.write()  return M.n.extract_values()

Currently trying to solve this MINLP with pyomo and mindtpy. Parameters are called from R with reticulate. Ipopt solves this with non-integer solutions however I am looking to use mindtpy to provide integer solutions. When I run it, I get the following error:

Error in py_call_impl(callable, call_args$unnamed, call_args$named) :KeyError: "Index 'slice(None, None, None)' is not valid for indexed component 'MindtPy_utils.objective_value'"

Any help is greatly appreciated.


Viewing all articles
Browse latest Browse all 14011

Trending Articles