Luck is undergoing some structural changes to support vocal programming. The project here will form the sub-lingual domain, but the spoken language will be developed separately by deep learning.

Demo Client for 2015 Black Box Optimization Competition

Download Source Files

BBComp is an optimization competition sponsored by the Microsoft Research - Inria joint centre. The goal is to optimize a function while not knowing any properties of the function beforehand. Until the contest results are released, we can only guess at what the generating function may be. For all we know it could be a lookup table of random values...

Anyone with experience in functional analysis is welcome to join the Luck team. We will be accepting new members until the submission deadline of June 30th, 2015. The Luck team will be competing in the GECCO'2015 track.

import "bbcomplib.h";;
import "stdio.h";;
import "stdlib.h";;
import "time.h";;
import "unistd.h";;

function optimize(): void = (
   print("black box example competition client in Luck");
   if configure!(1,"logs/":char*)==0 then failwith("configure() failed: " + string(errorMessage!()));

   if login!("demoaccount":char*, "demopassword":char*)==0 then failwith("login() failed: " + string(errorMessage!()));
   print("login successful");

   let numTracks = numberOfTracks!() in
   if numTracks==0 then failwith("numberOfTracks() failed: " + string(errorMessage!()));
   print(string(numTracks) + " track(s):");
   for i in range(numTracks) do (
       let trackname = trackName!(i) in
       if trackname==null then failwith("trackName() failed: " + string(errorMessage!()))

   if setTrack!("trial":char*)==0 then failwith("setTrack() failed: " + string(errorMessage!()));
   print("track set to 'trial'");

   let numProblems = numberOfProblems!() in
   if numProblems==0 then failwith("numberOfProblems() failed: " + string(errorMessage!()));
   printf("The track consists of %d problems.\n":char*, numProblems);

   let problemID = 0 in
   if setProblem!(problemID)==0 then failwith("setProblem() failed: " + string(errorMessage!()));
   print("Problem ID set to " + string(problemID));

   let dim = dimension!() in
   if dim==0 then failwith("dimension() failed: " + string(errorMessage!()));
   let bud = budget!() in
   if bud==0 then failwith("budget() failed: " + string(errorMessage!()));
   let evals = evaluations!() in
   if evals<0 then failwith("evaluations() failed: " + string(errorMessage!()));
   print("problem dimension: " + string(dim));
   print("problem budget: " + string(bud));
   print("number of already used up evaluations: " + string(evals));

   let point = malloc((dim as size_t) * sizeof(double)) as double* in
   if point==null then failwith("out of memory");

   let value:double in
   let bestValue:double = 1e100 in
   let bestEvaluation = -1 in
   srand(time(null) as unsigned);
   for e in range(bud) do
   if e<evals then (
      if history!(e, point, &value)==0 then failwith("history() failed: " + string(errorMessage!()));
      if value<bestValue then (
         bestValue = value;
         bestEvaluation = e
   ) else (
      for d in range(dim) do point[d] = (rand() as double)/((RAND_MAX as double) + (0.5:double));
      if evaluate!(point, &value)==0 then failwith("evaluate() failed: " + string(errorMessage!()));
      printf("[%d] %g\n":char*, e, value);
      if value<bestValue then (
         bestValue = value;
         bestEvaluation = e
   printf("best value: %g\n":char*, bestValue);
   if history!(bestEvaluation, point, &value)==0 then failwith("history() failed: " + string(errorMessage!()));
   printc("best point:");
   for d in range(dim) do printf(" %f":char*, point[d]);
   free(point as void*);
   if evaluations!()==bud
   then print("optimization finished.")
   else print("something went wrong: number of evaluations does not coincide with budget :(")

if DLL_LOAD_STATUS<0 then failwith("error loading library");;