Hierarchical Multiobjective Pool Solution Runtime
OngoingHow can I retrieve the runtime for each solution found in a biobjective model and not just the time it takes to optimize each respective objective? Observe below for an example of retrieved times of objective optimization through a callback but no information on individual solution run times.
-
Hi Brandon,
I guess you are interested at knowing the time it takes to find every feasible solution. When solving a multi-objective optimization model, you still can call the MIP-related callbacks. You can use the MIPSOL callback which is invoked upon finding a new incumbent solution and save the current time as the time it takes to find the newly found incumbent solution.
Best regards,
Maliheh
0 -
Hi Maliheh,
I do not think the MIPSOL callback will solve this issue. I'm interested if there is anyway to do something along the lines of "model.params.SolutionNumber = s" for each solution s and retrieve model.Runtime from there at a where == GRB. Callback. MULTIOBJ during the multiobjective solution process. From my understanding model.params.SolutionNumber allows you to retrieve solution vector for the model but not the runtime associated to reach this solution vector.
0 -
Hi Brandon,
Please see the code snippet below for what I exactly meant. Maybe I am misunderstanding your question. Could you please clarify what else you would like to do which the code below does not help with?
def callback(model, where):
if where == GRB.Callback.MULTIOBJ:
model._obj_count = model.cbGet(GRB.Callback.MULTIOBJ_OBJCNT)
if where == GRB.Callback.MIPSOL:
new_solution = model.cbGetSolution(model._vars)
# Ensure that this is a new solution not a MIPStart for the next objective
if new_solution not in model._solutions:
time = model.cbGet(GRB.Callback.RUNTIME)
model._solutions.append(new_solution)
print(
f"Found a new solution at time {time} while optimizing objective #{model._obj_count + 1}"
)
# Initialize the current count of the objective started to be optimized
model._obj_count = 0
model._vars = model.getVars()
model._solutions = []
model.optimize(callback)Best regards,Maliheh0 -
Hi Maliheh,
When I implement your code using both the model._vars or model._specific_decision_variable I cannot retrieve any vectors to confirm the existence of a new solution at GRB.Callback.MIPSOL. I get the following output:
If I use the below pseudo code after the entire model has been optimized I can retrieve solutions and confirm that indeed the solution vector of "s" is different from "s+1." However model.Runtime is equivalent for each solution when you look at the file where metrics are stored. This is supported by the 'OBJ_1_Val, OBJ_2_Val' columns containing decreasing values but 'Sol-Time' staying constant in the second screenshot.
for s in range(model.SolCount):
# Set which solution we will query from now on
model.params.SolutionNumber = s
# generate object with solution vector of solution s
object_s = object_generator([model.getAttr('Xn',model._X).items() for X in set_of_spcific_variables])
with open(results_file, mode='a') as results:
[store object_s metrics to .csv file such as model.Runtime of solution s]
results.close()Looking at 'In-Acc, 'Out-Acc, Obj_2_Val' it is quite clear how the 10 solutions generated by the model are indeed unique in their solution vectors but I cannot store any runtime information w.r.t the specific solutions. This is supported by the following screenshot showing solution vectors.
0
Please sign in to leave a comment.
Comments
4 comments