vrp_bin_packing - Experimental

Warning

Possible server crash

  • These functions might create a server crash

Warning

Experimental functions

  • They are not officially of the current release.

  • They likely will not be officially be part of the next release:

    • The functions might not make use of ANY-INTEGER and ANY-NUMERICAL

    • Name might change.

    • Signature might change.

    • Functionality might change.

    • pgTap tests might be missing.

    • Might need c/c++ coding.

    • May lack documentation.

    • Documentation if any might need to be rewritten.

    • Documentation examples might need to be automatically generated.

    • Might need a lot of feedback from the comunity.

    • Might depend on a proposed function of vrpRouting

    • Might depend on a deprecated function of vrpRouting

Availability

Version 0.4.1

  • Support for or-tools v9.10.4067

Version 0.4.0

  • New experimental function

    • vrp_knapsack

Description

The bin packing problem is an optimization problem, in which items of different sizes must be packed into a finite number of bins or containers, each of a fixed given capacity, in a way that minimizes the number of bins used. The problem has many applications, such as filling up containers, loading trucks with weight capacity constraints, creating file backups in media and technology mapping in FPGA semiconductor chip design.

Signatures

Summary

vrp_bin_packing(Weights SQL, bin_capacity, [max_rows])
Returns set of (bin_number, item_id)
OR EMPTY SET

Parameters

Column

Type

Description

Weights SQL

TEXT

Weights SQL as described below

bin_capacity

ANY-INTEGER

Maximum Capacity of the bin.

Optional Parameters

Column

Type

Default

Description

max_rows

ANY-INTEGER

\(100000\)

Maximum items(rows) to fetch from bin_packing_data table.

Where:

ANY-INTEGER:

SMALLINT, INTEGER, BIGINT

Inner Queries

Weights SQL

A SELECT statement that returns the following columns:

Column

Type

Description

id

ANY-INTEGER

Identifier of the item.

weight

ANY-INTEGER

Weight of the item.

Where:

ANY-INTEGER:

SMALLINT, INTEGER, BIGINT

Result Columns

Column

Type

Description

bin

ANY-INTEGER

Integer to uniquely identify a bin.

id

ANY-INTEGER

Indentifier of an item in the bin.

Where:

ANY-INTEGER:

SMALLINT, INTEGER, BIGINT

Example

SELECT *
FROM vrp_bin_packing($$SELECT id, weight FROM ortools.bin_packing$$, 100);
 bin | id
-----+----
   1 |  1
   1 |  2
   1 |  3
   2 |  4
   2 |  5
   2 |  6
   3 |  7
   3 |  8
   4 |  9
   4 | 10
   4 | 11
(11 rows)

See Also

Indices and tables