How do you optimize a function that depends on the prime factorization?

30 Views Asked by At

Here's the function:

from sympy.ntheory import factorint
from math import log,floor

la=3
lb=2
a=137
b=84

# (x0,x1,x2)
def objective(x):
  x0=x[0]
  x1=x[1]
  x2=x[2]
  x3=x0*lb**(b-x2)-la**(a-x1)
  qf=1
  if(x3>1):
    factor_f=factorint(x3)
    qf=max(factor_f.keys())
  qe=1
  if(x0>1):
    factor_e=factorint(x0)
    qe=max(factor_e.keys())
  return   x0**4*la**x1*qe**4*log(qe,2)+qf**2

As you can see, it depends on the prime factorization of a number (namely, on its lagest prime factor). Which means that a small change in the initial conditions can radically change the output conditions. You can add +1 to the input, and its prime factorization will change completely. Basic methods like gradient descent or whatever are powerless here.

How do you even minimize such a function? Are there methods?