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
import matplotlib.pyplot as plt | |
def remove_duplicate_candidates(N): | |
''' | |
Accept a list of candidate solutions (being binary lists) and make sure, each (element)-list is contained only once. | |
:param N: | |
:return: revised list containing no duplicate candidates | |
''' |
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
from ortools.linear_solver import pywraplp | |
import numpy as np | |
def solve(sudoku): | |
""" | |
Solve the sudoku passed | |
:param sudoku: a 9x9 sudoku field | |
:return: the completed 9x9 sudoku field | |
""" | |
# Create the model. |
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 construct_knapsack_solution(weights, values, capacity): | |
''' | |
Create a fair (initial) knapsack solution | |
:param weights: Weights of the objects in the knapsack problem | |
:param values: Values assigned to the knapsack items | |
:param capacity: Capacity of the knapsack | |
:return: an (initial) solution to start knapsack optimization with | |
''' | |
# enrich list with value/weight for each weight-value tupel |
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 remove_duplicate_candidates(N): | |
''' | |
Accept a list of candidate solutions (being binary lists) and make sure, each (element)-list is contained only once. | |
:param N: | |
:return: revised list containing no duplicate candidates | |
''' | |
unique_set = set(tuple(lst) for lst in N) | |
unique_list_of_lists = [list(tpl) for tpl in unique_set] | |
return unique_list_of_lists |
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
# 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') |
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
# 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') |
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
# 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') |
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
# -*- 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 |
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
<?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> |
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
# -*- 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 |
NewerOlder