Skip to content

Instantly share code, notes, and snippets.

Avatar

Fabian Leuthold phabee

View GitHub Profile
View ortools_gurobi.py
# source based on code presented here https://developers.google.com/optimization/mip/integer_opt
from ortools.linear_solver import pywraplp
# example how to solve a MIXED integer linear program continuous and integer variables
# and solve it with a gurobi solver installed (or gurobi cloud).
def main():
# Create the mip solver with the SCIP backend.
solver = pywraplp.Solver.CreateSolver('GUROBI_MIP')
View ortools_lp.py
# source based on code presented here https://developers.google.com/optimization/mip/integer_opt
from ortools.linear_solver import pywraplp
# example how to solve a linear program having ONLY continuous variables
def main():
# Create the mip solver with the SCIP backend.
# HINT: GLOP cannot handle integer variables!
solver = pywraplp.Solver.CreateSolver('GLOP')
View ortools_mip.py
# source based on code presented here https://developers.google.com/optimization/mip/integer_opt
from ortools.linear_solver import pywraplp
# example how to solve a MIXED integer linear program continuous and integer variables
# x is continuous
# y is integer
def main():
# Create the mip solver with the SCIP backend.
solver = pywraplp.Solver.CreateSolver('SCIP')
View addition_dialog.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'addition_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
View addition_dialog.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>247</height>
View addition_dialog.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'addition_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
View tsp_pilot_example.R
#' get next best pilot stop using nearest neighbor
#'
#' @param tour
#' @param dima
#'
#' @return
#' @export
get_best_pilot_stop <- function(tour, dima) {
stops <- 1:nrow(dima)
potential_stops <- stops[-tour]
@phabee
phabee / diet.m
Last active Nov 4, 2020
MATLAB GUROBI Diet Example Script
View diet.m
function diet()
% Copyright 2020, Gurobi Optimization, LLC
%
% Solve the classic diet model
% Nutrition guidelines, based on
% USDA Dietary Guidelines for Americans, 2005
% http://www.health.gov/DietaryGuidelines/dga2005/
ncategories = 4;
View fibonacci.c
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
int fibonacci(int n);
int main() {
clock_t begin, end;
float z;
int a;
View fibonacci.html
<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;
}