Finished week 1.
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.sublime-workspace
|
||||||
|
__pycache__
|
||||||
3
anyint/_coursera
Normal file
3
anyint/_coursera
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
heD35Vv_EeajDAoJAOJJEw
|
||||||
|
Any Integer
|
||||||
|
mJWtY, _coursera, solver.py, Send an Integer
|
||||||
BIN
anyint/handout.pdf
Normal file
BIN
anyint/handout.pdf
Normal file
Binary file not shown.
10
anyint/solver.py
Normal file
10
anyint/solver.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
def solve_it(input_data):
|
||||||
|
# return a positive integer, as a string
|
||||||
|
return '10'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print('This script submits the integer: %s\n' % solve_it(''))
|
||||||
|
|
||||||
456
anyint/submit.py
Executable file
456
anyint/submit.py
Executable file
@@ -0,0 +1,456 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# Python 2/3 compatibility
|
||||||
|
# Python 2:
|
||||||
|
try:
|
||||||
|
from urlparse import urlparse
|
||||||
|
from urllib import urlencode
|
||||||
|
from urllib2 import urlopen, Request, HTTPError
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Python 3:
|
||||||
|
try:
|
||||||
|
from urllib.parse import urlparse, urlencode
|
||||||
|
from urllib.request import urlopen, Request
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
import sys
|
||||||
|
# Python 2:
|
||||||
|
if sys.version_info < (3, 0):
|
||||||
|
def input(str):
|
||||||
|
return raw_input(str)
|
||||||
|
|
||||||
|
# Python 3, backward compatibility with unicode test
|
||||||
|
if sys.version_info >= (3, 0):
|
||||||
|
unicode = type(str)
|
||||||
|
|
||||||
|
version = '1.0.0'
|
||||||
|
submitt_url = \
|
||||||
|
'https://www.coursera.org/api/onDemandProgrammingScriptSubmissions.v1'
|
||||||
|
|
||||||
|
Metadata = namedtuple("Metadata", ['assignment_key', 'name', 'part_data'])
|
||||||
|
Part = namedtuple("Part", ['id', 'input_file', 'solver_file', 'name'])
|
||||||
|
|
||||||
|
|
||||||
|
def load_metadata(metadata_file_name='_coursera'):
|
||||||
|
'''
|
||||||
|
Parses an assignment metadata file
|
||||||
|
|
||||||
|
Args:
|
||||||
|
metadata_file_name (str): location of the metadata file
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
metadata as a named tuple structure
|
||||||
|
'''
|
||||||
|
|
||||||
|
if not os.path.exists(metadata_file_name):
|
||||||
|
print('metadata file "%s" not found' % metadata_file_name)
|
||||||
|
quit()
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(metadata_file_name, 'r') as metadata_file:
|
||||||
|
url = metadata_file.readline().strip()
|
||||||
|
name = metadata_file.readline().strip()
|
||||||
|
part_data = []
|
||||||
|
for line in metadata_file.readlines():
|
||||||
|
if ',' in line:
|
||||||
|
line_parts = line.split(',')
|
||||||
|
line_parts = [x.strip() for x in line_parts]
|
||||||
|
assert(len(line_parts) == 4)
|
||||||
|
part_data.append(Part(*line_parts))
|
||||||
|
if len(url) <= 0:
|
||||||
|
print('Empty url in _coursera file: %s' % metadata_file_name)
|
||||||
|
quit()
|
||||||
|
if len(name) <= 0:
|
||||||
|
print('Empty assignment name in _coursera file: %s' % metadata_file_name)
|
||||||
|
quit()
|
||||||
|
except Exception as e:
|
||||||
|
print('problem parsing assignment metadata file')
|
||||||
|
print('exception message:')
|
||||||
|
print(e)
|
||||||
|
quit()
|
||||||
|
|
||||||
|
return Metadata(url, name, part_data)
|
||||||
|
|
||||||
|
|
||||||
|
def part_prompt(problems):
|
||||||
|
'''
|
||||||
|
Prompts the user for which parts of the assignment they would like to
|
||||||
|
submit.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
problems: a list of assignment problems
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the selected subset of problems
|
||||||
|
'''
|
||||||
|
|
||||||
|
count = 1
|
||||||
|
print('Hello! These are the assignment parts that you can submit:')
|
||||||
|
for i, problem in enumerate(problems):
|
||||||
|
print(str(count) + ') ' + problem.name)
|
||||||
|
count += 1
|
||||||
|
print('0) All')
|
||||||
|
|
||||||
|
part_text = input('Please enter which part(s) you want to submit (0-%d): ' % (count-1))
|
||||||
|
selected_problems = []
|
||||||
|
selected_models = []
|
||||||
|
|
||||||
|
for item in part_text.split(','):
|
||||||
|
try:
|
||||||
|
i = int(item)
|
||||||
|
except:
|
||||||
|
print('Skipping input "' + item + '". It is not an integer.')
|
||||||
|
continue
|
||||||
|
|
||||||
|
if i >= count or i < 0:
|
||||||
|
print('Skipping input "' + item + '". It is out of the valid range (0-%d).' % (count-1))
|
||||||
|
continue
|
||||||
|
|
||||||
|
if i == 0:
|
||||||
|
selected_problems.extend(problems)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if i <= len(problems):
|
||||||
|
selected_problems.append(problems[i-1])
|
||||||
|
|
||||||
|
if len(selected_problems) <= 0:
|
||||||
|
print('No valid assignment parts identified. Please try again. \n')
|
||||||
|
return part_prompt(problems)
|
||||||
|
else:
|
||||||
|
return selected_problems
|
||||||
|
|
||||||
|
|
||||||
|
def compute(metadata, solver_file_override=None):
|
||||||
|
'''
|
||||||
|
Determines which assignment parts the student would like to submit.
|
||||||
|
Then computes his/her answers to those assignment parts
|
||||||
|
|
||||||
|
Args:
|
||||||
|
metadata: the assignment metadata
|
||||||
|
solver_file_override: an optional model file to override the metadata
|
||||||
|
default
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
a dictionary of results in the format Coursera expects
|
||||||
|
'''
|
||||||
|
|
||||||
|
if solver_file_override is not None:
|
||||||
|
print('Overriding solver file with: '+solver_file_override)
|
||||||
|
|
||||||
|
selected_problems = part_prompt(metadata.part_data)
|
||||||
|
|
||||||
|
results = {}
|
||||||
|
|
||||||
|
#submission needs empty dict for every assignment part
|
||||||
|
results.update({prob_data.id : {} for prob_data in metadata.part_data})
|
||||||
|
|
||||||
|
for problem in selected_problems:
|
||||||
|
if solver_file_override != None:
|
||||||
|
solver_file = solver_file_override
|
||||||
|
else:
|
||||||
|
solver_file = problem.solver_file
|
||||||
|
|
||||||
|
if not os.path.isfile(solver_file):
|
||||||
|
print('Unable to locate assignment file "%s" in the current working directory.' % solver_file)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# if a relative path is given, add that patth to system path so import will work
|
||||||
|
if os.path.sep in solver_file:
|
||||||
|
split = solver_file.rfind(os.path.sep)
|
||||||
|
path = solver_file[0:split]
|
||||||
|
file_name = solver_file[split+1:]
|
||||||
|
sys.path.insert(0, path)
|
||||||
|
solver_file = file_name
|
||||||
|
|
||||||
|
submission = output(problem.input_file, solver_file)
|
||||||
|
if submission != None:
|
||||||
|
results[problem.id] = {'output':submission}
|
||||||
|
|
||||||
|
print('\n== Computations Complete ...')
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def load_input_data(file_location):
|
||||||
|
with open(file_location, 'r') as input_data_file:
|
||||||
|
input_data = ''.join(input_data_file.readlines())
|
||||||
|
return input_data
|
||||||
|
|
||||||
|
|
||||||
|
def output(input_file, solver_file):
|
||||||
|
'''
|
||||||
|
Attempts to execute solve_it locally on a given input file.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
input_file: the assignment problem data of interest
|
||||||
|
solver_file: a python file containing the solve_it function
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the submission string in a format that the grader expects
|
||||||
|
'''
|
||||||
|
|
||||||
|
try:
|
||||||
|
pkg = __import__(solver_file[:-3]) # remove '.py' extension
|
||||||
|
if not hasattr(pkg, 'solve_it'):
|
||||||
|
print('the solve_it() function was not found in %s' % solver_file)
|
||||||
|
quit()
|
||||||
|
except ImportError:
|
||||||
|
print('import error with python file "%s".' % solver_file)
|
||||||
|
quit()
|
||||||
|
|
||||||
|
|
||||||
|
solution = ''
|
||||||
|
|
||||||
|
start = time.clock()
|
||||||
|
try:
|
||||||
|
solution = pkg.solve_it(load_input_data(input_file))
|
||||||
|
except Exception as e:
|
||||||
|
print('the solve_it(input_data) method from solver.py raised an exception')
|
||||||
|
print('try testing it with python ./solver.py before running this submission script')
|
||||||
|
print('exception message:')
|
||||||
|
print(str(e))
|
||||||
|
print('')
|
||||||
|
return 'Local Exception =('
|
||||||
|
end = time.clock()
|
||||||
|
|
||||||
|
if not (isinstance(solution, str) or isinstance(solution, unicode)):
|
||||||
|
print('Warning: the solver did not return a string. The given object will be converted with the str() method.')
|
||||||
|
solution = str(solution)
|
||||||
|
|
||||||
|
print('Submitting: ')
|
||||||
|
print(solution)
|
||||||
|
|
||||||
|
return solution.strip() + '\n' + str(end - start)
|
||||||
|
|
||||||
|
|
||||||
|
def login_dialog(assignment_key, results, credentials_file_location = '_credentials'):
|
||||||
|
'''
|
||||||
|
Requests Coursera login credentials from the student and submits the
|
||||||
|
student's solutions for grading
|
||||||
|
|
||||||
|
Args:
|
||||||
|
assignment_key: Coursera's assignment key
|
||||||
|
results: a dictionary of results in Cousera's format
|
||||||
|
credentials_file_location: a file location where login credentials can
|
||||||
|
be found
|
||||||
|
'''
|
||||||
|
|
||||||
|
success = False
|
||||||
|
tries = 0
|
||||||
|
|
||||||
|
while not success:
|
||||||
|
|
||||||
|
# stops infinate loop when credentials file is incorrect
|
||||||
|
if tries <= 0:
|
||||||
|
login, token = login_prompt(credentials_file_location)
|
||||||
|
else:
|
||||||
|
login, token = login_prompt('')
|
||||||
|
|
||||||
|
code, responce = submit_solution(assignment_key, login, token, results)
|
||||||
|
|
||||||
|
print('\n== Coursera Responce ...')
|
||||||
|
#print(code)
|
||||||
|
print(responce)
|
||||||
|
|
||||||
|
if code != 401:
|
||||||
|
success = True
|
||||||
|
else:
|
||||||
|
print('\ntry logging in again')
|
||||||
|
tries += 1
|
||||||
|
|
||||||
|
def login_prompt(credentials_file_location):
|
||||||
|
'''
|
||||||
|
Attempts to load credentials from a file, if that fails asks the user.
|
||||||
|
Returns:
|
||||||
|
the user's login and token
|
||||||
|
'''
|
||||||
|
|
||||||
|
if os.path.isfile(credentials_file_location):
|
||||||
|
try:
|
||||||
|
with open(credentials_file_location, 'r') as metadata_file:
|
||||||
|
login = metadata_file.readline().strip()
|
||||||
|
token = metadata_file.readline().strip()
|
||||||
|
metadata_file.close()
|
||||||
|
except:
|
||||||
|
login, token = basic_prompt()
|
||||||
|
else:
|
||||||
|
login, token = basic_prompt()
|
||||||
|
return login, token
|
||||||
|
|
||||||
|
|
||||||
|
def basic_prompt():
|
||||||
|
'''
|
||||||
|
Prompt the user for login credentials.
|
||||||
|
Returns:
|
||||||
|
the user's login and token
|
||||||
|
'''
|
||||||
|
login = input('User Name (e-mail address): ')
|
||||||
|
token = input('Submission Token (from the assignment page): ')
|
||||||
|
return login, token
|
||||||
|
|
||||||
|
|
||||||
|
def submit_solution(assignment_key, email_address, token, results):
|
||||||
|
'''
|
||||||
|
Sends the student's submission to Coursera for grading via the submission
|
||||||
|
API.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
assignment_key: Coursera's assignment key
|
||||||
|
email_address: the student's email
|
||||||
|
token: the student's assignment token
|
||||||
|
results: a dictionary of results in Cousera's format
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the https response code and a feedback message
|
||||||
|
'''
|
||||||
|
|
||||||
|
print('\n== Connecting to Coursera ...')
|
||||||
|
print('Submitting %d of %d parts' %
|
||||||
|
(sum(['output' in v for k,v in results.items()]), len(results)))
|
||||||
|
|
||||||
|
# build json datastructure
|
||||||
|
parts = {}
|
||||||
|
submission = {
|
||||||
|
'assignmentKey': assignment_key,
|
||||||
|
'submitterEmail': email_address,
|
||||||
|
'secret': token,
|
||||||
|
'parts': results
|
||||||
|
}
|
||||||
|
|
||||||
|
# send submission
|
||||||
|
req = Request(submitt_url)
|
||||||
|
req.add_header('Cache-Control', 'no-cache')
|
||||||
|
req.add_header('Content-type', 'application/json')
|
||||||
|
|
||||||
|
try:
|
||||||
|
res = urlopen(req, json.dumps(submission).encode('utf8'))
|
||||||
|
except HTTPError as e:
|
||||||
|
responce = json.loads(e.read().decode('utf8'))
|
||||||
|
|
||||||
|
if 'details' in responce and responce['details'] != None and \
|
||||||
|
'learnerMessage' in responce['details']:
|
||||||
|
return e.code, responce['details']['learnerMessage']
|
||||||
|
else:
|
||||||
|
return e.code, 'Unexpected response code, please contact the ' \
|
||||||
|
'course staff.\nDetails: ' + responce['message']
|
||||||
|
|
||||||
|
code = res.code
|
||||||
|
responce = json.loads(res.read().decode('utf8'))
|
||||||
|
|
||||||
|
if code >= 200 and code <= 299:
|
||||||
|
return code, 'Your submission has been accepted and will be ' \
|
||||||
|
'graded shortly.'
|
||||||
|
|
||||||
|
return code, 'Unexpected response code, please contact the '\
|
||||||
|
'course staff.\nDetails: ' + responce
|
||||||
|
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
'''
|
||||||
|
1) Reads a metadata file to customize the submission process to
|
||||||
|
a particular assignment.
|
||||||
|
2) The compute the student's answers to the assignment parts.
|
||||||
|
3) Submits the student's answers for grading.
|
||||||
|
|
||||||
|
Provides the an option for saving the submissions locally. This is very
|
||||||
|
helpful when testing the assignment graders.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
args: CLI arguments from an argparse parser
|
||||||
|
'''
|
||||||
|
|
||||||
|
# needed so that output can import from the cwd
|
||||||
|
sys.path.append(os.getcwd())
|
||||||
|
|
||||||
|
if args.metadata is None:
|
||||||
|
metadata = load_metadata()
|
||||||
|
else:
|
||||||
|
print('Overriding metadata file with: '+args.metadata)
|
||||||
|
metadata = load_metadata(args.metadata)
|
||||||
|
|
||||||
|
print('==\n== '+metadata.name+' Solution Submission \n==')
|
||||||
|
|
||||||
|
# compute dialog
|
||||||
|
results = compute(metadata, args.override)
|
||||||
|
|
||||||
|
if sum(['output' in v for k,v in results.items()]) <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
# store submissions if requested
|
||||||
|
if args.record_submission == True:
|
||||||
|
print('Recording submission as files')
|
||||||
|
for sid, submission in results.items():
|
||||||
|
if 'output' in submission:
|
||||||
|
directory = '_'+sid
|
||||||
|
if not os.path.exists(directory):
|
||||||
|
os.makedirs(directory)
|
||||||
|
|
||||||
|
submission_file_name = directory+'/submission.sub'
|
||||||
|
print(' writting submission file: '+submission_file_name)
|
||||||
|
with open(submission_file_name,'w') as submission_file:
|
||||||
|
submission_file.write(submission['output'])
|
||||||
|
submission_file.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
# submit dialog
|
||||||
|
if args.credentials is None:
|
||||||
|
login_dialog(metadata.assignment_key, results)
|
||||||
|
else:
|
||||||
|
print('Overriding credentials file with: '+args.credentials)
|
||||||
|
login_dialog(metadata.assignment_key, results, args.credentials)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
def build_parser():
|
||||||
|
'''
|
||||||
|
Builds an argument parser for the CLI
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
parser: an argparse parser
|
||||||
|
'''
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='''The submission script for Discrete Optimization
|
||||||
|
assignments on the Coursera Platform.''',
|
||||||
|
epilog='''Please file bugs on github at:
|
||||||
|
https://github.com/discreteoptimization/assignment/issues. If you
|
||||||
|
would like to contribute to this tool's development, check it out at:
|
||||||
|
https://github.com/discreteoptimization/assignment'''
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument('-v', '--version', action='version',
|
||||||
|
version='%(prog)s '+version)
|
||||||
|
|
||||||
|
parser.add_argument('-o', '--override',
|
||||||
|
help='overrides the python source file specified in the \'_coursera\' file')
|
||||||
|
|
||||||
|
parser.add_argument('-m', '--metadata',
|
||||||
|
help='overrides the \'_coursera\' metadata file')
|
||||||
|
|
||||||
|
parser.add_argument('-c', '--credentials',
|
||||||
|
help='overrides the \'_credentials\' credentials file')
|
||||||
|
|
||||||
|
parser.add_argument('-rs', '--record_submission',
|
||||||
|
help='records the submission(s) as files', action='store_true')
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = build_parser()
|
||||||
|
main(parser.parse_args())
|
||||||
|
|
||||||
8
discrete_optimization.sublime-project
Normal file
8
discrete_optimization.sublime-project
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"folders":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
91
knapsack/Solver.java
Normal file
91
knapsack/Solver.java
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class <code>Solver</code> is an implementation of a greedy algorithm to solve the knapsack problem.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Solver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main class
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
solve(args);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the instance, solve it, and print the solution in the standard output
|
||||||
|
*/
|
||||||
|
public static void solve(String[] args) throws IOException {
|
||||||
|
String fileName = null;
|
||||||
|
|
||||||
|
// get the temp file name
|
||||||
|
for(String arg : args){
|
||||||
|
if(arg.startsWith("-file=")){
|
||||||
|
fileName = arg.substring(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(fileName == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// read the lines out of the file
|
||||||
|
List<String> lines = new ArrayList<String>();
|
||||||
|
|
||||||
|
BufferedReader input = new BufferedReader(new FileReader(fileName));
|
||||||
|
try {
|
||||||
|
String line = null;
|
||||||
|
while (( line = input.readLine()) != null){
|
||||||
|
lines.add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// parse the data in the file
|
||||||
|
String[] firstLine = lines.get(0).split("\\s+");
|
||||||
|
int items = Integer.parseInt(firstLine[0]);
|
||||||
|
int capacity = Integer.parseInt(firstLine[1]);
|
||||||
|
|
||||||
|
int[] values = new int[items];
|
||||||
|
int[] weights = new int[items];
|
||||||
|
|
||||||
|
for(int i=1; i < items+1; i++){
|
||||||
|
String line = lines.get(i);
|
||||||
|
String[] parts = line.split("\\s+");
|
||||||
|
|
||||||
|
values[i-1] = Integer.parseInt(parts[0]);
|
||||||
|
weights[i-1] = Integer.parseInt(parts[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// a trivial greedy algorithm for filling the knapsack
|
||||||
|
// it takes items in-order until the knapsack is full
|
||||||
|
int value = 0;
|
||||||
|
int weight = 0;
|
||||||
|
int[] taken = new int[items];
|
||||||
|
|
||||||
|
for(int i=0; i < items; i++){
|
||||||
|
if(weight + weights[i] <= capacity){
|
||||||
|
taken[i] = 1;
|
||||||
|
value += values[i];
|
||||||
|
weight += weights[i];
|
||||||
|
} else {
|
||||||
|
taken[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare the solution in the specified output format
|
||||||
|
System.out.println(value+" 0");
|
||||||
|
for(int i=0; i < items; i++){
|
||||||
|
System.out.print(taken[i]+" ");
|
||||||
|
}
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
}
|
||||||
8
knapsack/_coursera
Normal file
8
knapsack/_coursera
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
_le-pVv_EeasJA5dVmWj2w
|
||||||
|
Knapsack
|
||||||
|
awPVV, ./data/ks_30_0, solver.py, Knapsack Problem 1
|
||||||
|
hHYWS, ./data/ks_50_0, solver.py, Knapsack Problem 2
|
||||||
|
JwWnx, ./data/ks_200_0, solver.py, Knapsack Problem 3
|
||||||
|
Z2tMt, ./data/ks_400_0, solver.py, Knapsack Problem 4
|
||||||
|
PUIxa, ./data/ks_1000_0, solver.py, Knapsack Problem 5
|
||||||
|
AKXWc, ./data/ks_10000_0, solver.py, Knapsack Problem 6
|
||||||
10001
knapsack/data/ks_10000_0
Normal file
10001
knapsack/data/ks_10000_0
Normal file
File diff suppressed because it is too large
Load Diff
1001
knapsack/data/ks_1000_0
Normal file
1001
knapsack/data/ks_1000_0
Normal file
File diff suppressed because it is too large
Load Diff
101
knapsack/data/ks_100_0
Normal file
101
knapsack/data/ks_100_0
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
100 100000
|
||||||
|
90000 90001
|
||||||
|
89750 89751
|
||||||
|
10001 10002
|
||||||
|
89500 89501
|
||||||
|
10252 10254
|
||||||
|
89250 89251
|
||||||
|
10503 10506
|
||||||
|
89000 89001
|
||||||
|
10754 10758
|
||||||
|
88750 88751
|
||||||
|
11005 11010
|
||||||
|
88500 88501
|
||||||
|
11256 11262
|
||||||
|
88250 88251
|
||||||
|
11507 11514
|
||||||
|
88000 88001
|
||||||
|
11758 11766
|
||||||
|
87750 87751
|
||||||
|
12009 12018
|
||||||
|
87500 87501
|
||||||
|
12260 12270
|
||||||
|
87250 87251
|
||||||
|
12511 12522
|
||||||
|
87000 87001
|
||||||
|
12762 12774
|
||||||
|
86750 86751
|
||||||
|
13013 13026
|
||||||
|
86500 86501
|
||||||
|
13264 13278
|
||||||
|
86250 86251
|
||||||
|
13515 13530
|
||||||
|
86000 86001
|
||||||
|
13766 13782
|
||||||
|
85750 85751
|
||||||
|
14017 14034
|
||||||
|
85500 85501
|
||||||
|
14268 14286
|
||||||
|
85250 85251
|
||||||
|
14519 14538
|
||||||
|
85000 85001
|
||||||
|
14770 14790
|
||||||
|
84750 84751
|
||||||
|
15021 15042
|
||||||
|
84500 84501
|
||||||
|
15272 15294
|
||||||
|
84250 84251
|
||||||
|
15523 15546
|
||||||
|
84000 84001
|
||||||
|
15774 15798
|
||||||
|
83750 83751
|
||||||
|
16025 16050
|
||||||
|
83500 83501
|
||||||
|
16276 16302
|
||||||
|
83250 83251
|
||||||
|
16527 16554
|
||||||
|
83000 83001
|
||||||
|
16778 16806
|
||||||
|
82750 82751
|
||||||
|
17029 17058
|
||||||
|
82500 82501
|
||||||
|
17280 17310
|
||||||
|
82250 82251
|
||||||
|
17531 17562
|
||||||
|
82000 82001
|
||||||
|
17782 17814
|
||||||
|
81750 81751
|
||||||
|
18033 18066
|
||||||
|
81500 81501
|
||||||
|
18284 18318
|
||||||
|
81250 81251
|
||||||
|
18535 18570
|
||||||
|
81000 81001
|
||||||
|
18786 18822
|
||||||
|
80750 80751
|
||||||
|
19037 19074
|
||||||
|
80500 80501
|
||||||
|
19288 19326
|
||||||
|
80250 80251
|
||||||
|
19539 19578
|
||||||
|
80000 80001
|
||||||
|
19790 19830
|
||||||
|
79750 79751
|
||||||
|
20041 20082
|
||||||
|
79500 79501
|
||||||
|
20292 20334
|
||||||
|
79250 79251
|
||||||
|
20543 20586
|
||||||
|
79000 79001
|
||||||
|
20794 20838
|
||||||
|
78750 78751
|
||||||
|
21045 21090
|
||||||
|
78500 78501
|
||||||
|
21296 21342
|
||||||
|
78250 78251
|
||||||
|
21547 21594
|
||||||
|
78000 78001
|
||||||
|
21798 21846
|
||||||
|
77750 77751
|
||||||
|
22049 22098
|
||||||
|
77500 77501
|
||||||
101
knapsack/data/ks_100_1
Normal file
101
knapsack/data/ks_100_1
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
100 3190802
|
||||||
|
1491 3882
|
||||||
|
399 1298
|
||||||
|
77 654
|
||||||
|
969 2638
|
||||||
|
8485 20670
|
||||||
|
55 610
|
||||||
|
1904 4908
|
||||||
|
703 2106
|
||||||
|
657 2014
|
||||||
|
932 2564
|
||||||
|
1201 3302
|
||||||
|
1697 4494
|
||||||
|
462 1424
|
||||||
|
1201 3302
|
||||||
|
111632 267364
|
||||||
|
9044 21988
|
||||||
|
147380 352660
|
||||||
|
31852 76604
|
||||||
|
9044 21988
|
||||||
|
9300 22700
|
||||||
|
8660 21020
|
||||||
|
174684 418068
|
||||||
|
19844 47788
|
||||||
|
9044 21988
|
||||||
|
1635 4370
|
||||||
|
62788 150476
|
||||||
|
6932 16964
|
||||||
|
6308 15516
|
||||||
|
50 600
|
||||||
|
4600 11300
|
||||||
|
565204 1351508
|
||||||
|
7463 18226
|
||||||
|
2988 7476
|
||||||
|
9044 21988
|
||||||
|
9044 21988
|
||||||
|
4040 9980
|
||||||
|
137732 329764
|
||||||
|
7150 17400
|
||||||
|
9300 22700
|
||||||
|
177 854
|
||||||
|
372 1244
|
||||||
|
499 1498
|
||||||
|
15108 36516
|
||||||
|
11108 26916
|
||||||
|
2468 6236
|
||||||
|
1133 3166
|
||||||
|
1490 3880
|
||||||
|
865 2430
|
||||||
|
2468 6236
|
||||||
|
2468 6236
|
||||||
|
5974 14648
|
||||||
|
5972 14644
|
||||||
|
9532 23164
|
||||||
|
1872 4844
|
||||||
|
3964 9828
|
||||||
|
2799 7098
|
||||||
|
527708 1261916
|
||||||
|
7212 17724
|
||||||
|
3002 7504
|
||||||
|
21004 50708
|
||||||
|
47728 114556
|
||||||
|
565204 1351508
|
||||||
|
100600 240900
|
||||||
|
118920 284740
|
||||||
|
2822 7144
|
||||||
|
612 1924
|
||||||
|
6324 15548
|
||||||
|
9508 23116
|
||||||
|
9268 22636
|
||||||
|
11636 28172
|
||||||
|
210708 504116
|
||||||
|
2176944 5204588
|
||||||
|
930 2560
|
||||||
|
4481 11062
|
||||||
|
50 600
|
||||||
|
112 724
|
||||||
|
14434 34968
|
||||||
|
0 500
|
||||||
|
248 996
|
||||||
|
48 596
|
||||||
|
820 2340
|
||||||
|
278 1056
|
||||||
|
643 1986
|
||||||
|
1413 3726
|
||||||
|
1408 3716
|
||||||
|
0 500
|
||||||
|
2581 6662
|
||||||
|
287 1074
|
||||||
|
2040 5180
|
||||||
|
289 1078
|
||||||
|
1380 3660
|
||||||
|
372 1244
|
||||||
|
0 500
|
||||||
|
472 1444
|
||||||
|
360 1220
|
||||||
|
0 500
|
||||||
|
622 1944
|
||||||
|
3504 8708
|
||||||
|
5924 14548
|
||||||
|
2784 7068
|
||||||
101
knapsack/data/ks_100_2
Normal file
101
knapsack/data/ks_100_2
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
100 10000
|
||||||
|
339 342
|
||||||
|
1629 1514
|
||||||
|
697 696
|
||||||
|
1299 1433
|
||||||
|
1613 1762
|
||||||
|
36 40
|
||||||
|
1737 1635
|
||||||
|
473 442
|
||||||
|
1859 1899
|
||||||
|
2055 1960
|
||||||
|
362 378
|
||||||
|
1104 1177
|
||||||
|
1880 1970
|
||||||
|
1349 1434
|
||||||
|
1545 1691
|
||||||
|
132 139
|
||||||
|
341 371
|
||||||
|
1430 1350
|
||||||
|
1878 1775
|
||||||
|
1870 1980
|
||||||
|
1536 1651
|
||||||
|
818 814
|
||||||
|
289 282
|
||||||
|
1690 1573
|
||||||
|
1437 1587
|
||||||
|
310 302
|
||||||
|
53 56
|
||||||
|
720 726
|
||||||
|
1707 1820
|
||||||
|
258 269
|
||||||
|
1842 1680
|
||||||
|
757 842
|
||||||
|
1642 1730
|
||||||
|
1149 1243
|
||||||
|
1970 1794
|
||||||
|
749 775
|
||||||
|
1904 1810
|
||||||
|
2 3
|
||||||
|
967 970
|
||||||
|
1310 1261
|
||||||
|
1004 997
|
||||||
|
1295 1192
|
||||||
|
1056 1036
|
||||||
|
51 52
|
||||||
|
1320 1453
|
||||||
|
1580 1673
|
||||||
|
480 440
|
||||||
|
604 624
|
||||||
|
1766 1813
|
||||||
|
1198 1326
|
||||||
|
1762 1637
|
||||||
|
2046 1902
|
||||||
|
315 323
|
||||||
|
714 746
|
||||||
|
434 471
|
||||||
|
1461 1366
|
||||||
|
1652 1511
|
||||||
|
1876 1785
|
||||||
|
906 1002
|
||||||
|
1483 1560
|
||||||
|
1355 1403
|
||||||
|
510 513
|
||||||
|
2114 1958
|
||||||
|
1479 1505
|
||||||
|
1618 1538
|
||||||
|
1472 1378
|
||||||
|
310 315
|
||||||
|
1478 1493
|
||||||
|
970 1066
|
||||||
|
43 40
|
||||||
|
1231 1172
|
||||||
|
1792 1972
|
||||||
|
870 956
|
||||||
|
1484 1541
|
||||||
|
1049 1014
|
||||||
|
56 55
|
||||||
|
814 793
|
||||||
|
978 985
|
||||||
|
1215 1311
|
||||||
|
720 737
|
||||||
|
210 204
|
||||||
|
460 492
|
||||||
|
1798 1961
|
||||||
|
1944 1952
|
||||||
|
208 204
|
||||||
|
1836 1872
|
||||||
|
882 806
|
||||||
|
239 234
|
||||||
|
141 136
|
||||||
|
49 49
|
||||||
|
1352 1363
|
||||||
|
915 883
|
||||||
|
1318 1259
|
||||||
|
72 70
|
||||||
|
937 886
|
||||||
|
1783 1843
|
||||||
|
1253 1319
|
||||||
|
1268 1375
|
||||||
|
1144 1234
|
||||||
|
878 818
|
||||||
107
knapsack/data/ks_106_0
Normal file
107
knapsack/data/ks_106_0
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
106 106925262
|
||||||
|
45276 45276
|
||||||
|
90552 90552
|
||||||
|
181104 181104
|
||||||
|
362208 362208
|
||||||
|
724416 724416
|
||||||
|
1448832 1448832
|
||||||
|
2897664 2897664
|
||||||
|
5795328 5795328
|
||||||
|
11590656 11590656
|
||||||
|
23181312 23181312
|
||||||
|
46362624 46362624
|
||||||
|
92725248 92725248
|
||||||
|
70778 70778
|
||||||
|
141556 141556
|
||||||
|
283112 283112
|
||||||
|
566224 566224
|
||||||
|
1132448 1132448
|
||||||
|
2264896 2264896
|
||||||
|
4529792 4529792
|
||||||
|
9059584 9059584
|
||||||
|
18119168 18119168
|
||||||
|
36238336 36238336
|
||||||
|
72476672 72476672
|
||||||
|
86911 86911
|
||||||
|
173822 173822
|
||||||
|
347644 347644
|
||||||
|
695288 695288
|
||||||
|
1390576 1390576
|
||||||
|
2781152 2781152
|
||||||
|
5562304 5562304
|
||||||
|
11124608 11124608
|
||||||
|
22249216 22249216
|
||||||
|
44498432 44498432
|
||||||
|
88996864 88996864
|
||||||
|
92634 92634
|
||||||
|
185268 185268
|
||||||
|
370536 370536
|
||||||
|
741072 741072
|
||||||
|
1482144 1482144
|
||||||
|
2964288 2964288
|
||||||
|
5928576 5928576
|
||||||
|
11857152 11857152
|
||||||
|
23714304 23714304
|
||||||
|
47428608 47428608
|
||||||
|
94857216 94857216
|
||||||
|
97839 97839
|
||||||
|
195678 195678
|
||||||
|
391356 391356
|
||||||
|
782712 782712
|
||||||
|
1565424 1565424
|
||||||
|
3130848 3130848
|
||||||
|
6261696 6261696
|
||||||
|
12523392 12523392
|
||||||
|
25046784 25046784
|
||||||
|
50093568 50093568
|
||||||
|
100187136 100187136
|
||||||
|
125941 125941
|
||||||
|
251882 251882
|
||||||
|
503764 503764
|
||||||
|
1007528 1007528
|
||||||
|
2015056 2015056
|
||||||
|
4030112 4030112
|
||||||
|
8060224 8060224
|
||||||
|
16120448 16120448
|
||||||
|
32240896 32240896
|
||||||
|
64481792 64481792
|
||||||
|
134269 134269
|
||||||
|
268538 268538
|
||||||
|
537076 537076
|
||||||
|
1074152 1074152
|
||||||
|
2148304 2148304
|
||||||
|
4296608 4296608
|
||||||
|
8593216 8593216
|
||||||
|
17186432 17186432
|
||||||
|
34372864 34372864
|
||||||
|
68745728 68745728
|
||||||
|
141033 141033
|
||||||
|
282066 282066
|
||||||
|
564132 564132
|
||||||
|
1128264 1128264
|
||||||
|
2256528 2256528
|
||||||
|
4513056 4513056
|
||||||
|
9026112 9026112
|
||||||
|
18052224 18052224
|
||||||
|
36104448 36104448
|
||||||
|
72208896 72208896
|
||||||
|
147279 147279
|
||||||
|
294558 294558
|
||||||
|
589116 589116
|
||||||
|
1178232 1178232
|
||||||
|
2356464 2356464
|
||||||
|
4712928 4712928
|
||||||
|
9425856 9425856
|
||||||
|
18851712 18851712
|
||||||
|
37703424 37703424
|
||||||
|
75406848 75406848
|
||||||
|
153525 153525
|
||||||
|
307050 307050
|
||||||
|
614100 614100
|
||||||
|
1228200 1228200
|
||||||
|
2456400 2456400
|
||||||
|
4912800 4912800
|
||||||
|
9825600 9825600
|
||||||
|
19651200 19651200
|
||||||
|
39302400 39302400
|
||||||
|
78604800 78604800
|
||||||
20
knapsack/data/ks_19_0
Normal file
20
knapsack/data/ks_19_0
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
19 31181
|
||||||
|
1945 4990
|
||||||
|
321 1142
|
||||||
|
2945 7390
|
||||||
|
4136 10372
|
||||||
|
1107 3114
|
||||||
|
1022 2744
|
||||||
|
1101 3102
|
||||||
|
2890 7280
|
||||||
|
962 2624
|
||||||
|
1060 3020
|
||||||
|
805 2310
|
||||||
|
689 2078
|
||||||
|
1513 3926
|
||||||
|
3878 9656
|
||||||
|
13504 32708
|
||||||
|
1865 4830
|
||||||
|
667 2034
|
||||||
|
1833 4766
|
||||||
|
16553 40006
|
||||||
201
knapsack/data/ks_200_0
Normal file
201
knapsack/data/ks_200_0
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
200 100000
|
||||||
|
90001 90000
|
||||||
|
89751 89750
|
||||||
|
10002 10001
|
||||||
|
89501 89500
|
||||||
|
10254 10252
|
||||||
|
89251 89250
|
||||||
|
10506 10503
|
||||||
|
89001 89000
|
||||||
|
10758 10754
|
||||||
|
88751 88750
|
||||||
|
11010 11005
|
||||||
|
88501 88500
|
||||||
|
11262 11256
|
||||||
|
88251 88250
|
||||||
|
11514 11507
|
||||||
|
88001 88000
|
||||||
|
11766 11758
|
||||||
|
87751 87750
|
||||||
|
12018 12009
|
||||||
|
87501 87500
|
||||||
|
12270 12260
|
||||||
|
87251 87250
|
||||||
|
12522 12511
|
||||||
|
87001 87000
|
||||||
|
12774 12762
|
||||||
|
86751 86750
|
||||||
|
13026 13013
|
||||||
|
86501 86500
|
||||||
|
13278 13264
|
||||||
|
86251 86250
|
||||||
|
13530 13515
|
||||||
|
86001 86000
|
||||||
|
13782 13766
|
||||||
|
85751 85750
|
||||||
|
14034 14017
|
||||||
|
85501 85500
|
||||||
|
14286 14268
|
||||||
|
85251 85250
|
||||||
|
14538 14519
|
||||||
|
85001 85000
|
||||||
|
14790 14770
|
||||||
|
84751 84750
|
||||||
|
15042 15021
|
||||||
|
84501 84500
|
||||||
|
15294 15272
|
||||||
|
84251 84250
|
||||||
|
15546 15523
|
||||||
|
84001 84000
|
||||||
|
15798 15774
|
||||||
|
83751 83750
|
||||||
|
16050 16025
|
||||||
|
83501 83500
|
||||||
|
16302 16276
|
||||||
|
83251 83250
|
||||||
|
16554 16527
|
||||||
|
83001 83000
|
||||||
|
16806 16778
|
||||||
|
82751 82750
|
||||||
|
17058 17029
|
||||||
|
82501 82500
|
||||||
|
17310 17280
|
||||||
|
82251 82250
|
||||||
|
17562 17531
|
||||||
|
82001 82000
|
||||||
|
17814 17782
|
||||||
|
81751 81750
|
||||||
|
18066 18033
|
||||||
|
81501 81500
|
||||||
|
18318 18284
|
||||||
|
81251 81250
|
||||||
|
18570 18535
|
||||||
|
81001 81000
|
||||||
|
18822 18786
|
||||||
|
80751 80750
|
||||||
|
19074 19037
|
||||||
|
80501 80500
|
||||||
|
19326 19288
|
||||||
|
80251 80250
|
||||||
|
19578 19539
|
||||||
|
80001 80000
|
||||||
|
19830 19790
|
||||||
|
79751 79750
|
||||||
|
20082 20041
|
||||||
|
79501 79500
|
||||||
|
20334 20292
|
||||||
|
79251 79250
|
||||||
|
20586 20543
|
||||||
|
79001 79000
|
||||||
|
20838 20794
|
||||||
|
78751 78750
|
||||||
|
21090 21045
|
||||||
|
78501 78500
|
||||||
|
21342 21296
|
||||||
|
78251 78250
|
||||||
|
21594 21547
|
||||||
|
78001 78000
|
||||||
|
21846 21798
|
||||||
|
77751 77750
|
||||||
|
22098 22049
|
||||||
|
77501 77500
|
||||||
|
22350 22300
|
||||||
|
77251 77250
|
||||||
|
22602 22551
|
||||||
|
77001 77000
|
||||||
|
22854 22802
|
||||||
|
76751 76750
|
||||||
|
23106 23053
|
||||||
|
76501 76500
|
||||||
|
23358 23304
|
||||||
|
76251 76250
|
||||||
|
23610 23555
|
||||||
|
76001 76000
|
||||||
|
23862 23806
|
||||||
|
75751 75750
|
||||||
|
24114 24057
|
||||||
|
75501 75500
|
||||||
|
24366 24308
|
||||||
|
75251 75250
|
||||||
|
24618 24559
|
||||||
|
75001 75000
|
||||||
|
24870 24810
|
||||||
|
74751 74750
|
||||||
|
25122 25061
|
||||||
|
74501 74500
|
||||||
|
25374 25312
|
||||||
|
74251 74250
|
||||||
|
25626 25563
|
||||||
|
74001 74000
|
||||||
|
25878 25814
|
||||||
|
73751 73750
|
||||||
|
26130 26065
|
||||||
|
73501 73500
|
||||||
|
26382 26316
|
||||||
|
73251 73250
|
||||||
|
26634 26567
|
||||||
|
73001 73000
|
||||||
|
26886 26818
|
||||||
|
72751 72750
|
||||||
|
27138 27069
|
||||||
|
72501 72500
|
||||||
|
27390 27320
|
||||||
|
72251 72250
|
||||||
|
27642 27571
|
||||||
|
72001 72000
|
||||||
|
27894 27822
|
||||||
|
71751 71750
|
||||||
|
28146 28073
|
||||||
|
71501 71500
|
||||||
|
28398 28324
|
||||||
|
71251 71250
|
||||||
|
28650 28575
|
||||||
|
71001 71000
|
||||||
|
28902 28826
|
||||||
|
70751 70750
|
||||||
|
29154 29077
|
||||||
|
70501 70500
|
||||||
|
29406 29328
|
||||||
|
70251 70250
|
||||||
|
29658 29579
|
||||||
|
70001 70000
|
||||||
|
29910 29830
|
||||||
|
69751 69750
|
||||||
|
30162 30081
|
||||||
|
69501 69500
|
||||||
|
30414 30332
|
||||||
|
69251 69250
|
||||||
|
30666 30583
|
||||||
|
69001 69000
|
||||||
|
30918 30834
|
||||||
|
68751 68750
|
||||||
|
31170 31085
|
||||||
|
68501 68500
|
||||||
|
31422 31336
|
||||||
|
68251 68250
|
||||||
|
31674 31587
|
||||||
|
68001 68000
|
||||||
|
31926 31838
|
||||||
|
67751 67750
|
||||||
|
32178 32089
|
||||||
|
67501 67500
|
||||||
|
32430 32340
|
||||||
|
67251 67250
|
||||||
|
32682 32591
|
||||||
|
67001 67000
|
||||||
|
32934 32842
|
||||||
|
66751 66750
|
||||||
|
33186 33093
|
||||||
|
66501 66500
|
||||||
|
33438 33344
|
||||||
|
66251 66250
|
||||||
|
33690 33595
|
||||||
|
66001 66000
|
||||||
|
33942 33846
|
||||||
|
65751 65750
|
||||||
|
34194 34097
|
||||||
|
65501 65500
|
||||||
|
34446 34348
|
||||||
|
65251 65250
|
||||||
|
34698 34599
|
||||||
|
68451 68450
|
||||||
201
knapsack/data/ks_200_1
Normal file
201
knapsack/data/ks_200_1
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
200 2640230
|
||||||
|
31860 76620
|
||||||
|
11884 28868
|
||||||
|
10492 25484
|
||||||
|
901 2502
|
||||||
|
43580 104660
|
||||||
|
9004 21908
|
||||||
|
6700 16500
|
||||||
|
29940 71980
|
||||||
|
7484 18268
|
||||||
|
5932 14564
|
||||||
|
7900 19300
|
||||||
|
6564 16028
|
||||||
|
6596 16092
|
||||||
|
8172 19844
|
||||||
|
5324 13148
|
||||||
|
8436 20572
|
||||||
|
7332 17964
|
||||||
|
6972 17044
|
||||||
|
7668 18636
|
||||||
|
6524 15948
|
||||||
|
6244 15388
|
||||||
|
635 1970
|
||||||
|
5396 13292
|
||||||
|
13596 32892
|
||||||
|
51188 122676
|
||||||
|
13684 33068
|
||||||
|
8596 20892
|
||||||
|
156840 375380
|
||||||
|
7900 19300
|
||||||
|
6460 15820
|
||||||
|
14132 34164
|
||||||
|
4980 12260
|
||||||
|
5216 12932
|
||||||
|
6276 15452
|
||||||
|
701 2102
|
||||||
|
3084 7868
|
||||||
|
6924 16948
|
||||||
|
5500 13500
|
||||||
|
3148 7996
|
||||||
|
47844 114788
|
||||||
|
226844 542788
|
||||||
|
25748 61996
|
||||||
|
7012 17124
|
||||||
|
3440 8580
|
||||||
|
15580 37660
|
||||||
|
314 1128
|
||||||
|
2852 7204
|
||||||
|
15500 37500
|
||||||
|
9348 22796
|
||||||
|
17768 42836
|
||||||
|
16396 39692
|
||||||
|
16540 39980
|
||||||
|
395124 944948
|
||||||
|
10196 24692
|
||||||
|
6652 16204
|
||||||
|
4848 11996
|
||||||
|
74372 178244
|
||||||
|
4556 11212
|
||||||
|
4900 12100
|
||||||
|
3508 8716
|
||||||
|
3820 9540
|
||||||
|
5460 13420
|
||||||
|
16564 40028
|
||||||
|
3896 9692
|
||||||
|
3832 9564
|
||||||
|
9012 21924
|
||||||
|
4428 10956
|
||||||
|
57796 138492
|
||||||
|
12052 29204
|
||||||
|
7052 17204
|
||||||
|
85864 205628
|
||||||
|
5068 12436
|
||||||
|
10484 25468
|
||||||
|
4516 11132
|
||||||
|
3620 9140
|
||||||
|
18052 43604
|
||||||
|
21 542
|
||||||
|
15804 38108
|
||||||
|
19020 45940
|
||||||
|
170844 408788
|
||||||
|
3732 9364
|
||||||
|
2920 7340
|
||||||
|
4120 10340
|
||||||
|
6828 16756
|
||||||
|
26252 63204
|
||||||
|
11676 28252
|
||||||
|
19916 47932
|
||||||
|
65488 156876
|
||||||
|
7172 17644
|
||||||
|
3772 9444
|
||||||
|
132868 318036
|
||||||
|
8332 20364
|
||||||
|
5308 13116
|
||||||
|
3780 9460
|
||||||
|
5208 12916
|
||||||
|
56788 136076
|
||||||
|
7172 17644
|
||||||
|
7868 19236
|
||||||
|
31412 75524
|
||||||
|
9252 22604
|
||||||
|
12276 29652
|
||||||
|
3712 9324
|
||||||
|
4516 11132
|
||||||
|
105876 253452
|
||||||
|
20084 48468
|
||||||
|
11492 27884
|
||||||
|
49092 117684
|
||||||
|
83452 199804
|
||||||
|
71372 171044
|
||||||
|
66572 159644
|
||||||
|
25268 60836
|
||||||
|
64292 154084
|
||||||
|
21228 51156
|
||||||
|
16812 40524
|
||||||
|
19260 46420
|
||||||
|
7740 18980
|
||||||
|
5632 13964
|
||||||
|
3256 8212
|
||||||
|
15580 37660
|
||||||
|
4824 11948
|
||||||
|
59700 143100
|
||||||
|
14500 35100
|
||||||
|
7208 17716
|
||||||
|
6028 14756
|
||||||
|
75716 181332
|
||||||
|
22364 53828
|
||||||
|
7636 18572
|
||||||
|
6444 15788
|
||||||
|
5192 12884
|
||||||
|
7388 18076
|
||||||
|
33156 79612
|
||||||
|
3032 7564
|
||||||
|
6628 16156
|
||||||
|
7036 17172
|
||||||
|
3200 8100
|
||||||
|
7300 17900
|
||||||
|
4452 11004
|
||||||
|
26364 63428
|
||||||
|
14036 33972
|
||||||
|
16932 40964
|
||||||
|
5788 14276
|
||||||
|
70476 168852
|
||||||
|
4552 11204
|
||||||
|
33980 81660
|
||||||
|
19300 46500
|
||||||
|
39628 95156
|
||||||
|
4484 11068
|
||||||
|
55044 131988
|
||||||
|
574 1848
|
||||||
|
29644 71188
|
||||||
|
9460 23020
|
||||||
|
106284 254468
|
||||||
|
304 1108
|
||||||
|
3580 8860
|
||||||
|
6308 15516
|
||||||
|
10492 25484
|
||||||
|
12820 31140
|
||||||
|
14436 34972
|
||||||
|
5044 12388
|
||||||
|
1155 3210
|
||||||
|
12468 30236
|
||||||
|
4380 10860
|
||||||
|
9876 24052
|
||||||
|
8752 21404
|
||||||
|
8676 21052
|
||||||
|
42848 102796
|
||||||
|
22844 54988
|
||||||
|
6244 15388
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
387480 926660
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
15996 38692
|
||||||
|
8372 20444
|
||||||
|
65488 156876
|
||||||
|
304 1108
|
||||||
|
4756 11812
|
||||||
|
5012 12324
|
||||||
|
304 1108
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
304 1108
|
||||||
|
1208 3316
|
||||||
|
47728 114556
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
301
knapsack/data/ks_300_0
Normal file
301
knapsack/data/ks_300_0
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
300 4040184
|
||||||
|
31860 76620
|
||||||
|
11884 28868
|
||||||
|
10492 25484
|
||||||
|
901 2502
|
||||||
|
43580 104660
|
||||||
|
9004 21908
|
||||||
|
6700 16500
|
||||||
|
29940 71980
|
||||||
|
7484 18268
|
||||||
|
5932 14564
|
||||||
|
7900 19300
|
||||||
|
6564 16028
|
||||||
|
6596 16092
|
||||||
|
8172 19844
|
||||||
|
5324 13148
|
||||||
|
8436 20572
|
||||||
|
7332 17964
|
||||||
|
6972 17044
|
||||||
|
7668 18636
|
||||||
|
6524 15948
|
||||||
|
6244 15388
|
||||||
|
635 1970
|
||||||
|
5396 13292
|
||||||
|
13596 32892
|
||||||
|
51188 122676
|
||||||
|
13684 33068
|
||||||
|
8596 20892
|
||||||
|
156840 375380
|
||||||
|
7900 19300
|
||||||
|
6460 15820
|
||||||
|
14132 34164
|
||||||
|
4980 12260
|
||||||
|
5216 12932
|
||||||
|
6276 15452
|
||||||
|
701 2102
|
||||||
|
3084 7868
|
||||||
|
6924 16948
|
||||||
|
5500 13500
|
||||||
|
3148 7996
|
||||||
|
47844 114788
|
||||||
|
226844 542788
|
||||||
|
25748 61996
|
||||||
|
7012 17124
|
||||||
|
3440 8580
|
||||||
|
15580 37660
|
||||||
|
314 1128
|
||||||
|
2852 7204
|
||||||
|
15500 37500
|
||||||
|
9348 22796
|
||||||
|
17768 42836
|
||||||
|
16396 39692
|
||||||
|
16540 39980
|
||||||
|
395124 944948
|
||||||
|
10196 24692
|
||||||
|
6652 16204
|
||||||
|
4848 11996
|
||||||
|
74372 178244
|
||||||
|
4556 11212
|
||||||
|
4900 12100
|
||||||
|
3508 8716
|
||||||
|
3820 9540
|
||||||
|
5460 13420
|
||||||
|
16564 40028
|
||||||
|
3896 9692
|
||||||
|
3832 9564
|
||||||
|
9012 21924
|
||||||
|
4428 10956
|
||||||
|
57796 138492
|
||||||
|
12052 29204
|
||||||
|
7052 17204
|
||||||
|
85864 205628
|
||||||
|
5068 12436
|
||||||
|
10484 25468
|
||||||
|
4516 11132
|
||||||
|
3620 9140
|
||||||
|
18052 43604
|
||||||
|
21 542
|
||||||
|
15804 38108
|
||||||
|
19020 45940
|
||||||
|
170844 408788
|
||||||
|
3732 9364
|
||||||
|
2920 7340
|
||||||
|
4120 10340
|
||||||
|
6828 16756
|
||||||
|
26252 63204
|
||||||
|
11676 28252
|
||||||
|
19916 47932
|
||||||
|
65488 156876
|
||||||
|
7172 17644
|
||||||
|
3772 9444
|
||||||
|
132868 318036
|
||||||
|
8332 20364
|
||||||
|
5308 13116
|
||||||
|
3780 9460
|
||||||
|
5208 12916
|
||||||
|
56788 136076
|
||||||
|
7172 17644
|
||||||
|
7868 19236
|
||||||
|
31412 75524
|
||||||
|
9252 22604
|
||||||
|
12276 29652
|
||||||
|
3712 9324
|
||||||
|
4516 11132
|
||||||
|
105876 253452
|
||||||
|
20084 48468
|
||||||
|
11492 27884
|
||||||
|
49092 117684
|
||||||
|
83452 199804
|
||||||
|
71372 171044
|
||||||
|
66572 159644
|
||||||
|
25268 60836
|
||||||
|
64292 154084
|
||||||
|
21228 51156
|
||||||
|
16812 40524
|
||||||
|
19260 46420
|
||||||
|
7740 18980
|
||||||
|
5632 13964
|
||||||
|
3256 8212
|
||||||
|
15580 37660
|
||||||
|
4824 11948
|
||||||
|
59700 143100
|
||||||
|
14500 35100
|
||||||
|
7208 17716
|
||||||
|
6028 14756
|
||||||
|
75716 181332
|
||||||
|
22364 53828
|
||||||
|
7636 18572
|
||||||
|
6444 15788
|
||||||
|
5192 12884
|
||||||
|
7388 18076
|
||||||
|
33156 79612
|
||||||
|
3032 7564
|
||||||
|
6628 16156
|
||||||
|
7036 17172
|
||||||
|
3200 8100
|
||||||
|
7300 17900
|
||||||
|
4452 11004
|
||||||
|
26364 63428
|
||||||
|
14036 33972
|
||||||
|
16932 40964
|
||||||
|
5788 14276
|
||||||
|
70476 168852
|
||||||
|
4552 11204
|
||||||
|
33980 81660
|
||||||
|
19300 46500
|
||||||
|
39628 95156
|
||||||
|
4484 11068
|
||||||
|
55044 131988
|
||||||
|
574 1848
|
||||||
|
29644 71188
|
||||||
|
9460 23020
|
||||||
|
106284 254468
|
||||||
|
304 1108
|
||||||
|
3580 8860
|
||||||
|
6308 15516
|
||||||
|
10492 25484
|
||||||
|
12820 31140
|
||||||
|
14436 34972
|
||||||
|
5044 12388
|
||||||
|
1155 3210
|
||||||
|
12468 30236
|
||||||
|
4380 10860
|
||||||
|
9876 24052
|
||||||
|
8752 21404
|
||||||
|
8676 21052
|
||||||
|
42848 102796
|
||||||
|
22844 54988
|
||||||
|
6244 15388
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
387480 926660
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
15996 38692
|
||||||
|
8372 20444
|
||||||
|
65488 156876
|
||||||
|
304 1108
|
||||||
|
4756 11812
|
||||||
|
5012 12324
|
||||||
|
304 1108
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
304 1108
|
||||||
|
1208 3316
|
||||||
|
47728 114556
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
104036 249172
|
||||||
|
5248 12996
|
||||||
|
312 1124
|
||||||
|
24468 58836
|
||||||
|
7716 18932
|
||||||
|
30180 72460
|
||||||
|
4824 11948
|
||||||
|
1120 3140
|
||||||
|
11496 27892
|
||||||
|
4916 12132
|
||||||
|
14428 34956
|
||||||
|
24948 59996
|
||||||
|
41100 98700
|
||||||
|
28692 69084
|
||||||
|
826 2352
|
||||||
|
3073 7846
|
||||||
|
7684 18868
|
||||||
|
5604 13708
|
||||||
|
17188 41476
|
||||||
|
34828 83756
|
||||||
|
7540 18380
|
||||||
|
8004 19508
|
||||||
|
2648 6796
|
||||||
|
5124 12748
|
||||||
|
3096 7892
|
||||||
|
166516 398532
|
||||||
|
13756 33212
|
||||||
|
9980 24260
|
||||||
|
15980 38660
|
||||||
|
9056 22012
|
||||||
|
5052 12404
|
||||||
|
8212 20124
|
||||||
|
11164 27028
|
||||||
|
13036 31572
|
||||||
|
23596 56892
|
||||||
|
2028 5156
|
||||||
|
7584 18468
|
||||||
|
5772 14244
|
||||||
|
4124 10348
|
||||||
|
5368 13236
|
||||||
|
4364 10828
|
||||||
|
5604 13708
|
||||||
|
8500 20700
|
||||||
|
7676 18652
|
||||||
|
8636 20972
|
||||||
|
4588 11276
|
||||||
|
4152 10404
|
||||||
|
4860 12020
|
||||||
|
5484 13468
|
||||||
|
8636 20972
|
||||||
|
5140 12780
|
||||||
|
236380 565460
|
||||||
|
116500 278900
|
||||||
|
36480 87660
|
||||||
|
16968 41036
|
||||||
|
5232 12964
|
||||||
|
13280 32060
|
||||||
|
138032 330364
|
||||||
|
9044 21988
|
||||||
|
22028 53156
|
||||||
|
4632 11564
|
||||||
|
13196 31892
|
||||||
|
65404 156708
|
||||||
|
28940 69580
|
||||||
|
865 2430
|
||||||
|
45988 110276
|
||||||
|
670 2040
|
||||||
|
4820 11940
|
||||||
|
41356 99212
|
||||||
|
39844 95588
|
||||||
|
897 2494
|
||||||
|
4028 9956
|
||||||
|
7924 19348
|
||||||
|
47756 114612
|
||||||
|
47036 112772
|
||||||
|
25908 62316
|
||||||
|
4516 11132
|
||||||
|
29460 70820
|
||||||
|
7964 19428
|
||||||
|
16964 41028
|
||||||
|
22196 53492
|
||||||
|
68140 163380
|
||||||
|
80924 193948
|
||||||
|
63700 152700
|
||||||
|
20860 50220
|
||||||
|
1682 4464
|
||||||
|
16804 40508
|
||||||
|
3195 8090
|
||||||
|
60348 144596
|
||||||
|
1901 4902
|
||||||
|
67468 161636
|
||||||
|
4772 11844
|
||||||
|
11196 27092
|
||||||
|
25836 62172
|
||||||
|
49676 119252
|
||||||
|
6188 15276
|
||||||
|
15588 37676
|
||||||
31
knapsack/data/ks_30_0
Normal file
31
knapsack/data/ks_30_0
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
30 100000
|
||||||
|
90000 90001
|
||||||
|
89750 89751
|
||||||
|
10001 10002
|
||||||
|
89500 89501
|
||||||
|
10252 10254
|
||||||
|
89250 89251
|
||||||
|
10503 10506
|
||||||
|
89000 89001
|
||||||
|
10754 10758
|
||||||
|
88750 88751
|
||||||
|
11005 11010
|
||||||
|
88500 88501
|
||||||
|
11256 11262
|
||||||
|
88250 88251
|
||||||
|
11507 11514
|
||||||
|
88000 88001
|
||||||
|
11758 11766
|
||||||
|
87750 87751
|
||||||
|
12009 12018
|
||||||
|
87500 87501
|
||||||
|
12260 12270
|
||||||
|
87250 87251
|
||||||
|
12511 12522
|
||||||
|
87000 87001
|
||||||
|
12762 12774
|
||||||
|
86750 86751
|
||||||
|
13013 13026
|
||||||
|
86500 86501
|
||||||
|
13264 13278
|
||||||
|
86250 86251
|
||||||
401
knapsack/data/ks_400_0
Normal file
401
knapsack/data/ks_400_0
Normal file
@@ -0,0 +1,401 @@
|
|||||||
|
400 9486367
|
||||||
|
31860 76620
|
||||||
|
11884 28868
|
||||||
|
10492 25484
|
||||||
|
901 2502
|
||||||
|
43580 104660
|
||||||
|
9004 21908
|
||||||
|
6700 16500
|
||||||
|
29940 71980
|
||||||
|
7484 18268
|
||||||
|
5932 14564
|
||||||
|
7900 19300
|
||||||
|
6564 16028
|
||||||
|
6596 16092
|
||||||
|
8172 19844
|
||||||
|
5324 13148
|
||||||
|
8436 20572
|
||||||
|
7332 17964
|
||||||
|
6972 17044
|
||||||
|
7668 18636
|
||||||
|
6524 15948
|
||||||
|
6244 15388
|
||||||
|
635 1970
|
||||||
|
5396 13292
|
||||||
|
13596 32892
|
||||||
|
51188 122676
|
||||||
|
13684 33068
|
||||||
|
8596 20892
|
||||||
|
156840 375380
|
||||||
|
7900 19300
|
||||||
|
6460 15820
|
||||||
|
14132 34164
|
||||||
|
4980 12260
|
||||||
|
5216 12932
|
||||||
|
6276 15452
|
||||||
|
701 2102
|
||||||
|
3084 7868
|
||||||
|
6924 16948
|
||||||
|
5500 13500
|
||||||
|
3148 7996
|
||||||
|
47844 114788
|
||||||
|
226844 542788
|
||||||
|
25748 61996
|
||||||
|
7012 17124
|
||||||
|
3440 8580
|
||||||
|
15580 37660
|
||||||
|
314 1128
|
||||||
|
2852 7204
|
||||||
|
15500 37500
|
||||||
|
9348 22796
|
||||||
|
17768 42836
|
||||||
|
16396 39692
|
||||||
|
16540 39980
|
||||||
|
395124 944948
|
||||||
|
10196 24692
|
||||||
|
6652 16204
|
||||||
|
4848 11996
|
||||||
|
74372 178244
|
||||||
|
4556 11212
|
||||||
|
4900 12100
|
||||||
|
3508 8716
|
||||||
|
3820 9540
|
||||||
|
5460 13420
|
||||||
|
16564 40028
|
||||||
|
3896 9692
|
||||||
|
3832 9564
|
||||||
|
9012 21924
|
||||||
|
4428 10956
|
||||||
|
57796 138492
|
||||||
|
12052 29204
|
||||||
|
7052 17204
|
||||||
|
85864 205628
|
||||||
|
5068 12436
|
||||||
|
10484 25468
|
||||||
|
4516 11132
|
||||||
|
3620 9140
|
||||||
|
18052 43604
|
||||||
|
21 542
|
||||||
|
15804 38108
|
||||||
|
19020 45940
|
||||||
|
170844 408788
|
||||||
|
3732 9364
|
||||||
|
2920 7340
|
||||||
|
4120 10340
|
||||||
|
6828 16756
|
||||||
|
26252 63204
|
||||||
|
11676 28252
|
||||||
|
19916 47932
|
||||||
|
65488 156876
|
||||||
|
7172 17644
|
||||||
|
3772 9444
|
||||||
|
132868 318036
|
||||||
|
8332 20364
|
||||||
|
5308 13116
|
||||||
|
3780 9460
|
||||||
|
5208 12916
|
||||||
|
56788 136076
|
||||||
|
7172 17644
|
||||||
|
7868 19236
|
||||||
|
31412 75524
|
||||||
|
9252 22604
|
||||||
|
12276 29652
|
||||||
|
3712 9324
|
||||||
|
4516 11132
|
||||||
|
105876 253452
|
||||||
|
20084 48468
|
||||||
|
11492 27884
|
||||||
|
49092 117684
|
||||||
|
83452 199804
|
||||||
|
71372 171044
|
||||||
|
66572 159644
|
||||||
|
25268 60836
|
||||||
|
64292 154084
|
||||||
|
21228 51156
|
||||||
|
16812 40524
|
||||||
|
19260 46420
|
||||||
|
7740 18980
|
||||||
|
5632 13964
|
||||||
|
3256 8212
|
||||||
|
15580 37660
|
||||||
|
4824 11948
|
||||||
|
59700 143100
|
||||||
|
14500 35100
|
||||||
|
7208 17716
|
||||||
|
6028 14756
|
||||||
|
75716 181332
|
||||||
|
22364 53828
|
||||||
|
7636 18572
|
||||||
|
6444 15788
|
||||||
|
5192 12884
|
||||||
|
7388 18076
|
||||||
|
33156 79612
|
||||||
|
3032 7564
|
||||||
|
6628 16156
|
||||||
|
7036 17172
|
||||||
|
3200 8100
|
||||||
|
7300 17900
|
||||||
|
4452 11004
|
||||||
|
26364 63428
|
||||||
|
14036 33972
|
||||||
|
16932 40964
|
||||||
|
5788 14276
|
||||||
|
70476 168852
|
||||||
|
4552 11204
|
||||||
|
33980 81660
|
||||||
|
19300 46500
|
||||||
|
39628 95156
|
||||||
|
4484 11068
|
||||||
|
55044 131988
|
||||||
|
574 1848
|
||||||
|
29644 71188
|
||||||
|
9460 23020
|
||||||
|
106284 254468
|
||||||
|
304 1108
|
||||||
|
3580 8860
|
||||||
|
6308 15516
|
||||||
|
10492 25484
|
||||||
|
12820 31140
|
||||||
|
14436 34972
|
||||||
|
5044 12388
|
||||||
|
1155 3210
|
||||||
|
12468 30236
|
||||||
|
4380 10860
|
||||||
|
9876 24052
|
||||||
|
8752 21404
|
||||||
|
8676 21052
|
||||||
|
42848 102796
|
||||||
|
22844 54988
|
||||||
|
6244 15388
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
387480 926660
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
15996 38692
|
||||||
|
8372 20444
|
||||||
|
65488 156876
|
||||||
|
304 1108
|
||||||
|
4756 11812
|
||||||
|
5012 12324
|
||||||
|
304 1108
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
304 1108
|
||||||
|
1208 3316
|
||||||
|
47728 114556
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
314 1128
|
||||||
|
104036 249172
|
||||||
|
5248 12996
|
||||||
|
312 1124
|
||||||
|
24468 58836
|
||||||
|
7716 18932
|
||||||
|
30180 72460
|
||||||
|
4824 11948
|
||||||
|
1120 3140
|
||||||
|
11496 27892
|
||||||
|
4916 12132
|
||||||
|
14428 34956
|
||||||
|
24948 59996
|
||||||
|
41100 98700
|
||||||
|
28692 69084
|
||||||
|
826 2352
|
||||||
|
3073 7846
|
||||||
|
7684 18868
|
||||||
|
5604 13708
|
||||||
|
17188 41476
|
||||||
|
34828 83756
|
||||||
|
7540 18380
|
||||||
|
8004 19508
|
||||||
|
2648 6796
|
||||||
|
5124 12748
|
||||||
|
3096 7892
|
||||||
|
166516 398532
|
||||||
|
13756 33212
|
||||||
|
9980 24260
|
||||||
|
15980 38660
|
||||||
|
9056 22012
|
||||||
|
5052 12404
|
||||||
|
8212 20124
|
||||||
|
11164 27028
|
||||||
|
13036 31572
|
||||||
|
23596 56892
|
||||||
|
2028 5156
|
||||||
|
7584 18468
|
||||||
|
5772 14244
|
||||||
|
4124 10348
|
||||||
|
5368 13236
|
||||||
|
4364 10828
|
||||||
|
5604 13708
|
||||||
|
8500 20700
|
||||||
|
7676 18652
|
||||||
|
8636 20972
|
||||||
|
4588 11276
|
||||||
|
4152 10404
|
||||||
|
4860 12020
|
||||||
|
5484 13468
|
||||||
|
8636 20972
|
||||||
|
5140 12780
|
||||||
|
236380 565460
|
||||||
|
116500 278900
|
||||||
|
36480 87660
|
||||||
|
16968 41036
|
||||||
|
5232 12964
|
||||||
|
13280 32060
|
||||||
|
138032 330364
|
||||||
|
9044 21988
|
||||||
|
22028 53156
|
||||||
|
4632 11564
|
||||||
|
13196 31892
|
||||||
|
65404 156708
|
||||||
|
28940 69580
|
||||||
|
865 2430
|
||||||
|
45988 110276
|
||||||
|
670 2040
|
||||||
|
4820 11940
|
||||||
|
41356 99212
|
||||||
|
39844 95588
|
||||||
|
897 2494
|
||||||
|
4028 9956
|
||||||
|
7924 19348
|
||||||
|
47756 114612
|
||||||
|
47036 112772
|
||||||
|
25908 62316
|
||||||
|
4516 11132
|
||||||
|
29460 70820
|
||||||
|
7964 19428
|
||||||
|
16964 41028
|
||||||
|
22196 53492
|
||||||
|
68140 163380
|
||||||
|
80924 193948
|
||||||
|
63700 152700
|
||||||
|
20860 50220
|
||||||
|
1682 4464
|
||||||
|
16804 40508
|
||||||
|
3195 8090
|
||||||
|
60348 144596
|
||||||
|
1901 4902
|
||||||
|
67468 161636
|
||||||
|
4772 11844
|
||||||
|
11196 27092
|
||||||
|
25836 62172
|
||||||
|
49676 119252
|
||||||
|
6188 15276
|
||||||
|
15588 37676
|
||||||
|
4412 10924
|
||||||
|
26564 63828
|
||||||
|
16412 39724
|
||||||
|
8108 19716
|
||||||
|
6084 14868
|
||||||
|
9884 24068
|
||||||
|
4224 10548
|
||||||
|
14660 35420
|
||||||
|
25708 61916
|
||||||
|
39228 94156
|
||||||
|
40748 97796
|
||||||
|
40748 97796
|
||||||
|
64276 154052
|
||||||
|
114356 273812
|
||||||
|
14724 35548
|
||||||
|
4540 11180
|
||||||
|
11612 28124
|
||||||
|
4972 12244
|
||||||
|
10060 24420
|
||||||
|
14548 35196
|
||||||
|
3136 7972
|
||||||
|
9132 22164
|
||||||
|
5752 14204
|
||||||
|
10100 24500
|
||||||
|
12172 29444
|
||||||
|
24428 58756
|
||||||
|
3336 8372
|
||||||
|
4356 10812
|
||||||
|
8652 21004
|
||||||
|
14492 35084
|
||||||
|
8796 21492
|
||||||
|
6408 15716
|
||||||
|
6056 14812
|
||||||
|
10124 24548
|
||||||
|
387480 926660
|
||||||
|
18188 43876
|
||||||
|
7732 18964
|
||||||
|
9492 23084
|
||||||
|
7300 17900
|
||||||
|
10052 24404
|
||||||
|
19604 47308
|
||||||
|
6644 16188
|
||||||
|
107364 257028
|
||||||
|
91812 219924
|
||||||
|
4620 11540
|
||||||
|
42848 102796
|
||||||
|
33268 79836
|
||||||
|
13260 32020
|
||||||
|
6564 16028
|
||||||
|
6524 15948
|
||||||
|
13596 32892
|
||||||
|
13596 32892
|
||||||
|
47844 114788
|
||||||
|
226844 542788
|
||||||
|
226844 542788
|
||||||
|
226844 542788
|
||||||
|
226844 542788
|
||||||
|
85864 205628
|
||||||
|
170844 408788
|
||||||
|
56788 136076
|
||||||
|
6628 16156
|
||||||
|
10492 25484
|
||||||
|
104036 249172
|
||||||
|
14428 34956
|
||||||
|
14428 34956
|
||||||
|
22028 53156
|
||||||
|
22028 53156
|
||||||
|
22028 53156
|
||||||
|
25836 62172
|
||||||
|
11612 28124
|
||||||
|
11612 28124
|
||||||
|
11612 28124
|
||||||
|
85872 205644
|
||||||
|
1377 3654
|
||||||
|
1365820 3265540
|
||||||
|
562272 1344644
|
||||||
|
1445900 3457100
|
||||||
|
501060 1198220
|
||||||
|
106224 254348
|
||||||
|
492496 1177692
|
||||||
|
387824 927548
|
||||||
|
151320 362140
|
||||||
|
109924 263148
|
||||||
|
105696 253092
|
||||||
|
96404 230908
|
||||||
|
107732 257964
|
||||||
|
42140 101180
|
||||||
|
102896 246292
|
||||||
|
4036 9972
|
||||||
|
19616 47332
|
||||||
|
100948 241796
|
||||||
|
1417728 3389756
|
||||||
|
62604 150108
|
||||||
|
491820 1176140
|
||||||
|
33740 80980
|
||||||
|
25216 60732
|
||||||
|
111716 267532
|
||||||
|
400156 957012
|
||||||
|
108800 260500
|
||||||
|
1211040 2895580
|
||||||
41
knapsack/data/ks_40_0
Normal file
41
knapsack/data/ks_40_0
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
40 100000
|
||||||
|
90001 90000
|
||||||
|
89751 89750
|
||||||
|
10002 10001
|
||||||
|
89501 89500
|
||||||
|
10254 10252
|
||||||
|
89251 89250
|
||||||
|
10506 10503
|
||||||
|
89001 89000
|
||||||
|
10758 10754
|
||||||
|
88751 88750
|
||||||
|
11010 11005
|
||||||
|
88501 88500
|
||||||
|
11262 11256
|
||||||
|
88251 88250
|
||||||
|
11514 11507
|
||||||
|
88001 88000
|
||||||
|
11766 11758
|
||||||
|
87751 87750
|
||||||
|
12018 12009
|
||||||
|
87501 87500
|
||||||
|
12270 12260
|
||||||
|
87251 87250
|
||||||
|
12522 12511
|
||||||
|
87001 87000
|
||||||
|
12774 12762
|
||||||
|
86751 86750
|
||||||
|
13026 13013
|
||||||
|
86501 86500
|
||||||
|
13278 13264
|
||||||
|
86251 86250
|
||||||
|
13530 13515
|
||||||
|
86001 86000
|
||||||
|
13782 13766
|
||||||
|
85751 85750
|
||||||
|
14034 14017
|
||||||
|
85501 85500
|
||||||
|
14286 14268
|
||||||
|
85251 85250
|
||||||
|
14538 14519
|
||||||
|
86131 86130
|
||||||
46
knapsack/data/ks_45_0
Normal file
46
knapsack/data/ks_45_0
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
45 58181
|
||||||
|
1945 4990
|
||||||
|
321 1142
|
||||||
|
2945 7390
|
||||||
|
4136 10372
|
||||||
|
1107 3114
|
||||||
|
1022 2744
|
||||||
|
1101 3102
|
||||||
|
2890 7280
|
||||||
|
47019 112738
|
||||||
|
1530 3960
|
||||||
|
3432 8564
|
||||||
|
2165 5630
|
||||||
|
1703 4506
|
||||||
|
1106 3112
|
||||||
|
370 1240
|
||||||
|
657 2014
|
||||||
|
962 2624
|
||||||
|
1060 3020
|
||||||
|
805 2310
|
||||||
|
689 2078
|
||||||
|
1513 3926
|
||||||
|
3878 9656
|
||||||
|
13504 32708
|
||||||
|
1865 4830
|
||||||
|
667 2034
|
||||||
|
1833 4766
|
||||||
|
16553 40006
|
||||||
|
1261 3422
|
||||||
|
2593 6686
|
||||||
|
1170 3240
|
||||||
|
794 2288
|
||||||
|
671 2042
|
||||||
|
7421 18142
|
||||||
|
6009 14718
|
||||||
|
1767 4634
|
||||||
|
2622 6744
|
||||||
|
831 2362
|
||||||
|
701 2102
|
||||||
|
5222 12944
|
||||||
|
3086 7872
|
||||||
|
900 2500
|
||||||
|
3121 7942
|
||||||
|
1029 2958
|
||||||
|
52555 126010
|
||||||
|
389 1278
|
||||||
5
knapsack/data/ks_4_0
Normal file
5
knapsack/data/ks_4_0
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
4 11
|
||||||
|
8 4
|
||||||
|
10 5
|
||||||
|
15 8
|
||||||
|
4 3
|
||||||
501
knapsack/data/ks_500_0
Normal file
501
knapsack/data/ks_500_0
Normal file
@@ -0,0 +1,501 @@
|
|||||||
|
500 50000
|
||||||
|
384 412
|
||||||
|
7060 7285
|
||||||
|
8475 8103
|
||||||
|
5028 4876
|
||||||
|
9741 9369
|
||||||
|
3360 3538
|
||||||
|
1426 1394
|
||||||
|
2084 2204
|
||||||
|
4865 5362
|
||||||
|
1885 1779
|
||||||
|
8191 8376
|
||||||
|
6296 6460
|
||||||
|
3292 3193
|
||||||
|
10227 9957
|
||||||
|
5744 5513
|
||||||
|
2163 2365
|
||||||
|
10738 9786
|
||||||
|
5099 4865
|
||||||
|
9193 9406
|
||||||
|
7777 7455
|
||||||
|
8538 8090
|
||||||
|
9597 9224
|
||||||
|
1275 1257
|
||||||
|
6317 5831
|
||||||
|
7598 7177
|
||||||
|
2241 2297
|
||||||
|
1398 1271
|
||||||
|
4083 4216
|
||||||
|
6033 5634
|
||||||
|
1694 1560
|
||||||
|
7563 6878
|
||||||
|
12 12
|
||||||
|
7406 6872
|
||||||
|
7679 7142
|
||||||
|
6619 6945
|
||||||
|
9222 8778
|
||||||
|
1869 1785
|
||||||
|
6809 7485
|
||||||
|
4961 5033
|
||||||
|
2616 2719
|
||||||
|
6406 6156
|
||||||
|
1703 1826
|
||||||
|
6415 6795
|
||||||
|
4898 4790
|
||||||
|
7601 7620
|
||||||
|
2145 1971
|
||||||
|
6559 6310
|
||||||
|
1691 1874
|
||||||
|
8734 8092
|
||||||
|
9570 9321
|
||||||
|
7649 7955
|
||||||
|
0 1
|
||||||
|
5652 5146
|
||||||
|
475 517
|
||||||
|
8789 8341
|
||||||
|
1366 1400
|
||||||
|
3325 3230
|
||||||
|
5487 5443
|
||||||
|
7316 7097
|
||||||
|
10232 9979
|
||||||
|
1788 1873
|
||||||
|
9179 9259
|
||||||
|
3790 3940
|
||||||
|
7820 8611
|
||||||
|
4462 4552
|
||||||
|
832 893
|
||||||
|
6798 7209
|
||||||
|
5467 5319
|
||||||
|
5573 6065
|
||||||
|
5489 5010
|
||||||
|
8246 8770
|
||||||
|
2815 2918
|
||||||
|
8766 8355
|
||||||
|
7043 7760
|
||||||
|
8834 8052
|
||||||
|
8549 8969
|
||||||
|
6511 6415
|
||||||
|
9253 9812
|
||||||
|
831 861
|
||||||
|
4587 4755
|
||||||
|
202 210
|
||||||
|
1022 950
|
||||||
|
867 823
|
||||||
|
1989 2194
|
||||||
|
2813 2594
|
||||||
|
1711 1642
|
||||||
|
9343 9828
|
||||||
|
1840 2029
|
||||||
|
2772 2575
|
||||||
|
6035 5564
|
||||||
|
8815 9345
|
||||||
|
9329 8485
|
||||||
|
354 353
|
||||||
|
3488 3792
|
||||||
|
2701 2645
|
||||||
|
102 102
|
||||||
|
3711 4046
|
||||||
|
10505 9897
|
||||||
|
8471 9201
|
||||||
|
3406 3157
|
||||||
|
10171 9442
|
||||||
|
6862 7425
|
||||||
|
3747 3887
|
||||||
|
7132 7137
|
||||||
|
7386 7590
|
||||||
|
3073 3179
|
||||||
|
7566 8244
|
||||||
|
2269 2467
|
||||||
|
7134 7291
|
||||||
|
7750 7078
|
||||||
|
8126 8991
|
||||||
|
1803 1824
|
||||||
|
8229 8894
|
||||||
|
9725 9514
|
||||||
|
1468 1498
|
||||||
|
844 771
|
||||||
|
2939 2868
|
||||||
|
7538 7210
|
||||||
|
380 406
|
||||||
|
10182 9845
|
||||||
|
176 188
|
||||||
|
8874 8977
|
||||||
|
5461 5808
|
||||||
|
7833 7831
|
||||||
|
9668 9122
|
||||||
|
3381 3255
|
||||||
|
8534 7808
|
||||||
|
10002 9684
|
||||||
|
8881 9703
|
||||||
|
3503 3884
|
||||||
|
2774 2742
|
||||||
|
6546 6754
|
||||||
|
3368 3227
|
||||||
|
2269 2521
|
||||||
|
3229 3149
|
||||||
|
6703 6895
|
||||||
|
9740 9718
|
||||||
|
1660 1779
|
||||||
|
4724 4906
|
||||||
|
10161 9765
|
||||||
|
2460 2712
|
||||||
|
1221 1161
|
||||||
|
893 956
|
||||||
|
3922 3736
|
||||||
|
3837 3854
|
||||||
|
4564 4211
|
||||||
|
6844 7195
|
||||||
|
7300 7204
|
||||||
|
550 509
|
||||||
|
3347 3315
|
||||||
|
8141 8090
|
||||||
|
7173 7121
|
||||||
|
1386 1366
|
||||||
|
2216 2053
|
||||||
|
4182 4310
|
||||||
|
6496 6753
|
||||||
|
7540 7923
|
||||||
|
6576 7072
|
||||||
|
745 774
|
||||||
|
10510 9710
|
||||||
|
5294 5494
|
||||||
|
6752 6259
|
||||||
|
3818 4235
|
||||||
|
6704 6462
|
||||||
|
212 222
|
||||||
|
6247 5995
|
||||||
|
7948 8543
|
||||||
|
2763 2688
|
||||||
|
5698 5186
|
||||||
|
2307 2186
|
||||||
|
7426 7303
|
||||||
|
5292 5134
|
||||||
|
9295 8645
|
||||||
|
2578 2430
|
||||||
|
6097 5571
|
||||||
|
2925 3243
|
||||||
|
1223 1123
|
||||||
|
8720 8978
|
||||||
|
4240 4139
|
||||||
|
4344 4244
|
||||||
|
6250 6864
|
||||||
|
6547 7189
|
||||||
|
4989 4641
|
||||||
|
732 753
|
||||||
|
4440 4445
|
||||||
|
7861 8726
|
||||||
|
147 147
|
||||||
|
3066 3394
|
||||||
|
5265 5044
|
||||||
|
6723 7050
|
||||||
|
7443 7655
|
||||||
|
6062 6387
|
||||||
|
3793 3529
|
||||||
|
6167 6689
|
||||||
|
1965 1918
|
||||||
|
1479 1530
|
||||||
|
7177 7624
|
||||||
|
3624 3782
|
||||||
|
6602 7203
|
||||||
|
9195 9398
|
||||||
|
8667 8091
|
||||||
|
4802 4637
|
||||||
|
3317 3035
|
||||||
|
10496 9631
|
||||||
|
2441 2467
|
||||||
|
8759 7973
|
||||||
|
320 325
|
||||||
|
3459 3770
|
||||||
|
4805 4396
|
||||||
|
6153 5990
|
||||||
|
5076 5513
|
||||||
|
6003 6084
|
||||||
|
2143 2027
|
||||||
|
2915 3169
|
||||||
|
6150 6074
|
||||||
|
5077 4948
|
||||||
|
3335 3361
|
||||||
|
8400 8116
|
||||||
|
9711 9158
|
||||||
|
1375 1467
|
||||||
|
6421 6150
|
||||||
|
8784 8277
|
||||||
|
3085 2946
|
||||||
|
247 228
|
||||||
|
6182 6208
|
||||||
|
7543 7284
|
||||||
|
2056 2048
|
||||||
|
1198 1190
|
||||||
|
4033 4380
|
||||||
|
2527 2603
|
||||||
|
4158 4618
|
||||||
|
2552 2607
|
||||||
|
668 609
|
||||||
|
7843 8591
|
||||||
|
3986 3670
|
||||||
|
8463 8184
|
||||||
|
6382 6242
|
||||||
|
3103 3422
|
||||||
|
397 385
|
||||||
|
10619 9845
|
||||||
|
8138 8106
|
||||||
|
8370 8192
|
||||||
|
4321 3974
|
||||||
|
4514 4964
|
||||||
|
4041 4063
|
||||||
|
6558 6871
|
||||||
|
397 438
|
||||||
|
1943 2122
|
||||||
|
319 305
|
||||||
|
8557 8465
|
||||||
|
10517 9695
|
||||||
|
7573 8139
|
||||||
|
9981 9433
|
||||||
|
8833 8354
|
||||||
|
5854 5944
|
||||||
|
3796 3761
|
||||||
|
2043 2109
|
||||||
|
7288 7949
|
||||||
|
7280 7744
|
||||||
|
2163 2065
|
||||||
|
2469 2264
|
||||||
|
5532 5066
|
||||||
|
2318 2387
|
||||||
|
7179 6779
|
||||||
|
8381 9284
|
||||||
|
5665 5694
|
||||||
|
3544 3303
|
||||||
|
3108 2872
|
||||||
|
3050 2801
|
||||||
|
7307 6760
|
||||||
|
528 536
|
||||||
|
8598 8444
|
||||||
|
1282 1404
|
||||||
|
1912 1919
|
||||||
|
6096 6018
|
||||||
|
2305 2211
|
||||||
|
3787 3723
|
||||||
|
7142 6631
|
||||||
|
950 965
|
||||||
|
7389 7413
|
||||||
|
2823 2941
|
||||||
|
2097 1979
|
||||||
|
7066 6576
|
||||||
|
3447 3779
|
||||||
|
2727 2493
|
||||||
|
7624 8353
|
||||||
|
764 776
|
||||||
|
4578 4617
|
||||||
|
2503 2653
|
||||||
|
7276 7099
|
||||||
|
6643 6991
|
||||||
|
2786 2972
|
||||||
|
2422 2349
|
||||||
|
6811 6498
|
||||||
|
5584 5951
|
||||||
|
10727 9755
|
||||||
|
3882 3987
|
||||||
|
9566 9211
|
||||||
|
4396 4126
|
||||||
|
8930 8192
|
||||||
|
831 849
|
||||||
|
4712 4675
|
||||||
|
657 602
|
||||||
|
2738 3006
|
||||||
|
6995 6708
|
||||||
|
5598 5844
|
||||||
|
8939 9020
|
||||||
|
6861 6674
|
||||||
|
9795 9952
|
||||||
|
2090 2208
|
||||||
|
4661 4726
|
||||||
|
3258 3155
|
||||||
|
6520 6999
|
||||||
|
3040 3298
|
||||||
|
7137 6758
|
||||||
|
8379 8963
|
||||||
|
7682 7553
|
||||||
|
5225 5634
|
||||||
|
5653 5459
|
||||||
|
6605 6957
|
||||||
|
8226 7939
|
||||||
|
7947 8831
|
||||||
|
6663 6956
|
||||||
|
9263 8743
|
||||||
|
8527 7914
|
||||||
|
110 116
|
||||||
|
486 526
|
||||||
|
916 863
|
||||||
|
6285 6030
|
||||||
|
8658 8005
|
||||||
|
9627 9516
|
||||||
|
777 752
|
||||||
|
5208 5569
|
||||||
|
7641 7249
|
||||||
|
2961 2726
|
||||||
|
255 252
|
||||||
|
6656 6447
|
||||||
|
10101 9887
|
||||||
|
124 133
|
||||||
|
8303 7584
|
||||||
|
7576 8318
|
||||||
|
2428 2643
|
||||||
|
4008 4090
|
||||||
|
2645 2517
|
||||||
|
756 717
|
||||||
|
3980 4407
|
||||||
|
2950 3236
|
||||||
|
9529 9690
|
||||||
|
3644 3814
|
||||||
|
260 276
|
||||||
|
7840 8345
|
||||||
|
4601 4493
|
||||||
|
7423 7117
|
||||||
|
1692 1817
|
||||||
|
6957 7465
|
||||||
|
2923 3073
|
||||||
|
1677 1792
|
||||||
|
1138 1088
|
||||||
|
5317 5247
|
||||||
|
9705 9127
|
||||||
|
840 838
|
||||||
|
1209 1309
|
||||||
|
2481 2369
|
||||||
|
7686 8119
|
||||||
|
6022 5554
|
||||||
|
8029 8016
|
||||||
|
5418 5101
|
||||||
|
646 613
|
||||||
|
9511 8848
|
||||||
|
2350 2335
|
||||||
|
2544 2444
|
||||||
|
6819 7518
|
||||||
|
1055 1044
|
||||||
|
7563 7599
|
||||||
|
4530 4369
|
||||||
|
2249 2154
|
||||||
|
2244 2095
|
||||||
|
2976 3034
|
||||||
|
6533 6184
|
||||||
|
1518 1625
|
||||||
|
2484 2603
|
||||||
|
6100 6072
|
||||||
|
6326 6297
|
||||||
|
7341 7384
|
||||||
|
8751 8748
|
||||||
|
7195 7352
|
||||||
|
2487 2548
|
||||||
|
6846 7003
|
||||||
|
1049 1102
|
||||||
|
3670 3525
|
||||||
|
2538 2691
|
||||||
|
5378 5906
|
||||||
|
1530 1403
|
||||||
|
8675 8179
|
||||||
|
5411 5421
|
||||||
|
308 342
|
||||||
|
8138 8884
|
||||||
|
3751 4000
|
||||||
|
5392 5535
|
||||||
|
8288 7690
|
||||||
|
3425 3797
|
||||||
|
6599 6118
|
||||||
|
1855 2050
|
||||||
|
8516 8028
|
||||||
|
5331 5379
|
||||||
|
8180 7989
|
||||||
|
708 746
|
||||||
|
1217 1315
|
||||||
|
5753 5983
|
||||||
|
2918 3035
|
||||||
|
8370 8675
|
||||||
|
9502 9840
|
||||||
|
10584 9793
|
||||||
|
6538 6077
|
||||||
|
3678 3780
|
||||||
|
5013 5327
|
||||||
|
8374 8415
|
||||||
|
2038 1965
|
||||||
|
6129 5741
|
||||||
|
6622 6292
|
||||||
|
7569 7366
|
||||||
|
942 963
|
||||||
|
1259 1194
|
||||||
|
4277 3984
|
||||||
|
1121 1021
|
||||||
|
6333 5974
|
||||||
|
8989 9647
|
||||||
|
9265 8860
|
||||||
|
8344 8231
|
||||||
|
3112 3138
|
||||||
|
3347 3355
|
||||||
|
1352 1450
|
||||||
|
9712 9502
|
||||||
|
2307 2209
|
||||||
|
5520 5095
|
||||||
|
10137 9833
|
||||||
|
4583 4634
|
||||||
|
4444 4676
|
||||||
|
6024 5990
|
||||||
|
2481 2671
|
||||||
|
9522 9498
|
||||||
|
9993 9209
|
||||||
|
5687 6004
|
||||||
|
420 414
|
||||||
|
5365 5480
|
||||||
|
834 836
|
||||||
|
4767 4745
|
||||||
|
2409 2497
|
||||||
|
1897 1847
|
||||||
|
8698 9047
|
||||||
|
4612 4405
|
||||||
|
3524 3486
|
||||||
|
1156 1173
|
||||||
|
6516 5996
|
||||||
|
7741 7139
|
||||||
|
8546 9331
|
||||||
|
2349 2219
|
||||||
|
6095 6103
|
||||||
|
835 872
|
||||||
|
724 666
|
||||||
|
5288 5114
|
||||||
|
5659 6134
|
||||||
|
2847 3042
|
||||||
|
9627 9511
|
||||||
|
189 189
|
||||||
|
1509 1378
|
||||||
|
3609 3963
|
||||||
|
3802 3926
|
||||||
|
134 139
|
||||||
|
5689 6206
|
||||||
|
9097 9077
|
||||||
|
6347 5951
|
||||||
|
3007 2835
|
||||||
|
4305 3972
|
||||||
|
3155 3228
|
||||||
|
4130 3764
|
||||||
|
3904 3631
|
||||||
|
1915 2109
|
||||||
|
9014 9897
|
||||||
|
8504 8943
|
||||||
|
651 708
|
||||||
|
8947 8695
|
||||||
|
6239 5900
|
||||||
|
8311 8054
|
||||||
|
1412 1422
|
||||||
|
6513 7166
|
||||||
|
8244 8159
|
||||||
|
8127 8361
|
||||||
|
5552 5782
|
||||||
|
4068 4325
|
||||||
|
1013 935
|
||||||
|
10274 9984
|
||||||
|
2977 3181
|
||||||
|
2751 2876
|
||||||
|
10479 9715
|
||||||
|
2260 2159
|
||||||
|
5603 5520
|
||||||
|
3074 3065
|
||||||
|
9406 9789
|
||||||
|
9416 9939
|
||||||
51
knapsack/data/ks_50_0
Normal file
51
knapsack/data/ks_50_0
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
50 341045
|
||||||
|
1906 4912
|
||||||
|
41516 99732
|
||||||
|
23527 56554
|
||||||
|
559 1818
|
||||||
|
45136 108372
|
||||||
|
2625 6750
|
||||||
|
492 1484
|
||||||
|
1086 3072
|
||||||
|
5516 13532
|
||||||
|
4875 12050
|
||||||
|
7570 18440
|
||||||
|
4436 10972
|
||||||
|
620 1940
|
||||||
|
50897 122094
|
||||||
|
2129 5558
|
||||||
|
4265 10630
|
||||||
|
706 2112
|
||||||
|
2721 6942
|
||||||
|
16494 39888
|
||||||
|
29688 71276
|
||||||
|
3383 8466
|
||||||
|
2181 5662
|
||||||
|
96601 231302
|
||||||
|
1795 4690
|
||||||
|
7512 18324
|
||||||
|
1242 3384
|
||||||
|
2889 7278
|
||||||
|
2133 5566
|
||||||
|
103 706
|
||||||
|
4446 10992
|
||||||
|
11326 27552
|
||||||
|
3024 7548
|
||||||
|
217 934
|
||||||
|
13269 32038
|
||||||
|
281 1062
|
||||||
|
77174 184848
|
||||||
|
952 2604
|
||||||
|
15572 37644
|
||||||
|
566 1832
|
||||||
|
4103 10306
|
||||||
|
313 1126
|
||||||
|
14393 34886
|
||||||
|
1313 3526
|
||||||
|
348 1196
|
||||||
|
419 1338
|
||||||
|
246 992
|
||||||
|
445 1390
|
||||||
|
23552 56804
|
||||||
|
23552 56804
|
||||||
|
67 634
|
||||||
51
knapsack/data/ks_50_1
Normal file
51
knapsack/data/ks_50_1
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
50 5000
|
||||||
|
995 945
|
||||||
|
259 242
|
||||||
|
258 244
|
||||||
|
279 281
|
||||||
|
576 582
|
||||||
|
126 119
|
||||||
|
280 303
|
||||||
|
859 913
|
||||||
|
270 279
|
||||||
|
389 408
|
||||||
|
927 925
|
||||||
|
281 305
|
||||||
|
624 662
|
||||||
|
961 938
|
||||||
|
757 718
|
||||||
|
231 250
|
||||||
|
838 767
|
||||||
|
154 158
|
||||||
|
649 595
|
||||||
|
277 268
|
||||||
|
180 167
|
||||||
|
895 957
|
||||||
|
23 22
|
||||||
|
930 948
|
||||||
|
93 102
|
||||||
|
61 62
|
||||||
|
626 604
|
||||||
|
342 349
|
||||||
|
262 279
|
||||||
|
215 221
|
||||||
|
183 203
|
||||||
|
958 889
|
||||||
|
205 213
|
||||||
|
859 835
|
||||||
|
171 166
|
||||||
|
566 575
|
||||||
|
779 758
|
||||||
|
704 706
|
||||||
|
196 182
|
||||||
|
26 28
|
||||||
|
726 729
|
||||||
|
621 671
|
||||||
|
800 864
|
||||||
|
580 579
|
||||||
|
535 553
|
||||||
|
647 632
|
||||||
|
168 163
|
||||||
|
90 95
|
||||||
|
679 745
|
||||||
|
440 438
|
||||||
61
knapsack/data/ks_60_0
Normal file
61
knapsack/data/ks_60_0
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
60 100000
|
||||||
|
90000 90001
|
||||||
|
89750 89751
|
||||||
|
10001 10002
|
||||||
|
89500 89501
|
||||||
|
10252 10254
|
||||||
|
89250 89251
|
||||||
|
10503 10506
|
||||||
|
89000 89001
|
||||||
|
10754 10758
|
||||||
|
88750 88751
|
||||||
|
11005 11010
|
||||||
|
88500 88501
|
||||||
|
11256 11262
|
||||||
|
88250 88251
|
||||||
|
11507 11514
|
||||||
|
88000 88001
|
||||||
|
11758 11766
|
||||||
|
87750 87751
|
||||||
|
12009 12018
|
||||||
|
87500 87501
|
||||||
|
12260 12270
|
||||||
|
87250 87251
|
||||||
|
12511 12522
|
||||||
|
87000 87001
|
||||||
|
12762 12774
|
||||||
|
86750 86751
|
||||||
|
13013 13026
|
||||||
|
86500 86501
|
||||||
|
13264 13278
|
||||||
|
86250 86251
|
||||||
|
13515 13530
|
||||||
|
86000 86001
|
||||||
|
13766 13782
|
||||||
|
85750 85751
|
||||||
|
14017 14034
|
||||||
|
85500 85501
|
||||||
|
14268 14286
|
||||||
|
85250 85251
|
||||||
|
14519 14538
|
||||||
|
85000 85001
|
||||||
|
14770 14790
|
||||||
|
84750 84751
|
||||||
|
15021 15042
|
||||||
|
84500 84501
|
||||||
|
15272 15294
|
||||||
|
84250 84251
|
||||||
|
15523 15546
|
||||||
|
84000 84001
|
||||||
|
15774 15798
|
||||||
|
83750 83751
|
||||||
|
16025 16050
|
||||||
|
83500 83501
|
||||||
|
16276 16302
|
||||||
|
83250 83251
|
||||||
|
16527 16554
|
||||||
|
83000 83001
|
||||||
|
16778 16806
|
||||||
|
82750 82751
|
||||||
|
17029 17058
|
||||||
|
82500 82501
|
||||||
83
knapsack/data/ks_82_0
Normal file
83
knapsack/data/ks_82_0
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
82 104723596
|
||||||
|
13211 13211
|
||||||
|
26422 26422
|
||||||
|
52844 52844
|
||||||
|
105688 105688
|
||||||
|
211376 211376
|
||||||
|
422752 422752
|
||||||
|
845504 845504
|
||||||
|
1691008 1691008
|
||||||
|
3382016 3382016
|
||||||
|
6764032 6764032
|
||||||
|
13528064 13528064
|
||||||
|
27056128 27056128
|
||||||
|
54112256 54112256
|
||||||
|
13212 13212
|
||||||
|
26424 26424
|
||||||
|
52848 52848
|
||||||
|
105696 105696
|
||||||
|
211392 211392
|
||||||
|
422784 422784
|
||||||
|
845568 845568
|
||||||
|
1691136 1691136
|
||||||
|
3382272 3382272
|
||||||
|
6764544 6764544
|
||||||
|
13529088 13529088
|
||||||
|
27058176 27058176
|
||||||
|
54116352 54116352
|
||||||
|
39638 39638
|
||||||
|
79276 79276
|
||||||
|
158552 158552
|
||||||
|
317104 317104
|
||||||
|
634208 634208
|
||||||
|
1268416 1268416
|
||||||
|
2536832 2536832
|
||||||
|
5073664 5073664
|
||||||
|
10147328 10147328
|
||||||
|
20294656 20294656
|
||||||
|
40589312 40589312
|
||||||
|
81178624 81178624
|
||||||
|
52844 52844
|
||||||
|
105688 105688
|
||||||
|
211376 211376
|
||||||
|
422752 422752
|
||||||
|
845504 845504
|
||||||
|
1691008 1691008
|
||||||
|
3382016 3382016
|
||||||
|
6764032 6764032
|
||||||
|
13528064 13528064
|
||||||
|
27056128 27056128
|
||||||
|
54112256 54112256
|
||||||
|
66060 66060
|
||||||
|
132120 132120
|
||||||
|
264240 264240
|
||||||
|
528480 528480
|
||||||
|
1056960 1056960
|
||||||
|
2113920 2113920
|
||||||
|
4227840 4227840
|
||||||
|
8455680 8455680
|
||||||
|
16911360 16911360
|
||||||
|
33822720 33822720
|
||||||
|
67645440 67645440
|
||||||
|
79268 79268
|
||||||
|
158536 158536
|
||||||
|
317072 317072
|
||||||
|
634144 634144
|
||||||
|
1268288 1268288
|
||||||
|
2536576 2536576
|
||||||
|
5073152 5073152
|
||||||
|
10146304 10146304
|
||||||
|
20292608 20292608
|
||||||
|
40585216 40585216
|
||||||
|
81170432 81170432
|
||||||
|
92482 92482
|
||||||
|
184964 184964
|
||||||
|
369928 369928
|
||||||
|
739856 739856
|
||||||
|
1479712 1479712
|
||||||
|
2959424 2959424
|
||||||
|
5918848 5918848
|
||||||
|
11837696 11837696
|
||||||
|
23675392 23675392
|
||||||
|
47350784 47350784
|
||||||
|
94701568 94701568
|
||||||
4
knapsack/data/ks_lecture_dp_1
Normal file
4
knapsack/data/ks_lecture_dp_1
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
3 9
|
||||||
|
5 4
|
||||||
|
6 5
|
||||||
|
3 2
|
||||||
6
knapsack/data/ks_lecture_dp_2
Normal file
6
knapsack/data/ks_lecture_dp_2
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
4 7
|
||||||
|
16 2
|
||||||
|
19 3
|
||||||
|
23 4
|
||||||
|
28 5
|
||||||
|
|
||||||
BIN
knapsack/handout.pdf
Normal file
BIN
knapsack/handout.pdf
Normal file
Binary file not shown.
51
knapsack/solver.py
Executable file
51
knapsack/solver.py
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
Item = namedtuple("Item", ['index', 'value', 'weight'])
|
||||||
|
|
||||||
|
def solve_it(input_data):
|
||||||
|
# Modify this code to run your optimization algorithm
|
||||||
|
|
||||||
|
# parse the input
|
||||||
|
lines = input_data.split('\n')
|
||||||
|
|
||||||
|
firstLine = lines[0].split()
|
||||||
|
item_count = int(firstLine[0])
|
||||||
|
capacity = int(firstLine[1])
|
||||||
|
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for i in range(1, item_count+1):
|
||||||
|
line = lines[i]
|
||||||
|
parts = line.split()
|
||||||
|
items.append(Item(i-1, int(parts[0]), int(parts[1])))
|
||||||
|
|
||||||
|
# a trivial greedy algorithm for filling the knapsack
|
||||||
|
# it takes items in-order until the knapsack is full
|
||||||
|
value = 0
|
||||||
|
weight = 0
|
||||||
|
taken = [0]*len(items)
|
||||||
|
|
||||||
|
for item in items:
|
||||||
|
if weight + item.weight <= capacity:
|
||||||
|
taken[item.index] = 1
|
||||||
|
value += item.value
|
||||||
|
weight += item.weight
|
||||||
|
|
||||||
|
# prepare the solution in the specified output format
|
||||||
|
output_data = str(value) + ' ' + str(0) + '\n'
|
||||||
|
output_data += ' '.join(map(str, taken))
|
||||||
|
return output_data
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
file_location = sys.argv[1].strip()
|
||||||
|
with open(file_location, 'r') as input_data_file:
|
||||||
|
input_data = input_data_file.read()
|
||||||
|
print(solve_it(input_data))
|
||||||
|
else:
|
||||||
|
print('This test requires an input file. Please select one from the data directory. (i.e. python solver.py ./data/ks_4_0)')
|
||||||
|
|
||||||
37
knapsack/solverJava.py
Normal file
37
knapsack/solverJava.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
|
def solve_it(input_data):
|
||||||
|
|
||||||
|
# Writes the inputData to a temporay file
|
||||||
|
|
||||||
|
tmp_file_name = 'tmp.data'
|
||||||
|
tmp_file = open(tmp_file_name, 'w')
|
||||||
|
tmp_file.write(input_data)
|
||||||
|
tmp_file.close()
|
||||||
|
|
||||||
|
# Runs the command: java Solver -file=tmp.data
|
||||||
|
|
||||||
|
process = Popen(['java', 'Solver', '-file=' + tmp_file_name], stdout=PIPE)
|
||||||
|
(stdout, stderr) = process.communicate()
|
||||||
|
|
||||||
|
# removes the temporay file
|
||||||
|
os.remove(tmp_file_name)
|
||||||
|
|
||||||
|
return stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
file_location = sys.argv[1].strip()
|
||||||
|
with open(file_location, 'r') as input_data_file:
|
||||||
|
input_data = input_data_file.read()
|
||||||
|
print solve_it(input_data)
|
||||||
|
else:
|
||||||
|
print('This test requires an input file. Please select one from the data directory. (i.e. python solver.py ./data/ks_4_0)')
|
||||||
|
|
||||||
456
knapsack/submit.py
Executable file
456
knapsack/submit.py
Executable file
@@ -0,0 +1,456 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# Python 2/3 compatibility
|
||||||
|
# Python 2:
|
||||||
|
try:
|
||||||
|
from urlparse import urlparse
|
||||||
|
from urllib import urlencode
|
||||||
|
from urllib2 import urlopen, Request, HTTPError
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Python 3:
|
||||||
|
try:
|
||||||
|
from urllib.parse import urlparse, urlencode
|
||||||
|
from urllib.request import urlopen, Request
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
import sys
|
||||||
|
# Python 2:
|
||||||
|
if sys.version_info < (3, 0):
|
||||||
|
def input(str):
|
||||||
|
return raw_input(str)
|
||||||
|
|
||||||
|
# Python 3, backward compatibility with unicode test
|
||||||
|
if sys.version_info >= (3, 0):
|
||||||
|
unicode = type(str)
|
||||||
|
|
||||||
|
version = '1.0.0'
|
||||||
|
submitt_url = \
|
||||||
|
'https://www.coursera.org/api/onDemandProgrammingScriptSubmissions.v1'
|
||||||
|
|
||||||
|
Metadata = namedtuple("Metadata", ['assignment_key', 'name', 'part_data'])
|
||||||
|
Part = namedtuple("Part", ['id', 'input_file', 'solver_file', 'name'])
|
||||||
|
|
||||||
|
|
||||||
|
def load_metadata(metadata_file_name='_coursera'):
|
||||||
|
'''
|
||||||
|
Parses an assignment metadata file
|
||||||
|
|
||||||
|
Args:
|
||||||
|
metadata_file_name (str): location of the metadata file
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
metadata as a named tuple structure
|
||||||
|
'''
|
||||||
|
|
||||||
|
if not os.path.exists(metadata_file_name):
|
||||||
|
print('metadata file "%s" not found' % metadata_file_name)
|
||||||
|
quit()
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(metadata_file_name, 'r') as metadata_file:
|
||||||
|
url = metadata_file.readline().strip()
|
||||||
|
name = metadata_file.readline().strip()
|
||||||
|
part_data = []
|
||||||
|
for line in metadata_file.readlines():
|
||||||
|
if ',' in line:
|
||||||
|
line_parts = line.split(',')
|
||||||
|
line_parts = [x.strip() for x in line_parts]
|
||||||
|
assert(len(line_parts) == 4)
|
||||||
|
part_data.append(Part(*line_parts))
|
||||||
|
if len(url) <= 0:
|
||||||
|
print('Empty url in _coursera file: %s' % metadata_file_name)
|
||||||
|
quit()
|
||||||
|
if len(name) <= 0:
|
||||||
|
print('Empty assignment name in _coursera file: %s' % metadata_file_name)
|
||||||
|
quit()
|
||||||
|
except Exception as e:
|
||||||
|
print('problem parsing assignment metadata file')
|
||||||
|
print('exception message:')
|
||||||
|
print(e)
|
||||||
|
quit()
|
||||||
|
|
||||||
|
return Metadata(url, name, part_data)
|
||||||
|
|
||||||
|
|
||||||
|
def part_prompt(problems):
|
||||||
|
'''
|
||||||
|
Prompts the user for which parts of the assignment they would like to
|
||||||
|
submit.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
problems: a list of assignment problems
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the selected subset of problems
|
||||||
|
'''
|
||||||
|
|
||||||
|
count = 1
|
||||||
|
print('Hello! These are the assignment parts that you can submit:')
|
||||||
|
for i, problem in enumerate(problems):
|
||||||
|
print(str(count) + ') ' + problem.name)
|
||||||
|
count += 1
|
||||||
|
print('0) All')
|
||||||
|
|
||||||
|
part_text = input('Please enter which part(s) you want to submit (0-%d): ' % (count-1))
|
||||||
|
selected_problems = []
|
||||||
|
selected_models = []
|
||||||
|
|
||||||
|
for item in part_text.split(','):
|
||||||
|
try:
|
||||||
|
i = int(item)
|
||||||
|
except:
|
||||||
|
print('Skipping input "' + item + '". It is not an integer.')
|
||||||
|
continue
|
||||||
|
|
||||||
|
if i >= count or i < 0:
|
||||||
|
print('Skipping input "' + item + '". It is out of the valid range (0-%d).' % (count-1))
|
||||||
|
continue
|
||||||
|
|
||||||
|
if i == 0:
|
||||||
|
selected_problems.extend(problems)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if i <= len(problems):
|
||||||
|
selected_problems.append(problems[i-1])
|
||||||
|
|
||||||
|
if len(selected_problems) <= 0:
|
||||||
|
print('No valid assignment parts identified. Please try again. \n')
|
||||||
|
return part_prompt(problems)
|
||||||
|
else:
|
||||||
|
return selected_problems
|
||||||
|
|
||||||
|
|
||||||
|
def compute(metadata, solver_file_override=None):
|
||||||
|
'''
|
||||||
|
Determines which assignment parts the student would like to submit.
|
||||||
|
Then computes his/her answers to those assignment parts
|
||||||
|
|
||||||
|
Args:
|
||||||
|
metadata: the assignment metadata
|
||||||
|
solver_file_override: an optional model file to override the metadata
|
||||||
|
default
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
a dictionary of results in the format Coursera expects
|
||||||
|
'''
|
||||||
|
|
||||||
|
if solver_file_override is not None:
|
||||||
|
print('Overriding solver file with: '+solver_file_override)
|
||||||
|
|
||||||
|
selected_problems = part_prompt(metadata.part_data)
|
||||||
|
|
||||||
|
results = {}
|
||||||
|
|
||||||
|
#submission needs empty dict for every assignment part
|
||||||
|
results.update({prob_data.id : {} for prob_data in metadata.part_data})
|
||||||
|
|
||||||
|
for problem in selected_problems:
|
||||||
|
if solver_file_override != None:
|
||||||
|
solver_file = solver_file_override
|
||||||
|
else:
|
||||||
|
solver_file = problem.solver_file
|
||||||
|
|
||||||
|
if not os.path.isfile(solver_file):
|
||||||
|
print('Unable to locate assignment file "%s" in the current working directory.' % solver_file)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# if a relative path is given, add that patth to system path so import will work
|
||||||
|
if os.path.sep in solver_file:
|
||||||
|
split = solver_file.rfind(os.path.sep)
|
||||||
|
path = solver_file[0:split]
|
||||||
|
file_name = solver_file[split+1:]
|
||||||
|
sys.path.insert(0, path)
|
||||||
|
solver_file = file_name
|
||||||
|
|
||||||
|
submission = output(problem.input_file, solver_file)
|
||||||
|
if submission != None:
|
||||||
|
results[problem.id] = {'output':submission}
|
||||||
|
|
||||||
|
print('\n== Computations Complete ...')
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def load_input_data(file_location):
|
||||||
|
with open(file_location, 'r') as input_data_file:
|
||||||
|
input_data = ''.join(input_data_file.readlines())
|
||||||
|
return input_data
|
||||||
|
|
||||||
|
|
||||||
|
def output(input_file, solver_file):
|
||||||
|
'''
|
||||||
|
Attempts to execute solve_it locally on a given input file.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
input_file: the assignment problem data of interest
|
||||||
|
solver_file: a python file containing the solve_it function
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the submission string in a format that the grader expects
|
||||||
|
'''
|
||||||
|
|
||||||
|
try:
|
||||||
|
pkg = __import__(solver_file[:-3]) # remove '.py' extension
|
||||||
|
if not hasattr(pkg, 'solve_it'):
|
||||||
|
print('the solve_it() function was not found in %s' % solver_file)
|
||||||
|
quit()
|
||||||
|
except ImportError:
|
||||||
|
print('import error with python file "%s".' % solver_file)
|
||||||
|
quit()
|
||||||
|
|
||||||
|
|
||||||
|
solution = ''
|
||||||
|
|
||||||
|
start = time.clock()
|
||||||
|
try:
|
||||||
|
solution = pkg.solve_it(load_input_data(input_file))
|
||||||
|
except Exception as e:
|
||||||
|
print('the solve_it(input_data) method from solver.py raised an exception')
|
||||||
|
print('try testing it with python ./solver.py before running this submission script')
|
||||||
|
print('exception message:')
|
||||||
|
print(str(e))
|
||||||
|
print('')
|
||||||
|
return 'Local Exception =('
|
||||||
|
end = time.clock()
|
||||||
|
|
||||||
|
if not (isinstance(solution, str) or isinstance(solution, unicode)):
|
||||||
|
print('Warning: the solver did not return a string. The given object will be converted with the str() method.')
|
||||||
|
solution = str(solution)
|
||||||
|
|
||||||
|
print('Submitting: ')
|
||||||
|
print(solution)
|
||||||
|
|
||||||
|
return solution.strip() + '\n' + str(end - start)
|
||||||
|
|
||||||
|
|
||||||
|
def login_dialog(assignment_key, results, credentials_file_location = '_credentials'):
|
||||||
|
'''
|
||||||
|
Requests Coursera login credentials from the student and submits the
|
||||||
|
student's solutions for grading
|
||||||
|
|
||||||
|
Args:
|
||||||
|
assignment_key: Coursera's assignment key
|
||||||
|
results: a dictionary of results in Cousera's format
|
||||||
|
credentials_file_location: a file location where login credentials can
|
||||||
|
be found
|
||||||
|
'''
|
||||||
|
|
||||||
|
success = False
|
||||||
|
tries = 0
|
||||||
|
|
||||||
|
while not success:
|
||||||
|
|
||||||
|
# stops infinate loop when credentials file is incorrect
|
||||||
|
if tries <= 0:
|
||||||
|
login, token = login_prompt(credentials_file_location)
|
||||||
|
else:
|
||||||
|
login, token = login_prompt('')
|
||||||
|
|
||||||
|
code, responce = submit_solution(assignment_key, login, token, results)
|
||||||
|
|
||||||
|
print('\n== Coursera Responce ...')
|
||||||
|
#print(code)
|
||||||
|
print(responce)
|
||||||
|
|
||||||
|
if code != 401:
|
||||||
|
success = True
|
||||||
|
else:
|
||||||
|
print('\ntry logging in again')
|
||||||
|
tries += 1
|
||||||
|
|
||||||
|
def login_prompt(credentials_file_location):
|
||||||
|
'''
|
||||||
|
Attempts to load credentials from a file, if that fails asks the user.
|
||||||
|
Returns:
|
||||||
|
the user's login and token
|
||||||
|
'''
|
||||||
|
|
||||||
|
if os.path.isfile(credentials_file_location):
|
||||||
|
try:
|
||||||
|
with open(credentials_file_location, 'r') as metadata_file:
|
||||||
|
login = metadata_file.readline().strip()
|
||||||
|
token = metadata_file.readline().strip()
|
||||||
|
metadata_file.close()
|
||||||
|
except:
|
||||||
|
login, token = basic_prompt()
|
||||||
|
else:
|
||||||
|
login, token = basic_prompt()
|
||||||
|
return login, token
|
||||||
|
|
||||||
|
|
||||||
|
def basic_prompt():
|
||||||
|
'''
|
||||||
|
Prompt the user for login credentials.
|
||||||
|
Returns:
|
||||||
|
the user's login and token
|
||||||
|
'''
|
||||||
|
login = input('User Name (e-mail address): ')
|
||||||
|
token = input('Submission Token (from the assignment page): ')
|
||||||
|
return login, token
|
||||||
|
|
||||||
|
|
||||||
|
def submit_solution(assignment_key, email_address, token, results):
|
||||||
|
'''
|
||||||
|
Sends the student's submission to Coursera for grading via the submission
|
||||||
|
API.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
assignment_key: Coursera's assignment key
|
||||||
|
email_address: the student's email
|
||||||
|
token: the student's assignment token
|
||||||
|
results: a dictionary of results in Cousera's format
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the https response code and a feedback message
|
||||||
|
'''
|
||||||
|
|
||||||
|
print('\n== Connecting to Coursera ...')
|
||||||
|
print('Submitting %d of %d parts' %
|
||||||
|
(sum(['output' in v for k,v in results.items()]), len(results)))
|
||||||
|
|
||||||
|
# build json datastructure
|
||||||
|
parts = {}
|
||||||
|
submission = {
|
||||||
|
'assignmentKey': assignment_key,
|
||||||
|
'submitterEmail': email_address,
|
||||||
|
'secret': token,
|
||||||
|
'parts': results
|
||||||
|
}
|
||||||
|
|
||||||
|
# send submission
|
||||||
|
req = Request(submitt_url)
|
||||||
|
req.add_header('Cache-Control', 'no-cache')
|
||||||
|
req.add_header('Content-type', 'application/json')
|
||||||
|
|
||||||
|
try:
|
||||||
|
res = urlopen(req, json.dumps(submission).encode('utf8'))
|
||||||
|
except HTTPError as e:
|
||||||
|
responce = json.loads(e.read().decode('utf8'))
|
||||||
|
|
||||||
|
if 'details' in responce and responce['details'] != None and \
|
||||||
|
'learnerMessage' in responce['details']:
|
||||||
|
return e.code, responce['details']['learnerMessage']
|
||||||
|
else:
|
||||||
|
return e.code, 'Unexpected response code, please contact the ' \
|
||||||
|
'course staff.\nDetails: ' + responce['message']
|
||||||
|
|
||||||
|
code = res.code
|
||||||
|
responce = json.loads(res.read().decode('utf8'))
|
||||||
|
|
||||||
|
if code >= 200 and code <= 299:
|
||||||
|
return code, 'Your submission has been accepted and will be ' \
|
||||||
|
'graded shortly.'
|
||||||
|
|
||||||
|
return code, 'Unexpected response code, please contact the '\
|
||||||
|
'course staff.\nDetails: ' + responce
|
||||||
|
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
'''
|
||||||
|
1) Reads a metadata file to customize the submission process to
|
||||||
|
a particular assignment.
|
||||||
|
2) The compute the student's answers to the assignment parts.
|
||||||
|
3) Submits the student's answers for grading.
|
||||||
|
|
||||||
|
Provides the an option for saving the submissions locally. This is very
|
||||||
|
helpful when testing the assignment graders.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
args: CLI arguments from an argparse parser
|
||||||
|
'''
|
||||||
|
|
||||||
|
# needed so that output can import from the cwd
|
||||||
|
sys.path.append(os.getcwd())
|
||||||
|
|
||||||
|
if args.metadata is None:
|
||||||
|
metadata = load_metadata()
|
||||||
|
else:
|
||||||
|
print('Overriding metadata file with: '+args.metadata)
|
||||||
|
metadata = load_metadata(args.metadata)
|
||||||
|
|
||||||
|
print('==\n== '+metadata.name+' Solution Submission \n==')
|
||||||
|
|
||||||
|
# compute dialog
|
||||||
|
results = compute(metadata, args.override)
|
||||||
|
|
||||||
|
if sum(['output' in v for k,v in results.items()]) <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
# store submissions if requested
|
||||||
|
if args.record_submission == True:
|
||||||
|
print('Recording submission as files')
|
||||||
|
for sid, submission in results.items():
|
||||||
|
if 'output' in submission:
|
||||||
|
directory = '_'+sid
|
||||||
|
if not os.path.exists(directory):
|
||||||
|
os.makedirs(directory)
|
||||||
|
|
||||||
|
submission_file_name = directory+'/submission.sub'
|
||||||
|
print(' writting submission file: '+submission_file_name)
|
||||||
|
with open(submission_file_name,'w') as submission_file:
|
||||||
|
submission_file.write(submission['output'])
|
||||||
|
submission_file.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
# submit dialog
|
||||||
|
if args.credentials is None:
|
||||||
|
login_dialog(metadata.assignment_key, results)
|
||||||
|
else:
|
||||||
|
print('Overriding credentials file with: '+args.credentials)
|
||||||
|
login_dialog(metadata.assignment_key, results, args.credentials)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
def build_parser():
|
||||||
|
'''
|
||||||
|
Builds an argument parser for the CLI
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
parser: an argparse parser
|
||||||
|
'''
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='''The submission script for Discrete Optimization
|
||||||
|
assignments on the Coursera Platform.''',
|
||||||
|
epilog='''Please file bugs on github at:
|
||||||
|
https://github.com/discreteoptimization/assignment/issues. If you
|
||||||
|
would like to contribute to this tool's development, check it out at:
|
||||||
|
https://github.com/discreteoptimization/assignment'''
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument('-v', '--version', action='version',
|
||||||
|
version='%(prog)s '+version)
|
||||||
|
|
||||||
|
parser.add_argument('-o', '--override',
|
||||||
|
help='overrides the python source file specified in the \'_coursera\' file')
|
||||||
|
|
||||||
|
parser.add_argument('-m', '--metadata',
|
||||||
|
help='overrides the \'_coursera\' metadata file')
|
||||||
|
|
||||||
|
parser.add_argument('-c', '--credentials',
|
||||||
|
help='overrides the \'_credentials\' credentials file')
|
||||||
|
|
||||||
|
parser.add_argument('-rs', '--record_submission',
|
||||||
|
help='records the submission(s) as files', action='store_true')
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = build_parser()
|
||||||
|
main(parser.parse_args())
|
||||||
|
|
||||||
Reference in New Issue
Block a user