Skip to content

Model Non Linear Objective function #663

@andreafresa

Description

@andreafresa

Hi, I have the following objective function

$$ \max_{n_{ij}(t)} &&\sum_{i \in I} \sum_{j \in J_i}Q_ib({n_{ij}(t)}) + \sum_{i \in I}V_iw_{ij}\sum_{j\in J_i}\min({b(n_{ij}(t)) , Q_i- \sum_{k <j}b(n_{ik}(t))})a_{ij} $$

Where n_ij is a matrix of the decision variables. My function is not linear, because of min, thus it is a Non-Linear Integer Programming problem (NILP).
I converted min(a,b) = (a + b)/2 + abs(a-b)/2

I implemented my function in the following way:

def new_npilp(queue , service_rate , accuracy , V, numcores):
    model = scipop.Model("npilp")
    x = {}
    for i in range(len(service_rate)):
            x[i]=model.addVar("x"+str(i), vtype="I", lb=0, ub=numcores)    
    nonlinexp = {}
    term1 = {}
    term2 = {}
    model = scipop.Model("npilp")
    model.addCons(scipop.quicksum(x[i] for i in range(len(service_rate))) <= numcores)
    for i in range(len(service_rate)):
        term1[i] = accuracy[i]*service_rate[i][1]*x[i]
        term2[i] = accuracy[i]*queue-scipop.quicksum(service_rate[k][1]*x[k] for k in range(len(service_rate)))
        nonlinexp[i] = (term1[i]+term2[i]/2) + abs(term1[i]-term2[i])/2
        print(type(nonlinexp[i]))
    fun = scipop.quicksum(queue*service_rate[i][1]*x[i] + nonlinexp[i] for i in range(len(service_rate)))
    model.setObjective(fun, "maximize")
    model.optimize()
    

However I get the following error:

AssertionError: given coefficients are neither Expr or number but SumExpr

Could someone help me here? How can I solve this using PySCIPOpt? If not, why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions