<commit_before>import Numeric.Optimization.Algorithms.CMAES

-- a function with minimum at x[i]=sqrt(i)
f xs = sum $ zipWith (\x i -> abs $ x**2-i) xs [1..]

-- a function with scale diversity
f2 xs = sum $ zipWith (\x i -> abs $ (x/1e4**i)**2-i ) xs [1..]

main = do
  -- this works fine
  xs <- run $ minimizer [1..10] f
  print xs

  -- if the scale for parameters differ too much
  -- it doesn't work very well
  xs <-run $ minimizer [1..10] f2
  print xs

  -- you need to hint the mimimizer with the
  -- appropriate scales
  xs <- run $
         (minimizer [1..10] f2)
           {scaling = Just [1e4**i | i<-[1..10] ] }
  print xs
<commit_msg>even more severe incline<commit_after>import Numeric.Optimization.Algorithms.CMAES

-- a function with minimum at x[i]=sqrt(i)
f xs = sum $ zipWith g xs [1..]
  where
    g x i = (x * abs x - i)**2

-- a function with scale diversity
f2 xs = sum $ zipWith g xs [1..]
  where
    g x' i = let x = x'/1e10**i in
      (x * abs x - i)**2

main = do
  -- this works fine
  xs <- run $ minimizer [1..10] f
  print xs
  print $ f xs

  -- if the scale for parameters differ too much
  -- it doesn't work very well
  xs <-run $ minimizer [1..10] f2
  print xs
  print $ f2 xs

  -- you need to hint the optimizer with the
  -- appropriate scales
  xs <- run $
         (minimizer [1..10] f2)
           {scaling = Just [1e10**i | i<-[1..10] ] }
  print xs
  print $ f2 xs

{'fraction_non_alphanumeric': 0.13983050847457626, 'fraction_numerical': 0.03531073446327684, 'mean_word_length': 2.148888888888889, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3148056', 'n_tokens_mistral': 569, 'n_tokens_neox': 516, 'n_words': 198}