The first thing that I feel I can say is that in my opinion try various algorithms to test the best one is a good practice in general but for this type of problem is not necessary because certainly a greedy approach does not lead to an optimal solution so I would have focused more on develop one solid algorithm that try to optimize the total numbers of elements Ls which is what the lab1 requires and reporting on the repo only the latter rather than all the others. According to what I said before I try to give you some feedback on the third of them, the A* algotithm, which is the one that seems to perform better.
First of all I think that, given the solutions that come up using seed = 42, you could assume that the elements within a list are all different and therefore your initial solution to transform the list of lists into a list of sets using a for loop it doesn't make much sense, what you could do instead is to have a single set in order to remove two different lists with the same elements inside so as improve the timing and the performances of your algorithm.
Futhermore, in my point of view there was no need to use the State class and add the modify_state function, since you work with a sets you could use the functions of those types to create the new state.
def modify_state(state: State, oldState, newSet): #to change the value of the state during the search
state.curr= oldState.curr.copy()
state.origin= newSet.copy()
state.curr.update(newSet.copy())
The final results look good in this case but maybe they aren't very optimal because I think there are better heuristics than the one you have used. Despite this, I think it is very valid as an algorithm and in general it is evident that you have worked a lot and that you like the subject, so good job!
Hi :sunglasses:
The first thing that I feel I can say is that in my opinion try various algorithms to test the best one is a good practice in general but for this type of problem is not necessary because certainly a greedy approach does not lead to an optimal solution so I would have focused more on develop one solid algorithm that try to optimize the total numbers of elements
Ls
which is what the lab1 requires and reporting on the repo only the latter rather than all the others. According to what I said before I try to give you some feedback on the third of them, theA* algotithm
, which is the one that seems to perform better.First of all I think that, given the solutions that come up using
seed = 42
, you could assume that the elements within a list are all different and therefore your initial solution to transform the list of lists into a list of sets using a for loop it doesn't make much sense, what you could do instead is to have a single set in order to remove two different lists with the same elements inside so as improve the timing and the performances of your algorithm.Futhermore, in my point of view there was no need to use the
State
class and add themodify_state
function, since you work with a sets you could use the functions of those types to create the new state.The final results look good in this case but maybe they aren't very optimal because I think there are better heuristics than the one you have used. Despite this, I think it is very valid as an algorithm and in general it is evident that you have worked a lot and that you like the subject, so good job!