File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
class01/background_materials Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -438,14 +438,9 @@ begin
438438 [2 8 7 4 1 9 6 3 5 ];
439439 [3 4 5 2 8 6 1 7 9 ]],)
440440
441- anss = missing
442- try
443- anss = (
444- x_ss = haskey (sudoku, :x_s ) ? JuMP. value .(sudoku[:x_s ]) : missing ,
445- )
446- catch
447- anss = missing
448- end
441+ anss = (;
442+ x_ss = haskey (sudoku, :x_s ) && JuMP. is_solved_and_feasible (sudoku) ? JuMP. value .(sudoku[:x_s ]) : missing
443+ )
449444
450445 # Convert 3D binary matrix to 2D solution matrix
451446 function convert_3d_to_solution (x_3d)
@@ -594,8 +589,8 @@ begin
594589model_nlp = Model (Ipopt. Optimizer)
595590
596591# Required named variables
597- @variable (model_nlp, x )
598- @variable (model_nlp, y )
592+ @variable (model_nlp, x_nlp )
593+ @variable (model_nlp, y_nlp )
599594
600595# --- YOUR CODE HERE ---
601596
@@ -737,8 +732,8 @@ begin
737732 ans3= missing
738733 try
739734 ans3 = (
740- x = safeval (model_nlp, :x ),
741- y = safeval (model_nlp, :y ),
735+ x = safeval (model_nlp, :x_nlp ),
736+ y = safeval (model_nlp, :y_nlp ),
742737 obj = objective_value (model_nlp),
743738 )
744739 catch
You can’t perform that action at this time.
0 commit comments