I want to add a KPI to calculate the percentage of occupancy of vehicles: the total travel time of occupied arcs (where the capacity of a vehicle is non-zero) over the total travel time.

How can I represent that using three variables: the $x_{ij}$ variable equal to $1$ if there is an arc between $i$ and $j$, the $q_i$ the capacity of vehicle after serving vertex $i$ and the $b_i$ the starting time of service for vertex $i$?


kpi syntax example in docplex

from docplex.mp.model import Model

mdl = Model(name='buses')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')

mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids')
mdl.minimize(nbbus40*500 + nbbus30*400)



for v in mdl.iter_integer_vars():
    print(v," = ",v.solution_value)

for k in mdl.iter_kpis():
    print(k," = ",k.solution_value)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.