Alright msol.get_solver_log() this did the trick.
Thanks a lot for helping.
Original Message:
Sent: Thu June 17, 2021 12:10 PM
From: ALEX FLEISCHER
Subject: Using set set_starting_point with integer_var_dict in docplex.cp
Hi,
I used Idle and saw
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
Original Message:
Sent: Wed June 16, 2021 04:05 AM
From: SHanaka Perera
Subject: Using set set_starting_point with integer_var_dict in docplex.cp
Hi @ALEX FLEISCHER Can you please tell me how did you get that log printed? when I rant your code I just got the answer but not the log which you have put in your answer. Thanks
------------------------------
SHanaka Perera
Original Message:
Sent: Wed June 17, 2020 09:30 AM
From: ALEX FLEISCHER
Subject: Using set set_starting_point with integer_var_dict in docplex.cp
In https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer/
you have many examples but not yet that one.
from docplex.cp.model import CpoModelmdl = CpoModel(name='buses')nbbus40 = mdl.integer_var(0,1000,name='nbBus40')nbbus30 = mdl.integer_var(0,1000,name='nbBus30')mdl.add(nbbus40*40 + nbbus30*30 >= 300)mdl.minimize(nbbus40*500 + nbbus30*400)sol=mdl.create_empty_solution()sol[nbbus40]=8sol[nbbus30]=0mdl.set_starting_point(sol)msol=mdl.solve()print(msol[nbbus40]," buses 40 seats")print(msol[nbbus30]," buses 30 seats")
works fine
and gives
! -------------------------------------------------- CP Optimizer 12.10.0.0 -- ! Minimization problem - 2 variables, 1 constraint ! Using starting point solution ! Initial process time : 0.00s (0.00s extraction + 0.00s propagation) ! . Log search space : 19.9 (before), 19.9 (after) ! . Memory usage : 267.0 kB (before), 267.0 kB (after) ! Using parallel search with 12 workers. ! ---------------------------------------------------------------------------- ! Best Branches Non-fixed W Branch decision 0 2 - + New bound is 0 ! Starting point is complete and consistent with constraints. * 4000 0 0.01s 1 (gap is 100.0%) 4000 0 2 1 - + New bound is 3800 (gap is 5.00%) * 3800 0 0.01s 1 (gap is 0.00%) ! ---------------------------------------------------------------------------- ! Search completed, 2 solutions found. ! Best objective : 3800 (optimal - effective tol. is 0) ! Best bound : 3800 ! ---------------------------------------------------------------------------- ! Number of branches : 232 ! Number of fails : 188 ! Total memory usage : 5.3 MB (5.3 MB CP Optimizer + 0.0 MB Concert) ! Time spent in solve : 0.01s (0.01s engine + 0.00s extraction) ! Search speed (br. / s) : 21090.9 ! ----------------------------------------------------------------------------6 buses 40 seats2 buses 30 seats
regards
------------------------------
ALEX FLEISCHER
Original Message:
Sent: Wed June 17, 2020 05:49 AM
From: Johan Eriksson
Subject: Using set set_starting_point with integer_var_dict in docplex.cp
Hello,
I have a cp problem where i use a integer_var_dict. I would like to set a starting point of that variable. I'm new to this and don't know if this is a lack of python or cplex knowledge.
Basicly:
import docplex.cp.model as cp
take = m.integer_var_dict(((b, r) for b in BatcheRange for r in Range), 0 , 3 , "take")
sol = m.create_empty_solution()
sol[take] = ???
m.set_starting_point(sol)
------------------------------
Johan Eriksson
------------------------------
#DecisionOptimization