vrp_knapsack - 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 knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, Determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible

Signatures

vrp_knapsack(Weight Costs SQL, capacity, [max_rows])
RETURNS SET OF (item_id)
OR EMPTY SET

Parameters

Column

Type

Description

Weight Costs SQL

TEXT

Weight Costs SQL as described below.

capacity

ANY-INTEGER

Maximum Capacity of the knapsack.

Optional Parameters

Column

Type

Default

Description

max_rows

ANY-INTEGER

\(100000\)

Maximum items(rows) to fetch from knapsack_data table.

Where:

ANY-INTEGER:

SMALLINT, INTEGER, BIGINT

Inner Queries

Weight Costs SQL

Column

Type

Description

id

ANY-INTEGER

Unique identifier of the item.

weight

ANY-INTEGER

Weight of the item.

cost

ANY-INTEGER

Cost of the item.

Where:

ANY-INTEGER:

SMALLINT, INTEGER, BIGINT

Result Columns

Column

Type

Description

id

INTEGER

Indentifier of an item in the knapsack.

Where:

ANY-INTEGER:

SMALLINT, INTEGER, BIGINT

Example

SELECT *
FROM vrp_knapsack($$SELECT * FROM ortools.knapsack$$, 15);
 id
----
  2
  3
  4
  5
(4 rows)

See Also

Indices and tables