Message Boards Message Boards

Running MaximizeOverPermutations in Python using WolframClient

Posted 1 year ago

Hello, I am trying to use the MaximizeOverPermutations over permutations function in Python as I have to use this for an optimization problem. I am new to using Wolfram client and wolfram functions and I am not sure how to run this example in Python.

f[{1, 2, 3}] = 2;
f[{1, 3, 2}] = 9;
f[{2, 1, 3}] = 1;
f[{2, 3, 1}] = -3;
f[{3, 1, 2}] = 9;
f[{3, 2, 1}] = 5;

ResourceFunction["MaximizeOverPermutations"][f, 3]

I am running the following code but there is obviously something wrong with the syntax:

from wolframclient.language import wl
from wolframclient.evaluation import WolframLanguageSession

session = WolframLanguageSession('C:\\Program Files\\Wolfram Research\\Mathematica\\13.2\\WolframKernel.exe')
f[{1, 2, 3}] = 2;
f[{1, 3, 2}] = 9;
f[{2, 1, 3}] = 1;
f[{2, 3, 1}] = -3;
f[{3, 1, 2}] = 9;
f[{3, 2, 1}] = 5;
m = session.evaluate(wl.ResourceFunction["MaximizeOverPermutations"][f, 3])
print(m)
session.terminate()

Can someone please explain how to run this example in Python?

POSTED BY: Ram Krishna
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract