NSP - new constraint

I would like to change first constraint in the NSP from no consecutive day working to, no nurse should work more than 3 days in a 5 day week. I.e in the current 11 day problem, any nurse should be scheduled for maximum 6 days. Any suggestion how this will be defined in the algorithm? 



  • Hello,

    I spoke with one of my colleagues about your question, and it seems like this can be solved by reading through the README.rst file and the nurse_scheduling.py file and making some modifications to the code.

    A good approach to understanding these constraints is to remove each constraint one by one and see how the results change and whether they make sense.

    One approach it to remove the "no nurse works two consecutive days" constraint and replace it by another constraint.

    The code for "all nurses should have approximately even work schedule" can be duplicated to modified to make this new constraint. 

    The values in this new constraint can be modified to try to obtain the desired behaviour of 3 days in a 5 day week.

    Hopefully this was helpful.

    Please let us know if you have any follow-up questions.


    Comment actions Permalink
  • Thanks David.

    Yes, I was able to achieve a version of what I was intending to, by doing some tweaks in the "Hard Nurse" function i.e. J. 

    But, I am still unclear how did this work and why? :)  

    Therefore I am now trying to understand how the matrix Q is used by the solver. Can you direct me to any book or online material through which I can understand how we work with upper diagonal matrix? In all the D-wave documents it is mentioned that, liner coefficients are on the diagonal and quadratic are off-diagonal, but how exactly the solver handle this?

    Any guidance will be much appreciated.


    Comment actions Permalink
  • Hello,

    The getting started guide has lots of great information in it.

    As far as how the QPU (solver) uses the linear and quadratic terms, these pages describes how qubit and coupler biases are used to represent the problem:



    The QPU is a specific architecture, so there are also ways to represent all columns in the Q matrix by embedding your problem onto the QPU:




    I hope this helps answer your question.

    Please let us know if you have any more questions!

    Comment actions Permalink
  • Thanks. This helps.

    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post