Built-in variablesと関数

Variables

Modeling & Solving

  • lsTimeLimit = {10, 50}; Spends 10 (resp. 50) sec to optimize objective 0 (resp. 1).
  • lsTimeLimit = 60; Corresponds to lsTimeLimit = {0,..., 0, 60}.
  • lsIterationLimit = {1000, 5000}; Spends 1000 (resp. 5000) iterations to optimize objective 0 (resp. 1).
  • lsIterationLimit = 6000; Corresponds to lsIterationLimit = {0,..., 0, 6000}.
  • lsTimeBetweenDisplays = 5; Displays info about the search every 5 sec (default: 1).
  • lsSeed = 9; Sets pseudo-random number generator seed to 9 (default: 0).
  • lsNbThreads = 4; Parallelizes the search over 4 threads (default: 2).
  • lsAnnealingLevel = 9; Sets simulated annealing level to 9 (no annealing: 0, default: 1).
  • lsVerbosity = 1; Sets verbosity to 1 (no display: 0, default: 1).

Functions

Input & Output

  • f = openRead("data.in"); Opens file "data.in" in reading mode.
  • f = openWrite("data.out"); Opens file "data.out" in writing mode.
  • f = openAppend("data.out"); Opens file "data.out" in append mode.
  • close(f); Closes the file.
  • eof(f) Returns true if the end of file is reached.
  • i = readInt(); Prompt the user for an int (in the console standard input).
  • i = readInt(f); Reads the next int parsed in file.
  • s = readln(); Prompt the user for a line (in the console standard input).
  • s = readln(f); Reads the next line of file.
  • s = readString(f); Reads the next string parsed in file.
  • print("s = " + s + "\n"); Prints the string in console.
  • print(f, "s = " + s + "\n"); Prints the string in file.
  • println("s = " + s); Prints the string followed by a line feed in console.
  • println(f, "s = " + s); Prints the string followed by a line feed in file.
  • error(msg); Prints an error message and exits.

Map

  • m = map(); m = {}; Creates an empty map.
  • m = map(9, "abc"); m = {1, "abc"}; Creates a map containing values 9, "abc" at keys 0, 1 respectively.
  • nbElems = count(m); Counts the number of values in the map.
  • elems = values(m); Returns the values of the map as a map.
  • indices = keys(m); Returns the keys of the map as a map.
  • add(m, 123); Adds 123 in the map with key equals to the largest integer key plus one.

String

  • i = toInt("123"); Converts the string into the corresponding integer (or throws an error if not possible).
  • m = split("a::b::c::d", "::"); Splits string "a::b::c::d" into substrings (as a map) according to the separator "::".
  • s = trim(" abcd "); Removes white spaces at the beginning and at the end of the string.
  • len = length("abcd"); Returns the length of a string.
  • s = substring("abcd",1,2); Returns a new string that is a substring of this string.There are two versions of this function: The first one takes two arguments : the string, and the start index of the substring. The second one takes 3 arguments : the string, the start index and the length of the substring.
  • b = startsWith("abcd","ab"); Returns true if the first argument starts with the specified prefix given as a second argument.If the second argument is the empty string, returns true.
  • b = endsWith("abcd","cd"); Returns true if the first argument ends with the specified suffix given as a second argument.
  • s = lowerCase("ABCD"); Returns a new string converted to lower case.
  • s = upperCase("abcd"); Returns a new string converted to upper case.
  • s = replace("abcd","bc","x"); Replaces each substring of a string that matches the literal target string with the specified literal replacement string. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaaaa" will result in "bba" rather than "abb".This function takes 3 arguments :subject string, searched sequence and replace sequence.

Modeling & Solving

  • getObjectiveBound(1); Gets the bound of objective (with index) 1.
  • setObjectiveBound(1, 9999); Sets the bound of objective 1 to 9999.
  • v = getValue(x); Gets the value of modeling expression x in the best solution found by the solver.
  • setValue(x, 1); Sets the value of x to 1 in the initial solution (or throws an error if x is not a decision).

このページの先頭へ