-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GSoC 2022: Manas Sivakumar Week 10 #252
Changes from 16 commits
2b4f0b4
b652ae6
1679240
114785f
80208ce
a271c49
7909899
cf8776c
fdf1aba
c188c17
2d846fc
bc6e4e8
cb4efd8
f0d2b41
34a9690
c3b44b7
b92d8b4
28f6d3c
2de1cfa
47d504d
37bfe85
73b3ed5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ gpush.sh | |
vrprun.sh | ||
error_output.txt | ||
.vscode/ | ||
vroom-v1.12.0/ | ||
|
||
# files are ignored on gh-pages | ||
doxy | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
SET(LOCAL_FILES | ||
knapsack | ||
multiple_knapsack | ||
bin_packing | ||
) | ||
|
||
foreach (f ${LOCAL_FILES}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
BEGIN; | ||
BEGIN | ||
SET client_min_messages TO NOTICE; | ||
SET | ||
DROP TABLE IF EXISTS bin_packing_query CASCADE; | ||
NOTICE: table "bin_packing_query" does not exist, skipping | ||
DROP TABLE | ||
CREATE TABLE bin_packing_query( | ||
weight INTEGER); | ||
CREATE TABLE | ||
INSERT INTO bin_packing_query (weight) | ||
VALUES | ||
(48), (30), (19), (36), (36), (27), (42), (42), (36), (24), (30); | ||
INSERT 0 11 | ||
SELECT * FROM vrp_bin_packing('SELECT * FROM bin_packing_query', 100); | ||
NOTICE: Entering Bin Packing program | ||
NOTICE: Starting Execution of inner query | ||
INFO: ('Number of rows processed : ', 11) | ||
NOTICE: SQL query returned expected column names | ||
NOTICE: SQL query returned expected column types | ||
NOTICE: Finished Execution of inner query | ||
NOTICE: SCIP solver ready! | ||
INFO: ('Bin number', 0) | ||
INFO: (' Items packed', [0, 1, 2]) | ||
INFO: (' Item weights', [48, 30, 19]) | ||
INFO: (' Total weight', 97) | ||
INFO: ('Bin number', 1) | ||
INFO: (' Items packed', [3, 4, 5]) | ||
INFO: (' Item weights', [36, 36, 27]) | ||
INFO: (' Total weight', 99) | ||
INFO: ('Bin number', 2) | ||
INFO: (' Items packed', [6, 7]) | ||
INFO: (' Item weights', [42, 42]) | ||
INFO: (' Total weight', 84) | ||
INFO: ('Bin number', 3) | ||
INFO: (' Items packed', [8, 9, 10]) | ||
INFO: (' Item weights', [36, 24, 30]) | ||
INFO: (' Total weight', 90) | ||
INFO: ('Number of bins used', 4.0) | ||
NOTICE: Exiting Bin Packing program | ||
vrp_bin_packing | ||
----------------- | ||
Success | ||
(1 row) | ||
|
||
ROLLBACK; | ||
ROLLBACK |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
DROP TABLE IF EXISTS bin_packing_query CASCADE; | ||
|
||
CREATE TABLE bin_packing_query( | ||
weight INTEGER); | ||
|
||
INSERT INTO bin_packing_query (weight) | ||
VALUES | ||
(48), (30), (19), (36), (36), (27), (42), (42), (36), (24), (30); | ||
|
||
SELECT * FROM vrp_bin_packing('SELECT * FROM bin_packing_query', 100); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
BEGIN; | ||
BEGIN | ||
SET client_min_messages TO NOTICE; | ||
SET | ||
DROP TABLE IF EXISTS knapsack_query; | ||
NOTICE: table "knapsack_query" does not exist, skipping | ||
DROP TABLE | ||
CREATE TABLE knapsack_query( | ||
weight INTEGER, | ||
cost INTEGER); | ||
CREATE TABLE | ||
INSERT INTO knapsack_query(weight, cost) | ||
VALUES | ||
(12, 4), | ||
(2, 2), | ||
(1, 1), | ||
(4, 10), | ||
(1, 2); | ||
INSERT 0 5 | ||
SELECT * | ||
FROM knapsack_query; | ||
weight | cost | ||
--------+------ | ||
12 | 4 | ||
2 | 2 | ||
1 | 1 | ||
4 | 10 | ||
1 | 2 | ||
(5 rows) | ||
|
||
SELECT * | ||
FROM vrp_knapsack($$SELECT * FROM knapsack_query$$, 15); | ||
NOTICE: Entering Knapsack program | ||
NOTICE: Starting Execution of inner query | ||
INFO: ('Number of rows processed : ', 5) | ||
NOTICE: SQL query returned expected column names | ||
NOTICE: SQL query returned expected column types | ||
NOTICE: Finished Execution of inner query | ||
INFO: ('Total value =', 15) | ||
INFO: ('Total weight:', 8) | ||
INFO: ('Packed items: ', [1, 2, 3, 4]) | ||
INFO: ('Packed weights: ', [2, 1, 4, 1]) | ||
INFO: ('Packed values: ', [2, 1, 10, 2]) | ||
NOTICE: Exiting program | ||
vrp_knapsack | ||
-------------- | ||
Success | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. Example: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially implemented something similar to what you are suggesting. but for the other two functions multiple knapsack and bin_packing, this approach won't make sense because each bin should have its own output table so that the user can differentiate which items are in which box There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I tried printing the output for each bin one by one, the outputs got merged into one single result query There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also Vicky Mentioned something about not wanting to user-defined types. I made some examples on that inside the sql/or_tools/plpython folder. I'll remove that in the final PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any way to break the result query?? Same columns but different output tables.
|
||
(1 row) | ||
|
||
ROLLBACK; | ||
ROLLBACK |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
BEGIN; | ||
BEGIN | ||
SET client_min_messages TO NOTICE; | ||
SET | ||
DROP TABLE IF EXISTS multiple_knapsack_query CASCADE; | ||
NOTICE: table "multiple_knapsack_query" does not exist, skipping | ||
DROP TABLE | ||
CREATE TABLE multiple_knapsack_query( | ||
weight INTEGER, | ||
cost INTEGER); | ||
CREATE TABLE | ||
INSERT INTO multiple_knapsack_query (weight, cost) | ||
VALUES | ||
(48, 10), | ||
(30, 30), | ||
(42, 25), | ||
(36, 50), | ||
(36, 35), | ||
(48, 30), | ||
(42, 15), | ||
(42, 40), | ||
(36, 30), | ||
(24, 35), | ||
(30, 45), | ||
(30, 10), | ||
(42, 20), | ||
(36, 30), | ||
(36, 25); | ||
INSERT 0 15 | ||
SELECT * | ||
FROM multiple_knapsack_query; | ||
weight | cost | ||
--------+------ | ||
48 | 10 | ||
30 | 30 | ||
42 | 25 | ||
36 | 50 | ||
36 | 35 | ||
48 | 30 | ||
42 | 15 | ||
42 | 40 | ||
36 | 30 | ||
24 | 35 | ||
30 | 45 | ||
30 | 10 | ||
42 | 20 | ||
36 | 30 | ||
36 | 25 | ||
(15 rows) | ||
|
||
SELECT * | ||
FROM vrp_multiple_knapsack('SELECT * FROM multiple_knapsack_query', ARRAY[100,100,100,100,100]); | ||
NOTICE: Entering Mulitple Knapsack program | ||
NOTICE: Starting Execution of inner query | ||
INFO: ('Number of rows processed : ', 15) | ||
NOTICE: SQL query returned expected column names | ||
NOTICE: SQL query returned expected column types | ||
NOTICE: Finished Execution of inner query | ||
NOTICE: SCIP solver ready! | ||
INFO: ('Total value =', 395.0) | ||
INFO: ('Bin :', 0) | ||
INFO: Item 1 - weight: 30 value: 30 | ||
INFO: Item 3 - weight: 36 value: 50 | ||
INFO: Item 10 - weight: 30 value: 45 | ||
INFO: ('Packed bin weight', 96) | ||
INFO: ('Packed bin value', 125) | ||
INFO: ('Bin :', 1) | ||
INFO: Item 2 - weight: 42 value: 25 | ||
INFO: Item 14 - weight: 36 value: 25 | ||
INFO: ('Packed bin weight', 78) | ||
INFO: ('Packed bin value', 50) | ||
INFO: ('Bin :', 2) | ||
INFO: Item 4 - weight: 36 value: 35 | ||
INFO: Item 9 - weight: 24 value: 35 | ||
INFO: Item 13 - weight: 36 value: 30 | ||
INFO: ('Packed bin weight', 96) | ||
INFO: ('Packed bin value', 100) | ||
INFO: ('Bin :', 3) | ||
INFO: Item 8 - weight: 36 value: 30 | ||
INFO: Item 12 - weight: 42 value: 20 | ||
INFO: ('Packed bin weight', 78) | ||
INFO: ('Packed bin value', 50) | ||
INFO: ('Bin :', 4) | ||
INFO: Item 5 - weight: 48 value: 30 | ||
INFO: Item 7 - weight: 42 value: 40 | ||
INFO: ('Packed bin weight', 90) | ||
INFO: ('Packed bin value', 70) | ||
INFO: ('Total packed weight', 438) | ||
NOTICE: Exiting Multiple Knapsack program | ||
vrp_multiple_knapsack | ||
----------------------- | ||
Success | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. Example: |
||
(1 row) | ||
|
||
ROLLBACK; | ||
ROLLBACK |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
DROP TABLE IF EXISTS multiple_knapsack_query CASCADE; | ||
|
||
CREATE TABLE multiple_knapsack_query( | ||
weight INTEGER, | ||
cost INTEGER); | ||
|
||
INSERT INTO multiple_knapsack_query (weight, cost) | ||
VALUES | ||
(48, 10), | ||
(30, 30), | ||
(42, 25), | ||
(36, 50), | ||
(36, 35), | ||
(48, 30), | ||
(42, 15), | ||
(42, 40), | ||
(36, 30), | ||
(24, 35), | ||
(30, 45), | ||
(30, 10), | ||
(42, 20), | ||
(36, 30), | ||
(36, 25); | ||
|
||
SELECT * | ||
FROM multiple_knapsack_query; | ||
|
||
SELECT * | ||
FROM vrp_multiple_knapsack('SELECT * FROM multiple_knapsack_query', ARRAY[100,100,100,100,100]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the
NOTICE
,INFO
, etc are just additional info to the user and are not generally considered as the "result" of the query. The result of your query is just "Success", so it would be better if you instead output some helpful information in the query result.As an example, maybe you can take as input a set of rows containing
(id, weight)
in the inner query instead of(weight)
, and output set of(bin_number, item_id)
as the result.