10000 Jackson bin packing by joshuaguerin · Pull Request #33 · joshuaguerin/Answer-Set-Programming-Algorithms · GitHub
[go: up one dir, main page]

Skip to content

Jackson bin packing #33
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jum 8000 p to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Bin-Packing/gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Problem: Bin-Packing Generator

## Description
The generator allows the user control over 2 variables, how many items to generate, and the max weight of the items.
It begins by establishing all the possible elements for the solver. Then it lists out each item individually and
randomly assigns a weight to each.
35 changes: 35 additions & 0 deletions Bin-Packing/gen/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# File: generate.py
# Author: Jackson Madsen

# Description: Set generator for Bin Packing problem solver
# Use: python3 generate.py -n n -w w > filename.lp
# where: n is the number of items to generate
# w is the maximum weight of an item
# filename.lp is the location to save the instance file to
# Each of n and w can be omitted (Defaults n=10, w=5)
# The redirect (> filename.lp) can be omitted (to print to stdout)


import random
import argparse

# Process Arguments
parser = argparse.ArgumentParser()

parser.add_argument('-n', default = 10, type = int,
help = "The number of items to generate. (Default = 10)")

parser.add_argument('-w', default = 5, type = int,
help = "The maximum weight of an item, non-inclusive. (Default = 5)")

args = parser.parse_args()

print("% Possible items")
# Print all possible items
print(f"item(1..{args.n}).")
print()

print("% Item definitions\n% item(number, cost).")
# Assign weights to each individual item
for i in range(1, args.n + 1):
print(f"item({i}, {random.randint(1,args.w)}).")
0