Is it possible to get an existing variable by its name? Something like:
model = CpModel()
model.new_bool_var("mySuperBoolVar")
# ...many lines later...
bv = model.get_bool_var_by_name("mySuperBoolVar")
Obviously, get_bool_var_by_name()
doesn't exist. There's only model.get_bool_var_from_proto_index()
, but I have no idea what does it do...
No, you will need to do the bookkeeping yourself.
Each variable has an index. Look at the clone model sample where it is used.