Initialization: generate an initial solution 𝑠 , set 𝑠 = 𝑠 and 𝑓 = 𝑓 ( 𝑠 ) ;
While a stopping time condition is not met and 𝑓 > 0 , do
 1. initialize the value of the best move: set 𝑔 = + ;
 2. generate the best move: for each non assigned variable 𝑠 𝑖 and each value 𝑑 𝑗 𝐷 𝑖 , test move 𝑚 = ( 𝑠 𝑖 , 𝑑 𝑗 ) on 𝑠 as follows:
   (a) assignment phase: give value 𝑑 𝑗 to variable 𝑠 𝑖 and compute the associated set 𝐶 ( 𝑚 ) of conflicting variables;
   (b) reassignment phase (optional): for each variable 𝑠 𝑟 of 𝐶 ( 𝑚 ) , if it is possible to assign another admissible value to 𝑠 𝑟
   without augmenting the number of violations, do it and remove 𝑠 𝑟 from 𝐶 ( 𝑚 ) ;
   (c) let 𝑠 c a n d be the so obtained candidate neighbor solution (which might be non feasible at this stage);
   (d) update the best candidate move: if | 𝐶 ( 𝑚 ) | < 𝑔 , set 𝑠 = 𝑠 c a n d and 𝑔 = | 𝐶 ( 𝑚 ) | ;
 3. repairing phase on the best move: remove the value of the 𝑔 conflicting variables of 𝑠 and let 𝑠 be the
  resulting new current solution;
 4. update the record: if 𝑓 𝑓 ( 𝑠 ) < , set 𝑠 = 𝑠 and 𝑓 = 𝑓 ( 𝑠 )
Output: solution 𝑠 (which is a complete feasible solution if 𝑓 = 0 );
Algorithm 1: CNS.