1
$\begingroup$

I have some formulas from a paper (Provably Manipulation-Resistant Reputation Systems) that I would like to run 3 times (with different nummbers).

Therefore, I wrote a small programm that now finally works ... and bam:

This computation has exceeded the memory limit for your plan

I didn't know something like this could occur.

Is there anything I can do to improve my code so that it runs to completion?

Formulas:

argmax

product

This is my code (first time coding with Wolfram|Cloud):

unr =  4;
lnr =  3;
size = unr * lnr;
eps =  0.2;

e = SparseArray[{{2, 3} -> -1}, {size,size}];
n = Array[f , {size,size}];

bounds = (If[0 <= # <= 1, True, Throw[False], Throw[False]])&;
checkLessEquals = (Catch[Map[bounds, #, {2}]; Throw[True]])&;

prod = (Total[#1*#2, 2])&;

ArgMax[
  {eps *  prod[e, n] + Log[Det[n+IdentityMatrix[size]]], 
   checkLessEquals[n] && PositiveDefiniteMatrixQ[n]}, 
  Flatten[n]]
$\endgroup$
12
  • $\begingroup$ "from a paper" - for reference, could you link to it, please? $\endgroup$ Commented Jan 14, 2017 at 5:42
  • $\begingroup$ @J.M. Sure. Sorry, i forgot to reference it. $\endgroup$
    – Spenhouet
    Commented Jan 14, 2017 at 5:52
  • $\begingroup$ Does it make sense to get that Det[]? Note that you should be able to work out for yourself what the Determinant is with relative ease! It's a lot of work, but this is what hangs your calculation. $\endgroup$
    – Feyre
    Commented Jan 14, 2017 at 10:01
  • $\begingroup$ @Feyre: I can't exclude Det[] from the calculation because i'm trying to find a matrix (n) that maximises the complete formula. I thought it's more likely that the computation is so bad because i have 144 variables that i'm ajusting to find a maximum for the calculation. I'm not sure if the constraints / bounds i specified is correct this way.. because that should minimalize the computation. $\endgroup$
    – Spenhouet
    Commented Jan 14, 2017 at 13:51
  • $\begingroup$ You've got other problems though checkLessEquals[n] and PositiveDefiniteMatrixQ[n] both evaluate to False. $\endgroup$
    – Feyre
    Commented Jan 14, 2017 at 14:08

1 Answer 1

1
$\begingroup$

You can test for the conditions explicitly:

ve = Array[v, {size}];
ArgMax[{(eps*prod[e, n] + Log[Det[n + IdentityMatrix[size]]]), 
0 < # < 1 & /@ Flatten@n, ({ve}.n.ve) > 0}, Flatten[{n, ve}]]
Chop[%, 10^-8]

1., 0, 1., 1., 0, 0, 1., 1., 0, 1., 1., 0, 0, 1., 1., 0, 0, 0, 0, 0, 1., 1., 1., 1., 1., 0, 1., 0, 1., 1., 1., 1., 0, 0, 0, 1., 1.4288, 0.403799, -0.37193, 0.742415, -0.39883, -0.0280605}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.