This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.ims.tests; | |
import java.util.List; | |
import ch.ims.core.TourGenerator; | |
import ch.ims.model.TourStop; | |
public class GrowingTour { | |
public static void runTest(int nLoop, int initSize) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Generate random Tour | |
#' | |
#' Generates a random Tour with nrows number of stops with x/y coordinates and | |
#' a 4-digit random ZIP-code. | |
#' | |
#' @param nrows numeric, the number of stops | |
#' | |
#' @return data.frame, the tour | |
#' @export | |
generate_random_tour_dynamic <- function(nrows) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Generate random Tour | |
#' | |
#' Generates a random Tour with nrows number of stops with x/y coordinates and | |
#' a 4-digit random ZIP-code. | |
#' | |
#' @param nrows numeric, the number of stops | |
#' | |
#' @return data.frame, the tour | |
#' @export | |
generate_random_tour <- function(nrows) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model.obj = [1,1,0,0,0,0]'; | |
model.sense = ['=', '=', '=', '=', '>', '>', '>', '>']'; | |
model.rhs = [200000, 100, 200, 0, 0, 0, 0, 0]'; | |
model.lb = [0, 0, 0, 0, 0, 0]'; | |
model.ub = [1e22, 1e22, 1e22, 1e22, 1e22, 1e22]'; | |
model.vtype = ['C', 'C', 'C', 'C', 'C', 'C']' | |
model.A = sparse([800, 400, 1, 0, 0, 0; 1, 0, 0, -1, 0, 0; 0, 1, 0, 0, -1, 0; 2, -1, 0, 0, 0, 1; zeros(4,2), eye(4)]); | |
model.modelsense = 'max'; | |
model.slack = [0, 0, 1, 1, 1, 1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tictoc) | |
fibonacci <- function(n) { | |
if (n > 1) { | |
return (fibonacci(n-2) + fibonacci(n-1)) | |
} else if (n == 1) { | |
return (1) | |
} | |
return(0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tic | |
fibonacci(30) | |
toc | |
function [n] = fibonacci(x) | |
if (x == 1 || x==0) | |
n = x; | |
else | |
n = fibonacci(x-1) + fibonacci(x-2); | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci(n): | |
if n >= 2: | |
return fibonacci(n - 2) + fibonacci(n - 1) | |
elif n == 2: | |
return 1 | |
elif n == 1: | |
return 1 | |
else: | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fibonacci { | |
public static void main(String[] args) { | |
long start = System.nanoTime(); | |
long a = fibonacci(30); | |
long end = System.nanoTime(); | |
System.out.println("Result: a="+a+ ", calculation time was " + (end - start)/1e9+" s."); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type = "text/javascript"> | |
function fibonacci(n) | |
{ | |
if (n > 2) | |
return fibonacci(n-2) + fibonacci(n-1); | |
if (n == 2 || n == 1) | |
return 1; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#include <sys/time.h> | |
int fibonacci(int n); | |
int main() { | |
clock_t begin, end; | |
float z; | |
int a; |
OlderNewer