Skip to content
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

Merged
merged 22 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2b4f0b4
[pgtap]pgtap no-crash-test
Manas23601 Aug 15, 2022
b652ae6
Working on no_crash_test pgtap
Manas23601 Aug 15, 2022
1679240
[pgtap] not working
Manas23601 Aug 15, 2022
114785f
[pgtap] Added pgtap inner_query
Manas23601 Aug 20, 2022
80208ce
[pgtap] Added pgtap types_check
Manas23601 Aug 20, 2022
a271c49
[pgtap] Added pgtap no_crash_test
Manas23601 Aug 20, 2022
7909899
[sql/or_tools] Made Changes to functions to support pgtaps
Manas23601 Aug 20, 2022
cf8776c
[docqueries] Created Docqueries for vrp_knapsack
Manas23601 Aug 20, 2022
fdf1aba
[docqueries] Configuring Cmakelists and tests.conf
Manas23601 Aug 20, 2022
c188c17
[docqueries] Created empty files for other ortools functions
Manas23601 Aug 20, 2022
2d846fc
[docqueries]
Manas23601 Aug 20, 2022
bc6e4e8
[docqueries]
Manas23601 Aug 20, 2022
cb4efd8
[pgtap] Corrected number of tests
Manas23601 Aug 20, 2022
f0d2b41
[workflows] building ortools in github actions
Manas23601 Aug 21, 2022
34a9690
[worflows] experimenting with permission settings
Manas23601 Aug 21, 2022
c3b44b7
[worflows] experimenting with permission settings
Manas23601 Aug 21, 2022
b92d8b4
[.github] trying ortools indist-packages folder
Manas23601 Aug 21, 2022
28f6d3c
[.github] checking where ortools is installed in github actions
Manas23601 Aug 21, 2022
2de1cfa
[workflows] Google OR-Tools built succesfully in github actions
Manas23601 Aug 21, 2022
47d504d
[sql] Partial Documentation update
Manas23601 Aug 21, 2022
37bfe85
[doc] Doc template for OR-Tools functions
Manas23601 Aug 21, 2022
73b3ed5
removed an unnecessary file
Manas23601 Aug 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ jobs:
postgresql-${{ matrix.psql }}-pgrouting \
postgresql-server-dev-${{ matrix.psql }} \
postgresql-plpython3-${{ matrix.psql }}


- name: Install Google OR-Tools dependencies
run: |
sudo su
umask 022
pip3 install ortools
exit

- name: Install VROOM dependencies
run: |
sudo apt-get install libssl-dev libasio-dev libglpk-dev
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ gpush.sh
vrprun.sh
error_output.txt
.vscode/
vroom-v1.12.0/

# files are ignored on gh-pages
doxy
Expand Down
2 changes: 2 additions & 0 deletions docqueries/or_tools/CMakeLists.txt
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})
Expand Down
47 changes: 47 additions & 0 deletions docqueries/or_tools/bin_packing.result
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
Copy link
Member

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.

(1 row)

ROLLBACK;
ROLLBACK
10 changes: 10 additions & 0 deletions docqueries/or_tools/bin_packing.test.sql
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);
51 changes: 51 additions & 0 deletions docqueries/or_tools/knapsack.result
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Example:
INPUT: (id, weight, cost) in the inner query.
OUTPUT: (id) or maybe all three columns. I think just id is sufficient because other column values can be found out by SQL JOIN query.

Copy link
Author

Choose a reason for hiding this comment

The 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

Copy link
Author

Choose a reason for hiding this comment

The 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

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Author

@Manas23601 Manas23601 Aug 21, 2022

Choose a reason for hiding this comment

The 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.
Like

 Bin1
-------
   180
(1 row)
 BIn2
-------
   170
(1 row)

(1 row)

ROLLBACK;
ROLLBACK
9 changes: 5 additions & 4 deletions docqueries/or_tools/knapsack.test.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CREATE TABLE knapsack_data(
DROP TABLE IF EXISTS knapsack_query;
CREATE TABLE knapsack_query(
weight INTEGER,
cost INTEGER);

INSERT INTO knapsack_data (weight, cost)
INSERT INTO knapsack_query(weight, cost)
VALUES
(12, 4),
(2, 2),
Expand All @@ -11,7 +12,7 @@ VALUES
(1, 2);

SELECT *
FROM knapsack_data;
FROM knapsack_query;

SELECT *
FROM vrp_knapsack($$SELECT weight, cost FROM knapsack_data$$, 3);
FROM vrp_knapsack($$SELECT * FROM knapsack_query$$, 15);
96 changes: 96 additions & 0 deletions docqueries/or_tools/multiple_knapsack.result
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Example:
INPUT: (id, weight, cost) in the inner query
OUTPUT: (bin_number, item_id)

(1 row)

ROLLBACK;
ROLLBACK
29 changes: 29 additions & 0 deletions docqueries/or_tools/multiple_knapsack.test.sql
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]);
4 changes: 4 additions & 0 deletions docqueries/or_tools/test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
'newdb' => 1,
'tests' => [qw(
knapsack
multiple_knapsack
bin_packing
)],

'documentation' => [qw(
knapsack
multiple_knapsack
bin_packing
)],

'nottesting' => [qw(
Expand Down
Loading