lab #3 worksheet ---------------- - make a new folder for week4 - files for this week: w4mRPS.m w4nm3.m w4game.p - start matlab & change to the week 4 folder warm-up ------- - you can rerun the modified RPS from class. "w4mRPS", this is mostly a plotting script, but it does set the game matrix "Pmatrix". - type "Pmatrix" to verify that it is modified RPS. - "w4nm3" is the nelder-mead minimization algorithm to the matrix game defined by "Pmatrix". - it should recover A's optimal system A = [3/12 5/12 4/12] expected winnings = 1/12 - redefine Pmatrix to be its negative transpose: Pmatrix = -transpose(Pmatrix) - rerun "w4nm3" for the new "Pmatrix", surprisingly it returns the optimal system for B! B = [4/12 5/12 3/12] expected winnings = -1/12 - choose with your partner a 7-digit phone number - this will be your common seed. (eg. 1234567) Pmatrix = w4game(3,1234567) will give you a random 3x3 matrix whose entries are integers between -50 and 50. it may make a lot of noise before it stops. also, this script is in pcode, which does not allow you to see what's inside (it actually checks that your matrix has a "good answer"). - use "w4nm3" to obtain the optimal systems & verify the minimax result. INSTRUCTIONS ------------ * this is officially a programming exercise. you will have to figure out what the variables & code sections in "w4nm3" are doing. - you will also have to debug your code modifications. - remember: by putting "return"s in your code, you can stop it before an error so that you can query your variable states. staring at your code will seldom fix your problem. - note: help min help max will tell you that min & max can return two results, the second being the index of the optimal vector element. STUDY #1 -------- - using the same phone number, generate a 4x4 matrix game: Pmatrix = w4game(4,1234567) - this study will require you to modify the nelder-mead implementation of "w4nm3" to a 4x4 case "w4nm4". - verify the minimax result. $ try to explain why your optimal systems might be consistent with your matrix's payoff scheme. STUDY #2 -------- - using the same phone number, generate a 5x5 matrix game: Pmatrix = w4game(5,1234567) - this study will require you to modify the nelder-mead implementation of "w4nm3" to a 5x5 case "w4nm5". - in this case, you are likely to find that your optimization code gets bogged down in "flat spots". you will have find some way of modifying your initial simplex so that the nelder-mead finds the true optima. - you will therefore have to "help" your code to find the optimum. but you should in short order be able to verify results consistent with the minimax theorem. $ try to explain why your optimal systems might be consistent with your matrix's payoff scheme. - one of the purposes of this study is to investigate one of the failure modes of the nelder-mead. so, there is no reward for a "lucky draw" -- if your phone number just happens to generate a nicer than average matrix. i've tested several dozen 5x5 matrices & they all fail. if you happen to get a lucky matrix, throw it back, choose a different phone number for this study & continue. (i still can't believe someone got 10 digits last week.)