Hello,
I am programming a little sudoku solver&generator.
There are two situations when it can occur that I have an infeasible problem:
1. the user enters a wrong/unsolvable sudoku
2. during the generation process, when the field is filled with some random numbers at the beginning, it might cause an infeasibility, so that a correction is needed
I want to achieve, that AIMMS does not terminate the program, but in the 1. case gives a message to the user, and in the 2. case goes back/starts again with generating a new field.
I tried to work with a code like this for the generation. It shall check whether given random numbers can be filled to a sudoku, if not then it shall start again with some random numbers/alternatively go back and delete some numbers in the field
Valid_Solution_Found := 0;
while(not Valid_Solution_Found) do
! process a new selection of random numbers here, or a correction !
Solve My_Sudoku_Program;
if (My_Sudoku_Program.ProgramStatus = 'Optimal') then
Valid_Solution_Found := 1;
! go on with the code here !
else
empty My_Solution(r,c,k);
empty Some_Random_Numbers_On_A_Sudoku_Field(r,c);
endif;
endwhile;
But this dos not work at all, I only get a message which constraints could not be satisfied and the execution of the program is terminated.
I am just a beginner with AIMMS, so I am not sure whether there is an easy way to do what I want. But I did not find a proper way how to easily check the feasibility of a given problem.
I hope someone can help me with that.