This homework has an opportunity for substantial extra credit, which is described at the end of this document.

Similar documents
CS 2316 Individual Homework 5 Joint Probability Out of 100 points

CS 2316 Homework 9a Login Due: Friday, November 2nd, before 11:55 PM Out of 100 points. Premise

CS 2316 Homework 9b GT Room Reservation

CS 2316 Homework 9b GT Thrift Shop Due: Wednesday, April 20 th, before 11:55 PM Out of 100 points. Premise

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

CS 2316 Homework 9a GT Room Reservation Login

CS 2316 Homework 9a GT Pizza Login Due: Wednesday November 6th Out of 100 points. Premise

CS Homework 4 Lifeguard Employee Ranker. Due: Tuesday, June 3rd, before 11:55 PM Out of 100 points. Files to submit: 1. HW4.py.

CS Homework 4 Employee Ranker. Due: Wednesday, February 8th, before 11:55 PM Out of 100 points. Files to submit: 1. HW4.py.

CS 1803 Pair Homework 10 Newsvendor Inventory Policy Due: Monday, November 29th before 6:00 PM Out of 100 points

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, September 8th, before 6 PM Out of 100 points

CS 1301 Pair Homework 4 Conditionals & Loops Due: Friday, October 1, before 6 PM Out of 100 points

CSCI 204 Introduction to Computer Science II

CS 2316 Pair 1: Homework 3 Enigma Fun Due: Wednesday, February 1st, before 11:55 PM Out of 100 points

CS 1301 Homework Robot Web Writer

CMSC 201 Spring 2017 Project 1 Number Classifier

CSE 142, Autumn 2018 Programming Assignment #9: Critters (20 points) Due Tuesday, December 4th, 9:00 PM

CMSC 201 Spring 2018 Project 2 Battleship

CS 1803 Individual Homework 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points

Homework 5. Due Friday, March 1 at 5:00 PM

CS 1301 Individual Homework 3 Conditionals & Loops Due: Monday February 8 th before 11:55pm Out of 100 points

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

LIBRE OFFICE CALC What is Calc? Spreadsheets, sheets, and cells spreadsheets Spreadsheets Cells

The State Universtiy of New York, Korea Computer Science

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, January 20 th, before 11:55 PM Out of 100 points

Designing a track in Adams/Car:

CMSC 201 Spring 2018 Project 3 Minesweeper

CS150 - Assignment 5 Data For Everyone Due: Wednesday Oct. 16, at the beginning of class

Premium POS Pizza Order Entry Module. Introduction and Tutorial

Self assessment due: Monday 10/29/2018 at 11:59pm (submit via Gradescope)

CPSC 217 Assignment 3

Assignment 4: Dodo gets smarter

Individual Homework- Create Your Own Password! Due: September 15 th, 2014 Before 11:55PM Out of 100 points

Visit the TA Helpdesk (schedule posted on class website)

CS195H Homework 1 Grid homotopies and free groups. Due: February 5, 2015, before class

When to use the Grid Manager

Solutions to Problem 1 of Homework 3 (10 (+6) Points)

What can I say? The Excel program window (shown in Figure 1-1)

ICDL & OOo BASE. Module Five. Databases

Decision Logic: if, if else, switch, Boolean conditions and variables

CS2223: Algorithms D-Term, Assignment 5

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

EXCEL 2007 GETTING STARTED

Microsoft Office 2016 Mail Merge

Table Basics. The structure of an table

EXAM Computer Science 1 Part 1

Instructions for Crossword Assignment CS130

Exercise 1: Tail Sum of Squares (2 points) Homework 3 READ THIS BEFORE YOU BEGIN:

MS Office for Engineers

A Brief Introduction to the ProClarity Enrollment Reports

Read every line of the exam sheet before programming!

CS 3L (Clancy) Solutions and grading standards for exam 1

CS 1510: Intro to Computing - Fall 2017 Assignment 8: Tracking the Greats of the NBA

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, August 28th, before 11:55 PM Out of 100 points

MS Office 2016 Excel Pivot Tables - notes

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2010

P2: Collaborations. CSE 335, Spring 2009

Spring 2017 CS 1110/1111 Exam 3

Homework 8: Matrices Due: 11:59 PM, Oct 30, 2018

1. To access the Course settings page, click Edit settings in the Administration block.

: Principles of Imperative Computation. Fall Assignment 5: Interfaces, Backtracking Search, Hash Tables

Spring 2017 CS 1110/1111 Exam 1

Lesson 6: Modeling Basics

Beginning PowerPoint XP for Windows

Grade Point Scales Standard Honors AP/College A B C D F Sample file

Read this before starting!

CMSC 201 Spring 2017 Homework 4 Lists (and Loops and Strings)

CS 1301 Exam 1 Fall 2010

CMSC 201 Fall 2016 Homework 6 Functions

Premium Auto Attendant USER GUIDE

Homework 8 Lights, Camera, Robot Action! Due: Friday, April 13th, before 11:55 PM EST Out of 200 points Files to submit: {filmingcode.

CSCI 1301: Introduction to Computing and Programming Spring 2018 Project 3: Hangman 2.0 (A Word Guessing Game)

Some (semi-)advanced tips for LibreOffice

Unit 1, Lesson 1: Tiling the Plane

Excel Forecasting Tools Review

ADMINISTRATOR USER GUIDE NYC REPORTING TOOL

CS 1110, LAB 1: PYTHON EXPRESSIONS.

Lab 4: Strings/Loops Due Apr 22 at midnight

CSci 1113 Lab Exercise 6 (Week 7): Arrays & Strings

Geometric Entities for Pilot3D. Copyright 2001 by New Wave Systems, Inc. All Rights Reserved

Premium Auto Attendant User Guide

FTRESTORE. Yaesu FT Radio Configuration Restore Utility

CS 2316 Exam 2 Summer 2011

Assignment 4 One and two dimensional arrays. Cinema Booking System

Project 1 - Battleship Game

Unit 2 Fine-tuning Spreadsheets, Functions (AutoSum)

Business Process Procedures

CS 051 Homework Laboratory #2

2018 Pummill Relay problem statement

Learning Worksheet Fundamentals

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Lab 12: Sampling and Interpolation

Microsoft Excel Level 2

CS 134 Test Program #2

Part 1. Creating an Array of Controls or Indicators

Spring CS Homework 3 p. 1. CS Homework 3

Transcription:

CS 2316 Pair Homework Box Packer Due: Tuesday, June 17th, before 11:55 PM Out of 100 points Files to submit: 1. boxpacker.py For Help: - TA Helpdesk Schedule posted on class website. - Email TA's or use T-Square Forums Notes: Don t forget to include the required comments and collaboration statement (as outlined on the course syllabus). Do not wait until the last minute to do this assignment in case you run into problems. Read the entire specifications document before starting this assignment. Premise This homework will have you packing rectangular objects into a 2D space, similar to packing boxes into a flat truck. You will be given the dimensions of the space you are packing objects into, as well as a list of boxes. With this information, you will implement and analyze two algorithms that will pack the boxes into the truck: the first which packs the largest boxes into the truck first, and the second which packs the smallest boxes into the truck first. Your program will then report to the user how many boxes were packed, which boxes were packed, which boxes were not packed, and how much space on the truck is left unfilled, using a GUI that you will create. Homework 6 is a problem-solving homework; we want you to reason through how to develop the algorithms and place things in the GUI, so do not wait until the last minute to start this assignment, as this assignment requires you to implement a large amount of functionality. This homework has an opportunity for substantial extra credit, which is described at the end of this document. File Format Information You will be required to read in a CSV file of data about the boxes you will be packing.

The format for each row is as follows: BOX ID, LENGTH, WIDTH BOX ID is a string that uniquely identifies each box that you will try to place on the truck. It is a string of letters and numbers that may be of any length, such as X5QR76. LENGTH is the length of the box, in feet. This number should be an integer, such as 2. The length of the box is analogous to the number of rows in your implementation. WIDTH is the width of the box, in feet. This number should be an integer, such as 2. The width is analogous to the number of columns in your implementation. A sample row in the file would be X5QR76, 2, 2 There is no limit to the number of rows that may be contained within the file. The Truck For this assignment, we re going to be packing boxes only one layer high (i.e. in two dimensions only), so we will represent the truck as a 2-dimensional list. This 2- dimensional list should be stored as an instance variable named "truck" so that all methods you write will be able to access the 2D list using "self.truck". The 2D list will have a cell for each square foot present in your truck; an empty cell will be represented by an empty string, while an occupied cell will be represented by the Box ID of the box that occupies that cell. Represented as a table, a possible truck could look like the following: X5QR76 X5QR76 123XYZ 123XYZ X5QR76 X5QR76 Method Name: init This method is automatically called whenever you create a new instance of your GUI class. The init method is responsible for arranging and initializing your GUI. You should create a GUI which looks like the following:

You may generate this window however you wish, but it is highly suggested that you use the grid layout manager. Things to note about the GUI you see: The entry box between the Boxes File: label and the Select File button is width 75, readonly, and has text if no file has been selected. Clicking on the Select File button should call the openfileclicked method. Largest Box First and Smallest Box First are Radiobutton widgets. When the window is first opened, neither of these radio buttons should be selected. The width and width entry boxes are the default width and have a state of NORMAL. The Pack Boxes & Save Results button should span the width of the entire window (Hint: To make something like a button or entry box expand to take up the whole space, sticky it in both the east and west directions when using the grid layout manager). Clicking on this button calls the packnsaveclicked method. Method Name: openfileclicked This method will simply launch a file open dialog box and prompt the user to select a file. If the user selects a file, the text for the Entry box beside the Boxes file: label will be set to the file the user chose. If the user chooses cancel, you must set the text of this entry box to be. Store the file name returned in the "filename" object variable, so that other methods (such as readboxsfile) can access the string using "self.filename". Method Name: readboxesfile

This method will open the file which the user specified in the open file dialog box, read in the CSV file, and store the data that is read from the file as an object variable which points to a list of lists. Name this object variable "boxes" so that other methods can access it using "self.boxes". As you read in each row from the CSV file, you should convert the width and length data into integers before saving the row. In the event that a piece of data in the CSV file is malformed (doesn t have all the required data or has a non-integer width and/or length) or the user did not give you a valid CSV file, you should raise a ValueError which you will catch in the packandsaveresults method. Remember to close the file when you are finished. Method Name: isvalidlocation Integer The row number of the cell you re testing Integer The column number of the cell you re testing Integer The width of the box you re trying to pack Integer The length of the box you re trying to pack Boolean True if the box can be packed into the truck starting at location row, col, False if it cannot be packed starting at that location. This method will check to see if you can pack a box (with certain dimensions that you passed in) into the truck, with the box s upper left corner starting at the row, column position that was passed in. Do not change the orientation of the box when trying to check and see if the location is valid. (Your union does not allow you to rotate boxes!) The method should return True if none of the cells in the truck that would be occupied by the box are used by another box, and if the box can fit into the truck at that location (i.e. doesn t extend beyond the boundaries of the truck). This method should return False if there is any overlap or if the box would extend beyond the boundaries of the truck. Method Name: filltrucklocation()

Integer The row of the space where you wish to start packing the box. Integer The column of the space where you wish to start packing the box. List The list of box information This method will accept a row and column, which represents the location where the upper left corner of the box will be located. You must fill in spaces starting at row, col and expanding to the right the width of the box and expanding down the length of the box. You should fill in each cell with the Box ID of the box you are filling the space with. Method Name: packbox() List A list containing the data for one particular box. A Boolean True if the box was successfully packed into the truck, False if it was not. This method will look through the truck and try to find the first empty cell, starting with the first row and first column, then moving to the right on that row until there are no more cells to check, then moving to the second row, first column, then moving to the right until there are no more cells to check on that row, and so on and so forth. When you find an empty cell, you will attempt to pack the upper left-corner of the box into this position, and the rest of the box will extend to the right and down; use the isvalidlocation method you wrote to see if the box will fit in this location. If it will fit, call the filltrucklocation method with the appropriate information and return True. If the box will not fit into this location, continue searching for an empty cell until you find another one. Repeat this process of finding empty cells and checking to see if the box will fit at that location until you either find a location where the box will fit or you run out of empty locations in the truck. If you have checked all of the empty locations in the truck and none are valid, or if there are no empty locations left, you should return False. Method Name: packtruck() A List A list of all boxes from the CSV file that were not packed into the truck with the given algorithm. This method will attempt to pack all the boxes from the CSV file into the truck.

The order in which it will attempt to place boxes into the truck is dependent upon which radio button the user selected: If the user picked Largest Box First, you will attempt to pack the boxes such that the box with the largest area is packed on the truck first, followed by the second largest area, etc. If two boxes have the same area, prefer boxes that have a larger Box ID (as determined by the python greater than operator). If the user picked Smallest Box First, you will attempt to pack the boxes such that the box with the smallest area is packed on the truck first, followed by the second smallest area, etc. If two boxes have the same area, prefer boxes that have a smaller Box ID (as determined by the python less than operator). When you have attempted to pack all the boxes, you should return a list of boxes that were not packed into the truck. Method Name: writetrucktocsv() This method will write out the contents of the truck object variable as a CSV file. You should be able to open this CSV file in a program such as Excel or LibreOffice Calc and see the table view of the boxes packed into your truck. You do not need to format the data in any special way before writing it out. You should save this file as truckview.csv. Use of csv.writer will make this method trivial to implement. Remember to close the file when you are finished. Function Name: packnsaveclicked This function will set up the truck object variable to have the appropriate number of empty spaces, read in the file containing information about the boxes, pack the boxes using the algorithm the user specified, write the contents of the truck out to the truckview.csv file, and add some widgets to the GUI to show the user some statistics about the truck they just packed. First, you must make sure that the user has entered an appropriate width and length for the truck as well as selected a packing algorithm. If the user did not provide all of this information (or the user entered an invalid value for width or length), you should pop up a message dialog box informing the user of the mistake. If readboxesfile raises a ValueError when you call it, you should display a

message dialog box to the user informing them that the CSV file is invalid. You should not attempt to pack any boxes if this occurs. When you have successfully packed as many boxes as possible using the user s specified algorithm, you should update the GUI so that it looks like the following: You will need to compute the percentage of the boxes packed as well as the percentage of the truck that was filled during the packing process. Additionally, you will need to display the Box IDs of all boxes that were not packed. Below is another test-case output so you can validate your program: Extra Credit Opportunity: If you examine the algorithm and packing procedure we described above, you will notice that this is a rather naïve way to pack the truck. Sometimes, if we had changed the order in which we packed boxes, or didn t necessarily always pack the largest or smallest box, we could find a more optimal solution. Also, we did not permit any kind of transformation of the box, such as a rotation. In some cases, rotating the box would permit the box to be packed. For extra credit, come up with your own packing algorithm and method to fill in spaces in the truck; there are no restrictions on what you can do to pack the boxes this time around. Your objective is maximize the percentage of boxes packed, the percentage of the truck that is filled, or (optimally) both! The TAs will award extra credit based on the creativity of the approach as well as the results; the

better your algorithm is at maximizing the number of boxes packed or the amount of the truck filled, the more extra credit you will receive. Make sure that the basics of your program work correctly; if your extra credit attempt breaks the base functionality, you will lose points! If you choose to do this, you need to modify your program so you have three radio buttons instead of two; the third radio button should be labeled appropriately, and when a user selects it, it should pack the boxes using your packing algorithm and method. At the top of your file, write a brief description of how your algorithm and method work and why it is better than the two algorithms we provided. Be sure to comment your custom algorithm thoroughly!

Grading: You will earn points as follows for each piece of functionality that works correctly according to the specifications. The GUI 20 GUI has all required initial components 10 openfileclicked works as described 5 GUI has proper error checking 5 readboxesfile() 6 Successfully reads in all information from file 2 Stores data from file in an instance variable 2 Converts width and length into integers 2 isvalidlocation() 10 Checks truck boundaries 5 Correctly checks all relevant spaces in truck 5 filltrucklocation() 7 Correctly fills all spaces in the truck with given dimensions 7 packbox() 8 Correctly searches for empty spaces 5 Correctly calls filltrucklocation when space found 3 packtruck() 25 Keeps track of unpacked boxes correctly 10 Attempts to execute correct packing algorithm 5 Packs boxes in correct order 10 writecsvfile() 4 Writes CSV file correctly 4 packnsaveclicked() 20 Adds new GUI elements after computation 10 Does not reimplement functionality from other methods 3 Percent packed and percent empty computed correctly 7