Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
81 changes: 81 additions & 0 deletions data/irregular/tests/fixed_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"objective": "open-dimension-x",
"bin_types": [
{
"type": "polygon",
"copies": 1,
"copies_min": 1,
"vertices": [
{
"x": 0,
"y": 0
},
{
"x": 40,
"y": 0
},
{
"x": 40,
"y": 30
},
{
"x": 0,
"y": 30
}
],
"fixed_items": [
{
"item_type_id": 0,
"angle": 0,
"mirror": false,
"bl_corner": {"x": 10, "y": 10}
}
]
}
],
"item_types": [
{
"type": "polygon",
"vertices": [
{
"x": 0,
"y": 0
},
{
"x": 10,
"y": 0
},
{
"x": 10,
"y": 20
},
{
"x": 0,
"y": 20
}
]
},
{
"type": "polygon",
"allow_mirroring": true,
"vertices": [
{
"x": 0,
"y": 0
},
{
"x": 10,
"y": 0
},
{
"x": 10,
"y": 10
},
{
"x": 0,
"y": 10
}
]
}
]
}
122 changes: 122 additions & 0 deletions data/irregular/tests/fixed_item_solution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"bins": [
{
"copies": 1,
"id": 0,
"items": [
{
"angle": 0.0,
"id": 1,
"item_shapes": [
{
"shape": [
{
"type": "LineSegment",
"xe": 10.0,
"xs": 0.0,
"ye": 0.0,
"ys": 0.0
},
{
"type": "LineSegment",
"xe": 10.0,
"xs": 10.0,
"ye": 10.0,
"ys": 0.0
},
{
"type": "LineSegment",
"xe": 0.0,
"xs": 10.0,
"ye": 10.0,
"ys": 10.0
},
{
"type": "LineSegment",
"xe": 0.0,
"xs": 0.0,
"ye": 0.0,
"ys": 10.0
}
]
}
],
"mirror": false,
"x": 0.0,
"y": 0.0
},
{
"angle": 0.0,
"id": 0,
"item_shapes": [
{
"shape": [
{
"type": "LineSegment",
"xe": 20.0,
"xs": 10.0,
"ye": 10.0,
"ys": 10.0
},
{
"type": "LineSegment",
"xe": 20.0,
"xs": 20.0,
"ye": 30.0,
"ys": 10.0
},
{
"type": "LineSegment",
"xe": 10.0,
"xs": 20.0,
"ye": 30.0,
"ys": 30.0
},
{
"type": "LineSegment",
"xe": 10.0,
"xs": 10.0,
"ye": 10.0,
"ys": 30.0
}
]
}
],
"mirror": false,
"x": 10.0,
"y": 10.0
}
],
"shape": [
{
"type": "LineSegment",
"xe": 40.0,
"xs": 0.0,
"ye": 0.0,
"ys": 0.0
},
{
"type": "LineSegment",
"xe": 40.0,
"xs": 40.0,
"ye": 30.0,
"ys": 0.0
},
{
"type": "LineSegment",
"xe": 0.0,
"xs": 40.0,
"ye": 30.0,
"ys": 30.0
},
{
"type": "LineSegment",
"xe": 0.0,
"xs": 0.0,
"ye": 0.0,
"ys": 30.0
}
]
}
]
}
18 changes: 18 additions & 0 deletions include/packingsolver/box/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,27 @@ struct ItemType
inline Volume space() const { return volume(); }

inline bool can_rotate(int rotation) const { return ((rotations >> rotation) & 1); }

/** Number of fixed copies of the item type (pre-placed in bin types). */
ItemPos copies_fixed = 0;
};

std::ostream& operator<<(
std::ostream& os,
const ItemType& item_type);

struct FixedItem
{
/** Item type. */
ItemTypeId item_type_id;

/** Bottom-left corner of the item. */
Point bl_corner;

/** Rotation of the item. */
int rotation;
};

/**
* Bin type structure for a problem of type 'box'.
*/
Expand All @@ -167,6 +182,9 @@ struct BinType
/** Maximum weight. */
Weight maximum_weight = std::numeric_limits<Weight>::infinity();

/** Fixed items pre-placed in every bin of this type. */
std::vector<FixedItem> fixed_items;

/*
* Computed attributes
*/
Expand Down
15 changes: 12 additions & 3 deletions include/packingsolver/box/instance_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ class InstanceBuilder
* This method is used in the column generation procedure.
*/
void add_bin_type(
const BinType& bin_type,
BinPos copies);
const Instance& original_instance,
BinTypeId original_bin_type_id,
BinPos copies,
BinPos copies_min = 0);

/**
* For each bin type, set an infinite x.
Expand Down Expand Up @@ -120,7 +122,8 @@ class InstanceBuilder
* This method is used in the column generation procedure.
*/
void add_item_type(
const ItemType& item_type,
const Instance& original_instance,
ItemTypeId original_item_type_id,
Profit profit,
ItemPos copies);

Expand Down Expand Up @@ -175,6 +178,12 @@ class InstanceBuilder
/** Instance. */
Instance instance_;

/** Mapping from original bin type IDs to sub-instance bin type IDs. */
std::vector<BinTypeId> orig_to_sub_bin_type_ids_;

/** Mapping from original item type IDs to sub-instance item type IDs. */
std::vector<ItemTypeId> orig_to_sub_item_type_ids_;

};

}
Expand Down
21 changes: 21 additions & 0 deletions include/packingsolver/boxstacks/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,30 @@ struct ItemType
inline Volume space() const { return volume(); }

inline bool can_rotate(int rotation) const { return ((rotations >> rotation) & 1); }

/** Number of fixed copies of the item type (pre-placed in bin types). */
ItemPos copies_fixed = 0;
};

std::ostream& operator<<(
std::ostream& os,
const ItemType& item_type);

struct FixedItem
{
/** Item type. */
ItemTypeId item_type_id;

/** Position of the bottom-left corner of the stack. */
Point bl_corner;

/** Initial z-coordinate of the item. */
Length z_start;

/** Rotation of the item. */
int rotation;
};

/**
* Bin type structure for a problem of type 'boxstacks'.
*/
Expand Down Expand Up @@ -258,6 +276,9 @@ struct BinType
/** Semi-trailer truck data. */
SemiTrailerTruckData semi_trailer_truck_data;

/** Fixed items pre-placed in every bin of this type. */
std::vector<FixedItem> fixed_items;

/*
* Computed attributes
*/
Expand Down
15 changes: 12 additions & 3 deletions include/packingsolver/boxstacks/instance_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ class InstanceBuilder
* This method is used in the column generation procedure.
*/
void add_bin_type(
const BinType& bin_type,
BinPos copies);
const Instance& original_instance,
BinTypeId original_bin_type_id,
BinPos copies,
BinPos copies_min = 0);

/**
* For each bin type, set an infinite x.
Expand Down Expand Up @@ -174,7 +176,8 @@ class InstanceBuilder
* This method is used in the column generation procedure.
*/
void add_item_type(
const ItemType& item_type,
const Instance& original_instance,
ItemTypeId original_item_type_id,
Profit profit,
ItemPos copies);

Expand Down Expand Up @@ -229,6 +232,12 @@ class InstanceBuilder
/** Instance. */
Instance instance_;

/** Mapping from original bin type IDs to sub-instance bin type IDs. */
std::vector<BinTypeId> orig_to_sub_bin_type_ids_;

/** Mapping from original item type IDs to sub-instance item type IDs. */
std::vector<ItemTypeId> orig_to_sub_item_type_ids_;

};

}
Expand Down
Loading
Loading