reasoning with constraints from cspexamples import test_csp def sls_solver(csp,prob_best= )"""stochastic local searcher (prob_best= )""se slsearcher(cspse search( ,prob_bestreturn se current_assignment def any_conflict_solver(csp)"""stochastic local searcher (any-conflict)""return sls_solver(csp, if __name__ ="__main__"test_csp(sls_solvertest_csp(any_conflict_solver from cspexamples import csp csp crossword crossword #test solving csps with search#se slsearcher(csp )print(se search( )#se slsearcher(csp )print(se search( , )greedy #se slsearcher(csp )print(se search( , )any_conflict #se slsearcher(csp )print(se search( , ) greedy any_conflict #slsearcher max_display_level= #more detailed display #se slsearcher(crossword )print(se search( ), # runtime_distribution(csp # plot_runs( , , any_conflict # plot_runs( , , greedy # plot_runs( , , greedy any_conflict exercise modify this to plot the runtimeinstead of the number of steps to measure runtime use timeit (htmlsmall runtimes are inaccurateso timeit can run the same code multiple times stochastic local algorithms give different runtimes each time called to make the timing meaningfulyou need to make sure the random seed is the same for each repeated call (see random getstate and random setstate in https//docs python org/ /library/random htmlbecause the runtime for different seeds can vary great dealfor each seedyou should start with iteration and multiplying it bysay until the time is greater than seconds make sure you plot the average time for each run before you starttry to estimate the total runtimeso you will be able to tell if there is problem with the algorithm stopping discrete optimization softconstraint is constraintbut where the condition is real-valued function because we did not force the condition to be booleanwe can makejust reuse the constraint class cspsoft py -representations of soft constraints from cspproblem import variableconstraintcsp version june