Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  class docplex.mp.model.Model(name=None, checker = "on") what is checker

    Posted Tue October 20, 2020 06:07 AM
    http://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.model.html

    In above link it provides some information about how to define an optimization model using docplex.
    I have solved optimization model as follows.

    mymodel = Model("demo_model")

    I noted that a model can be defined as following method as well.

    mymodel = Model(name="demo_model",checker='on');

    I see in the link above it explains the usage checker,,Can someone explain with an example how we can use this feature in optimization models.How we can enhance modeling by using this 'checker' feature.

    Thanks.

    ------------------------------
    Suresh Abeyweera
    ------------------------------

    #DecisionOptimization


  • 2.  RE: class docplex.mp.model.Model(name=None, checker = "on") what is checker

    Posted Tue October 20, 2020 06:29 AM
    The `checker` argument lets you control the amount of type-checking that DOcplex performs on method arguments.
    By default(checker='on'), DOcplex checks the type of _all_ argument methods, issuing message that are relevant to modeling;
    of course this comes with a runtime cost, in the modeling phase (the solve time itself is unchanged)

    Setting checker='off' disables all type-checking. Use this option only when your model has been completely tuned and debugged.
    On one hand, this might speed up model build time, but unexpected arguments might well print hard-to-understand messages.
    At least this option let you switch type-checking on and off

    ------------------------------
    Philippe Couronne
    ------------------------------



  • 3.  RE: class docplex.mp.model.Model(name=None, checker = "on") what is checker

    Posted Tue October 20, 2020 06:52 AM
    Hi Philippe, Thanks for your prompt reply. By refereing your answer I understand that I am not well familiar with what is meant by 'all type-checking' in your reply .Is there anyplace that I can understand this concept.Thanks

    ------------------------------
    Suresh Abeyweera
    ------------------------------



  • 4.  RE: class docplex.mp.model.Model(name=None, checker = "on") what is checker

    Posted Tue October 20, 2020 08:50 AM
    Type checking means checking the _type_ of the arguments passed to DOcplex methods. Let's take an example with `Model.add_constraint`, 
    which expects a constraint. If I pass a string instead, with checker='on' , as below

    Model(checker='on').add_constraint("foo")

    I get this message:

    >>> docplex.mp.utils.DOcplexException: Expecting constraint, got: 'foo' with type: <class 'str'>

    With typechecking disabled, I get:


    Model(checker='off').add_constraint("foo")
    >>> AttributeError: 'str' object has no attribute '_index'


    Which is a lot more cryptic. The rule of thumb is: do not bother with `checker' until you have serious model building performance issues,
    for which you might look here for general ideas:

    https://github.com/IBMDecisionOptimization/docplex-examples/blob/master/examples/mp/jupyter/efficient.ipynb






    ------------------------------
    Philippe Couronne
    ------------------------------



  • 5.  RE: class docplex.mp.model.Model(name=None, checker = "on") what is checker

    Posted Wed October 21, 2020 01:49 AM
    This is super Philippe.I understood the concept clearly. Thanks for the update.

    ------------------------------
    Suresh Abeyweera
    ------------------------------