This file contains hidden or 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.sat.python import cp_model | |
| def x_is_outside_range(model, x, i, D): | |
| """Returns a boolean literal that is True if (x > i OR x <= i - D).""" | |
| # 1. Create the boolean that represents the final state | |
| is_outside = model.new_bool_var(f'outside_{i}_{D}') | |
| # 2. Define the two possible ways to be 'outside' | |
| too_high = model.new_bool_var('too_high') |
This file contains hidden or 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 <iostream> | |
| #include <cstdint> | |
| #include <functional> | |
| #include <string> | |
| #include <optional> | |
| //using F = std::function<int(int,int)>; | |
| template <typename RType, typename DummyType = int64_t, | |
| typename PType = int32_t, |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| """Development In Progress | |
| CVRPTW. | |
| or-tools == 9.9.3963 | |
| python == 3.11.7 | |
| Number of Regular Nodes = 16, | |
| Depot Nodes = 1 |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| """ | |
| Having a cost different if a node is visited last or along the route | |
| """ | |
| from ortools.constraint_solver import routing_enums_pb2 | |
| from ortools.constraint_solver import pywrapcp | |
| def create_data_model(): |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| """Solve a multiple knapsack problem using the CP-SAT solver.""" | |
| from ortools.sat.python import cp_model | |
| def main(): | |
| data = {} | |
| data["weights"] = [48, 30, 42, 36, 36, 48, 42, 42, 36, 24, 30, 30, 42, 36, 36] | |
| data["values"] = [10, 30, 25, 50, 35, 30, 15, 40, 30, 35, 45, 10, 20, 30, 25] | |
| assert len(data["weights"]) == len(data["values"]) | |
| data["num_items"] = len(data["weights"]) |
This file contains hidden or 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
| ```sh | |
| $ sysctl hw.optional | |
| hw.optional.arm.FEAT_FlagM: 1 | |
| hw.optional.arm.FEAT_FlagM2: 1 | |
| hw.optional.arm.FEAT_FHM: 1 | |
| hw.optional.arm.FEAT_DotProd: 1 | |
| hw.optional.arm.FEAT_SHA3: 1 | |
| hw.optional.arm.FEAT_RDM: 1 | |
| hw.optional.arm.FEAT_LSE: 1 | |
| hw.optional.arm.FEAT_SHA256: 1 |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| '''Simple test | |
| ''' | |
| from ortools.sat.python import cp_model | |
| import pandas as pd | |
| # Define the dataframe with feature columns and the target column | |
| data = { | |
| 'A': [1.59, 0.9, 2.82,2.44,2.61], | |
| 'B': [0.68,0.1,1.3,1.64,1.59], |
This file contains hidden or 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 <cstdio> | |
| #include <iostream> | |
| #include <filesystem> | |
| #include <fstream> | |
| namespace fs = std::filesystem; | |
| int main() | |
| { | |
| const std::string filename = std::tmpnam(nullptr); |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| """Vehicles Routing Problem (VRP). | |
| Some point are on the same physical location | |
| No more than two vehicle to visit a physical location | |
| """ | |
| from ortools.constraint_solver import routing_enums_pb2 | |
| from ortools.constraint_solver import pywrapcp | |
This file contains hidden or 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
| // Based on the GDC 2017 talk "Math for Game Programmers: Noise-Based RNG" | |
| // https://www.youtube.com/watch?v=LWFzPP8ZbdU&ab_channel=GDC | |
| const BIT_NOISE1 = 0xB5297A4D | |
| const BIT_NOISE2 = 0x68E31DA4 | |
| const BIT_NOISE3 = 0x1B56C4E9 | |
| const PRIME1 = 198491317 | |
| const PRIME2 = 6542989 | |
| class Squirrel3 { |
NewerOlder