user12484944
user12484944

Reputation: 3

The sub-optimal with docplex (cplex) when time limit is reached?

I am using Docplex (Cplex python version) with a maximization objective. I set the time limit, using

mdl.solve(TimeLimit=600).

It is possible that the model doesn't reach the optimal during this time, so i want to get the objective value (sub-optimal) when the timeLimit is reached. How can i do it? For the optimal, i use :

mdl.get_objective_values()

It gives me None when the time limit is reached!

Thanks,

Upvotes: 0

Views: 827

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10059

your model could be either infeasible or not provide a solution in the given time limit. You should test the status after solve:

    sol = mdl.solve(TimeLimit=600)
    if sol is not None:

        print_information("Ok")

    else:
        print("* model is infeasible")

Upvotes: 0

Related Questions