0

Using from docplex.cp.model import CpoModel I have written a docplex code. Model defenition is as follows.

mdl = CpoModel(name="HouseBuilding")

But by the solve() function it is printing unnecessary output with the solution at last.

msol = mdl.solve(TimeLimit=10)

I believe it is printing below things .

solve status,
solver parameters,
solver information
output log

Sample output as follows.How should I avoid print these information but only the solution.

! -------------------------------------------------- CP Optimizer 12.10.0.0 --
 ! Maximization problem - 153 variables, 123 constraints
 ! TimeLimit            = 10
 ! Initial process time : 0.00s (0.00s extraction + 0.00s propagation)
 !  . Log search space  : 330.1 (before), 330.1 (after)
 !  . Memory usage      : 926.0 kB (before), 926.0 kB (after)
 ! Using parallel search with 4 workers.
 ! ----------------------------------------------------------------------------
 !          Best Branches  Non-fixed    W       Branch decision
                        0        153                 -
 + New bound is 385
 ! Using iterative diving.
 ! Using temporal relaxation.
                        0        153    1            -
 + New bound is 372
 *           309      155  0.12s        1      (gap is 20.39%)
 *           313      387  0.12s        1      (gap is 18.85%)
 *           315      552  0.12s        1      (gap is 18.10%)
             315     1000          2    1   F         !presenceOf(H4-facade(Jack))
 *           340     1480  0.12s        1      (gap is 9.41%)
             340     2000          2    1       230  = startOf(H3-garden(Jim))
 *           346     2343  0.12s        1      (gap is 7.51%)
suresh_chinthy
  • 377
  • 2
  • 12

1 Answers1

1

You only need set the log_output parameter to delete this unnecessary output

msol = mdl.solve(TimeLimit=10, log_output=False)

To print objetive value (aka solution):

print(msol.objective_value)

Finally, if you need to access the solution of your variables, you must iterare your Narray variable and use:

msol[var_name[(i, j, ... , etc. )]]))

I hope this answer will be helpful to you and sorry for my English.