# 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?

## Comments

David J(Report)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.

(https://github.com/dwave-examples/nurse-scheduling)

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.

SOMANKAR B(Report)Thanks. This helps.

SOMANKAR B(Report)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.

Regards,

David J(Report)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:

https://docs.dwavesys.com/docs/latest/c_gs_2.html

https://docs.dwavesys.com/docs/latest/c_gs_3.html

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:

https://docs.dwavesys.com/docs/latest/c_gs_4.html

https://docs.dwavesys.com/docs/latest/c_gs_7.html

I hope this helps answer your question.

Please let us know if you have any more questions!

Please sign in to leave a comment.