This regards problem 4 of problem set 8. I'm trying to build the initial brute force subject finder to which I will later apply DP. What I have is essentially a modified version of maxVal, but the idea is that along the way to the highest value possible, as I consider to take or not take each class, I make a note of the result in a dictionary. It gives me the right maximum value at the end, but the dictionary that it keeps is wrong. Here's the code thus far: http://pastebin.com/fCUQLKJd
don't worry too much about the helper functions makeTheVectors and maximumList1 , all they're doing is making lists of subjects, _value_ and work values and putting them in the function respectively. The real workhorse is maximumList0. Putting in some print statements (since removed for clarity), I can see that the reason it gives me the wrong list of subjects (variable x) seems to be that it changes values back and forth, which is fine but it's in a way that doesn't match up with how it's keeping track of the highest value. I think the issue might be on how I'm implementing the recursion steps - perhaps I should be changing x in some way in the variables I'm calling? Or something. Appreciate your thoughts.
x is supposed to represent items that have been taken (?) it looks like you are using the same x object for the with and without branches - i don't think that will work - you might need to keep them separate
X is meant to be a vector of 1s and 0s as in class; the value of x[i] will be one if we're taking that subject, and 0 if we're not. The intention at the end is to have a vector with 1 where the classes we want to take are, and 0 everywhere else.
you are using different variables to accumulate value (without_i, with_i) - it seems like you should use separate variables to keep track of the indices. it looks like your with and without 'paths' will be overwriting each other so that you don't really know which subjects are associated with the with_I and without_i values
Join our real-time social learning platform and learn together with your friends!