@mark1russell7/packing 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/build/index.d.ts +218 -21
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2407 -24
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +25 -1
- package/src/layout-input.ts +11 -1
- package/src/portfolio-cell.ts +165 -0
- package/src/portfolio-sets.ts +2363 -0
- package/src/portfolio-strategy.ts +62 -0
- package/src/portfolio.ts +110 -0
- package/src/registry.ts +10 -3
package/README.md
CHANGED
|
@@ -60,6 +60,28 @@ pack(rects, outer, { strategy: "maxrects", rule: "cp" });
|
|
|
60
60
|
- The move of each rule other than `bl` counts a box when the rule chooses a place that `bl` does not choose.
|
|
61
61
|
- A shape that is not a rectangle gets bands. The option `bandHeight` sets their largest height. The default is the height divided by `MAXRECTS_BANDS`.
|
|
62
62
|
|
|
63
|
+
Since 0.2.6, `packPortfolio` packs an input with each member and keeps the best output. It is opt-in, and no default uses it.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const { output, winner } = packPortfolio(["skyline", "shelf"]).pick(input);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- The pick is `selectBest` of `@mark1russell7/layout-contract` on `PORTFOLIO_LEVELS`: the hard breaks, then `pack.overflow.excessArea`, then `pack.fill`.
|
|
70
|
+
- The trace of the output gets the stage `portfolio` with the measure `move.pick`.
|
|
71
|
+
- `outputHash` gives the hash of the placements of an output, as the bench records have it.
|
|
72
|
+
|
|
73
|
+
Since 0.2.7, the strategy `portfolio` packs an input with the set of its cell. It is opt-in, and no default uses it.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const output = packWith("portfolio", input); // the default member count of the cell
|
|
77
|
+
const cell = portfolioCell(input); // { shape: "rect", count: "100", spread: "uniform" }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- `portfolioCell` gives the container shape, the band of the item count and the band of the size spread.
|
|
81
|
+
- `PORTFOLIO_SETS` gives the sets of 1, 2 and 3 members of each cell. The bench records of one run gave them.
|
|
82
|
+
- Without options, the default member count of the cell runs. The output is a function of the input only.
|
|
83
|
+
- The option `k` (2 or 3) runs each member of the set of `k`. The option `budgetMs` is an opt-in time limit.
|
|
84
|
+
|
|
63
85
|
Both functions also work alone, in an outer rectangle with a width that you set. They do not change the width.
|
|
64
86
|
|
|
65
87
|
A `locked` rectangle keeps its position. `packSkyline` and `packShelf` put the other rectangles around it. `packRows` only keeps its position.
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContainerTest, ContainerTest as ContainerTest$1, DEFAULT_TOLERANCE, Direction, Direction as Direction$1, EPS, Item, Item as Item$1, LayoutContainer, LayoutContainer as LayoutContainer$1, LayoutEdge, LayoutEdge as LayoutEdge$1, LayoutGenerator, LayoutInput, LayoutInput as LayoutInput$1, Margin, MeasureSpec as MeasureSpec$1, Obstacle, PackHard, PackHard as PackHard$1, PackInput, PackOutput, Placement, Port, RECORD_EPS, Region, Side, Sides, Sides as Sides$1, StageTrace, Tolerance, checkInput, turnPoint, turnPort, turnRegion } from "@mark1russell7/layout-contract";
|
|
1
|
+
import { ContainerTest, ContainerTest as ContainerTest$1, DEFAULT_TOLERANCE, Direction, Direction as Direction$1, EPS, Item, Item as Item$1, LayoutContainer, LayoutContainer as LayoutContainer$1, LayoutEdge, LayoutEdge as LayoutEdge$1, LayoutGenerator, LayoutInput, LayoutInput as LayoutInput$1, Margin, MeasureSpec as MeasureSpec$1, MemberTrace, Obstacle, PackHard, PackHard as PackHard$1, PackInput, PackOutput, Placement, Port, Portfolio, Portfolio as Portfolio$1, PortfolioPick, PortfolioTrace, RECORD_EPS, Region, SelectLevel, SelectLevel as SelectLevel$1, Side, Sides, Sides as Sides$1, StageTrace, Tolerance, checkInput, turnPoint, turnPort, turnRegion } from "@mark1russell7/layout-contract";
|
|
2
2
|
/** A mutable two-dimensional vector. */
|
|
3
3
|
export declare class Vector {
|
|
4
4
|
#private;
|
|
@@ -750,36 +750,66 @@ export declare function fromRects<T>(rects: readonly Rect<T>[], outer: Rect<T>):
|
|
|
750
750
|
* each rectangle, and the free sides of the outer rectangle. It gives the outer rectangle.
|
|
751
751
|
*/
|
|
752
752
|
export declare function toRects<T>(output: PackOutput, rects: Rect<T>[], outer: Rect<T>): Rect<T>;
|
|
753
|
-
/** Each strategy of the package. The benchmark starts each one on each input of the corpus. */
|
|
753
|
+
/** Each single strategy of the package. The benchmark starts each one on each input of the corpus. */
|
|
754
754
|
export declare const strategies: readonly Strategy[];
|
|
755
|
-
/**
|
|
755
|
+
/**
|
|
756
|
+
* The composite strategies of the registry: each one packs an input with other strategies. They are not in `strategies`.
|
|
757
|
+
* Since 0.2.7, the list has `portfolio` of roadmap item k20.
|
|
758
|
+
*/
|
|
759
|
+
export declare const composites: readonly Strategy[];
|
|
760
|
+
/** This function gives the strategy with an id, also a composite strategy. It throws a `RangeError` for an id that the registry does not have. */
|
|
756
761
|
export declare function strategy(id: string): Strategy;
|
|
757
762
|
/**
|
|
758
763
|
* This function packs an input with the strategy of an id. The options go over the defaults of the strategy. The
|
|
759
764
|
* context gets `mulberry32` with the seed. The default seed is 0.
|
|
760
765
|
*/
|
|
761
766
|
export declare function packWith(id: string, input: PackInput, options?: unknown, seed?: number): PackOutput;
|
|
767
|
+
/** A member of `packPortfolio`: a strategy of the registry with some options. The id names the member in the trace. */
|
|
768
|
+
interface PortfolioEntry {
|
|
769
|
+
id: string;
|
|
770
|
+
/** The id of a strategy of the registry */
|
|
771
|
+
strategy: string;
|
|
772
|
+
/** The options of the member over the defaults of the strategy */
|
|
773
|
+
options?: unknown;
|
|
774
|
+
}
|
|
775
|
+
/** The options of `packPortfolio`. The time limit and the member limit are those of `portfolio` of the contract. */
|
|
776
|
+
interface PackPortfolioOptions {
|
|
777
|
+
/** The id of the portfolio. The default is `portfolio`. */
|
|
778
|
+
id?: string;
|
|
779
|
+
/** The seed of each member. The default is 0, as for `packWith`. */
|
|
780
|
+
seed?: number;
|
|
781
|
+
/** The time limit in milliseconds. Without it, each member runs. A cut member makes the pick not deterministic. */
|
|
782
|
+
budgetMs?: number;
|
|
783
|
+
/** The largest count of members that run */
|
|
784
|
+
maxMembers?: number;
|
|
785
|
+
/** The clock in milliseconds. The default is `performance.now`. */
|
|
786
|
+
now?: () => number;
|
|
787
|
+
}
|
|
788
|
+
/** The id of the trace stage of `packPortfolio`. Its measure `move.pick` is 1 when the pick is not member 0. */
|
|
789
|
+
export declare const PORTFOLIO_STAGE = "portfolio";
|
|
762
790
|
/**
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
* - `no-overlap`: each pair of items with their margins, and each pair of an item and an obstacle, that overlap by more than `tolerance.overlap`.
|
|
766
|
-
* - `in-container`: each item with its margin that goes out of a fixed side by more than `tolerance.overlap`. The inset of
|
|
767
|
-
* the container makes each fixed side smaller (decision 3 of `docs/PACKER.md`).
|
|
768
|
-
* - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no placement.
|
|
769
|
-
* - `complete`: each item with no placement that is not in the overflow. A locked item breaks `locked-kept` in its place.
|
|
791
|
+
* The levels of the pick of `packPortfolio` and of the portfolio report of the benchmark, in order. Level 0 is `hard`.
|
|
770
792
|
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
793
|
+
* - `hard`: the count of hard breaks of `checkHard` with `exactContainer`. Lower is better, with the minimum effect 0.
|
|
794
|
+
* - `pack.overflow.excessArea`: the overflow area above its bound. Lower is better.
|
|
795
|
+
* - `pack.fill`: the fill of the hull. Higher is better.
|
|
796
|
+
*/
|
|
797
|
+
export declare const PORTFOLIO_LEVELS: readonly SelectLevel$1[];
|
|
798
|
+
/** This function gives the count of the hard breaks of an output: the sum of `checkHard` with `exactContainer`. */
|
|
799
|
+
export declare function hardBreaks(input: PackInput, output: PackOutput): number;
|
|
800
|
+
/**
|
|
801
|
+
* This function makes an opt-in portfolio of strategies of the registry with `portfolio` of the contract.
|
|
802
|
+
* Its `pick(input)` packs the input with each member and gives the output of the winner, its id and the trace.
|
|
777
803
|
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
804
|
+
* - A member is a strategy id, or a `PortfolioEntry` with options. The members run in the given order.
|
|
805
|
+
* - `members` is a list, or a function of the input that gives the list. The strategy `portfolio` uses the function form.
|
|
806
|
+
* - The key is the hard breaks, then `pack.overflow.excessArea`, then `pack.fill`. `PORTFOLIO_LEVELS` gives the specs.
|
|
807
|
+
* - The hash of the key is `outputHash`. `selectBest` of the contract picks the winner.
|
|
808
|
+
* - The output of the winner gets the trace stage `portfolio` with `move.pick` of `pickMoves`.
|
|
809
|
+
* - The function throws a `RangeError` for an unknown strategy, an empty list and two members with the same id.
|
|
810
|
+
* With the function form, `pick` throws this error for the list of an input.
|
|
781
811
|
*/
|
|
782
|
-
export declare function
|
|
812
|
+
export declare function packPortfolio(members: readonly (string | PortfolioEntry)[] | ((input: PackInput) => readonly (string | PortfolioEntry)[]), options?: PackPortfolioOptions): Portfolio$1<PackInput, PackOutput>;
|
|
783
813
|
/** The parameters of a generator: a name and a string or a number for each parameter. */
|
|
784
814
|
type GeneratorParams = Record<string, string | number>;
|
|
785
815
|
/**
|
|
@@ -833,6 +863,12 @@ export declare function round3(x: number): number;
|
|
|
833
863
|
export declare function canonicalJson(value: unknown): string;
|
|
834
864
|
/** This function gives the hash of an input file: the first 16 hex characters of the SHA-256 of its canonical form without `hash`. */
|
|
835
865
|
export declare function hashInput(file: LayoutInput$1): string;
|
|
866
|
+
/**
|
|
867
|
+
* This function gives the `outputHash` of an output. It is the first 16 hex characters of the SHA-256 of the canonical form of
|
|
868
|
+
* its placements, sorted by id. The canonical form rounds each number with `round3`. Thus the order of the list does not count.
|
|
869
|
+
* The records of the benchmark and the key of `packPortfolio` use it. It is not `outputHash` of the contract, which uses a grid.
|
|
870
|
+
*/
|
|
871
|
+
export declare function outputHash(output: Pick<PackOutput, "placements">): string;
|
|
836
872
|
/** This function gives the scale of a count: the nearest of 1, 10, 100, 1000 and 10000 on a log scale. The count 0 gives `1`. */
|
|
837
873
|
export declare function countCell(count: number): CountScale;
|
|
838
874
|
/**
|
|
@@ -840,6 +876,167 @@ export declare function countCell(count: number): CountScale;
|
|
|
840
876
|
* A file without a container gets `{ fixed: "none" }`, so the packer picks the size. It is `toPackInput` of the contract.
|
|
841
877
|
*/
|
|
842
878
|
export declare function toPackInput(file: Pick<LayoutInput$1, "container" | "boxes" | "obstacles" | "gap">): PackInput;
|
|
879
|
+
/** The band of the size spread of the items of an input. */
|
|
880
|
+
type SpreadBand = "identical" | "uniform" | "heavyTail";
|
|
881
|
+
/** The cell of an input for the per-cell portfolio: the container shape, the band of the item count and the band of the size spread. */
|
|
882
|
+
interface PortfolioCell {
|
|
883
|
+
shape: DimensionValue<"containerShape">;
|
|
884
|
+
/** The band of the item count, as `countCell` gives it: `1`, `10`, `100`, `1k` or `10k`. */
|
|
885
|
+
count: CountScale;
|
|
886
|
+
spread: SpreadBand;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* The thresholds of the spread bands. The statistic is the standard deviation of the natural log of the linear size
|
|
890
|
+
* `sqrt(w * h)` of each item.
|
|
891
|
+
*
|
|
892
|
+
* - Below `identical`, the band is `identical`.
|
|
893
|
+
* - Below `uniform`, the band is `uniform`.
|
|
894
|
+
* - At `uniform` or above, the band is `heavyTail`.
|
|
895
|
+
*
|
|
896
|
+
* On the seeds 1 to 7 of the generators of `pack-screen-v1`, the uniform sizes give 0.258 at most. The heavy-tail sizes give 0.278 at least.
|
|
897
|
+
*/
|
|
898
|
+
export declare const SPREAD_THRESHOLDS: Readonly<{
|
|
899
|
+
identical: number;
|
|
900
|
+
uniform: number;
|
|
901
|
+
}>;
|
|
902
|
+
/** A cell with fewer inputs than this count in the training records is thin. It uses the set of its container shape. */
|
|
903
|
+
export declare const THIN_INPUTS = 12;
|
|
904
|
+
/**
|
|
905
|
+
* The frame budget of the default member count, in milliseconds. The default count of a cell is the largest prefix of its
|
|
906
|
+
* set of 3 that fits this budget. The prefix fits when its median summed member time on the CI records is this value or less.
|
|
907
|
+
* The count is 1 or more at all times.
|
|
908
|
+
* The default output thus does not depend on the clock: a time limit is only the opt-in option `budgetMs`.
|
|
909
|
+
*/
|
|
910
|
+
export declare const PORTFOLIO_FRAME_MS = 50;
|
|
911
|
+
/** This function gives the key of a cell: `<shape>/<count>/<spread>`, for example `rect/100/uniform`. */
|
|
912
|
+
export declare function cellKey(cell: PortfolioCell): string;
|
|
913
|
+
/**
|
|
914
|
+
* This function gives the spread statistic of an input: the standard deviation of the natural log of `sqrt(w * h)` of each item.
|
|
915
|
+
* An item with no area does not count. Fewer than 2 items with an area give 0.
|
|
916
|
+
*/
|
|
917
|
+
export declare function spreadOf(input: PackInput): number;
|
|
918
|
+
/** This function gives the band of a spread statistic by `SPREAD_THRESHOLDS`. */
|
|
919
|
+
export declare function spreadBand(spread: number): SpreadBand;
|
|
920
|
+
/**
|
|
921
|
+
* This function gives the cell of an input for the per-cell portfolio. The function reads only the input, not a corpus id.
|
|
922
|
+
*
|
|
923
|
+
* - `shape` is the `containerShape` of `cellOf`.
|
|
924
|
+
* - `count` is `countCell` of the count of the items.
|
|
925
|
+
* - `spread` is `spreadBand` of `spreadOf`.
|
|
926
|
+
*/
|
|
927
|
+
export declare function portfolioCell(input: PackInput): PortfolioCell;
|
|
928
|
+
/** The sizes of the sets of the table. */
|
|
929
|
+
type PortfolioSize = 1 | 2 | 3;
|
|
930
|
+
/** The score of a set on its training records. The regrets are means against the oracle of the pool. */
|
|
931
|
+
interface PortfolioTrainScore {
|
|
932
|
+
inputs: number;
|
|
933
|
+
/** The mean of the hard breaks of the winner of the set less those of the oracle */
|
|
934
|
+
hardRegret: number;
|
|
935
|
+
/** The mean of `pack.overflow.excessArea` of the winner of the set less that of the oracle */
|
|
936
|
+
excessAreaRegret: number;
|
|
937
|
+
/** The mean of `pack.fill` of the oracle less that of the winner of the set */
|
|
938
|
+
fillRegret: number;
|
|
939
|
+
/** The inputs where the winner of the set is in the last kept list of the oracle */
|
|
940
|
+
wins: number;
|
|
941
|
+
winShare: number;
|
|
942
|
+
/** The mean of the summed times of the members on an input, in milliseconds */
|
|
943
|
+
msMean: number;
|
|
944
|
+
}
|
|
945
|
+
/** The sets of one cell of the table, by size, with their training scores. */
|
|
946
|
+
interface PortfolioCellSets {
|
|
947
|
+
/** The inputs of the cell in the training records */
|
|
948
|
+
inputs: number;
|
|
949
|
+
/** The value `true` when `inputs` is less than `THIN_INPUTS`. A thin cell has no sets. It uses the sets of its shape. */
|
|
950
|
+
thin: boolean;
|
|
951
|
+
/** The ids of the members of each set, in the order of the pick. A thin cell has none. */
|
|
952
|
+
sets?: Readonly<Record<`${PortfolioSize}`, readonly string[]>>;
|
|
953
|
+
/** The training score of each set */
|
|
954
|
+
train?: Readonly<Record<`${PortfolioSize}`, PortfolioTrainScore>>;
|
|
955
|
+
/** The median over the inputs of the summed member times of each prefix of the set of 3, in milliseconds. A missing record counts 0. */
|
|
956
|
+
prefixMedianMs?: Readonly<Record<`${PortfolioSize}`, number>>;
|
|
957
|
+
/** The default member count: the largest prefix of the set of 3 with `prefixMedianMs` of `PORTFOLIO_FRAME_MS` or less, and 1 at least */
|
|
958
|
+
defaultMembers?: PortfolioSize;
|
|
959
|
+
}
|
|
960
|
+
/** The table of the per-cell portfolio. `bench/choose-sets.ts` generates it from the records of one run. */
|
|
961
|
+
interface PortfolioSets {
|
|
962
|
+
/** The run of the records: the corpus, the commit of the code and the id of the run of `bench.yml`. It also has the frame budget of the default counts. */
|
|
963
|
+
source: Readonly<{
|
|
964
|
+
corpus: string;
|
|
965
|
+
run: string;
|
|
966
|
+
commit: string;
|
|
967
|
+
inputs: number;
|
|
968
|
+
frameMs: number;
|
|
969
|
+
}>;
|
|
970
|
+
/** The member of each id: a strategy of the registry with some options */
|
|
971
|
+
entries: Readonly<Record<string, PortfolioEntry>>;
|
|
972
|
+
/** The sets of all the inputs. They are the fixed default of an input of an unknown shape. */
|
|
973
|
+
all: PortfolioCellSets;
|
|
974
|
+
/** The sets of each container shape. They are the fallback of a thin cell and of an unknown cell. */
|
|
975
|
+
shapes: Readonly<Record<string, PortfolioCellSets>>;
|
|
976
|
+
/** The sets of each cell, by `cellKey` */
|
|
977
|
+
cells: Readonly<Record<string, PortfolioCellSets>>;
|
|
978
|
+
}
|
|
979
|
+
/** The source of the members of an input in the table. */
|
|
980
|
+
type PortfolioSetSource = "cell" | "shape" | "default";
|
|
981
|
+
/** This function gives the sets of an input from a table: the sets of its cell, or of its shape, or of all the inputs. */
|
|
982
|
+
export declare function portfolioSetOf(input: PackInput, table?: PortfolioSets): {
|
|
983
|
+
key: string;
|
|
984
|
+
source: PortfolioSetSource;
|
|
985
|
+
sets: PortfolioCellSets;
|
|
986
|
+
};
|
|
987
|
+
/**
|
|
988
|
+
* This function gives the `k` members of an input for `packPortfolio`. The members are the set of the cell of the input.
|
|
989
|
+
* A thin cell or an unknown cell takes the set of its shape, or the set of all the inputs. The function throws a `RangeError` for a `k` other than 1, 2 or 3.
|
|
990
|
+
*/
|
|
991
|
+
export declare function portfolioMembers(input: PackInput, k: number, table?: PortfolioSets): PortfolioEntry[];
|
|
992
|
+
/**
|
|
993
|
+
* This function gives the default member count of an input: `defaultMembers` of the sets of its cell, its shape or all the inputs.
|
|
994
|
+
* With a `k`, the count is not more than `k`. A table without the count gives `k`, or 3 without a `k`.
|
|
995
|
+
*/
|
|
996
|
+
export declare function portfolioDefaultMembers(input: PackInput, k?: number, table?: PortfolioSets): number;
|
|
997
|
+
/** The table of the per-cell portfolio: the sets of 1, 2 and 3 members of each cell, with their training scores. The run 40652567756 gives it. */
|
|
998
|
+
export declare const PORTFOLIO_SETS: PortfolioSets;
|
|
999
|
+
/** The options of the strategy `portfolio`. Without options, the output is a function of the input only. */
|
|
1000
|
+
interface PortfolioStrategyOptions {
|
|
1001
|
+
/** The size of the set of the cell: 2 or 3. With `k`, each of the `k` members runs. Without `k`, the strategy uses the set of 3. */
|
|
1002
|
+
k?: 2 | 3;
|
|
1003
|
+
/** The largest count of the members that run. Without `k` and `maxMembers`, the count is `defaultMembers` of the cell. */
|
|
1004
|
+
maxMembers?: number;
|
|
1005
|
+
/** The opt-in time limit of `portfolio` of the contract, in milliseconds. It has no default. A cut member makes the result not deterministic. */
|
|
1006
|
+
budgetMs?: number;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* The strategy `portfolio`: `packPortfolio` with the function form `(input) => portfolioMembers(input, k)`. The seed of the context
|
|
1010
|
+
* goes to each member. Its supports are the union of the supports of the members.
|
|
1011
|
+
*
|
|
1012
|
+
* - Without `k` and `maxMembers`, the members are the set of 3 of the cell, and `maxMembers` is `defaultMembers` of the cell.
|
|
1013
|
+
* The default output thus does not depend on the clock.
|
|
1014
|
+
* - A member that does not support the cell of an input throws, and it does not win. When each member throws, the strategy throws the first error.
|
|
1015
|
+
* - The option `budgetMs` goes to `portfolio` of the contract. The first member always runs.
|
|
1016
|
+
* - The strategy throws a `RangeError` for a `k` other than 2 or 3.
|
|
1017
|
+
*/
|
|
1018
|
+
export declare const portfolioStrategy: Strategy<PortfolioStrategyOptions>;
|
|
1019
|
+
/**
|
|
1020
|
+
* This function counts the breaks of the 4 hard rules of the packer for an output.
|
|
1021
|
+
*
|
|
1022
|
+
* - `no-overlap`: each pair of items with their margins, and each pair of an item and an obstacle, that overlap by more than `tolerance.overlap`.
|
|
1023
|
+
* - `in-container`: each item with its margin that goes out of a fixed side by more than `tolerance.overlap`. The inset of
|
|
1024
|
+
* the container makes each fixed side smaller (decision 3 of `docs/PACKER.md`).
|
|
1025
|
+
* - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no placement.
|
|
1026
|
+
* - `complete`: each item with no placement that is not in the overflow. A locked item breaks `locked-kept` in its place.
|
|
1027
|
+
*
|
|
1028
|
+
* A locked item with no placement stays at its input position for `no-overlap` and `in-container`. A locked item with no
|
|
1029
|
+
* `x` or no `y` in the input is a bad input. The rules skip it, as `packHard` of the contract does. `checkInput` finds it.
|
|
1030
|
+
*
|
|
1031
|
+
* The test of an obstacle is exact: a circle, an ellipse and a polygon with holes count only their insides, as in `packHard`.
|
|
1032
|
+
* The rules read a shape of the container or of an item as its bounding box (decision 5). The bounding box of an item
|
|
1033
|
+
* shape is relative to the position of the item. The result has no tolerance in it.
|
|
1034
|
+
*
|
|
1035
|
+
* With `options.exactContainer`, a shaped container with the size `fixed` also uses its true outline for `in-container`.
|
|
1036
|
+
* A box then counts when `rectInRegion` of the contract tells that it is not in the shape, as in `packHard`.
|
|
1037
|
+
* For that test, the box grows by the inset and becomes smaller by `tolerance.overlap` on each side. The default is `false`.
|
|
1038
|
+
*/
|
|
1039
|
+
export declare function checkHard(input: PackInput, output: PackOutput, tolerance?: Pick<Tolerance, "overlap">, options?: ContainerTest$1): PackHard$1;
|
|
843
1040
|
/** A seeded generator of `layout-input/1` files. The same version, parameters and seed give the same file, byte for byte. */
|
|
844
1041
|
interface CorpusGenerator<P extends GeneratorParams = GeneratorParams> {
|
|
845
1042
|
/** The name. The file writes it in `generator.name`. */
|
|
@@ -952,5 +1149,5 @@ interface Corpus {
|
|
|
952
1149
|
* `RangeError` for an unknown generator, a different version or 2 inputs with the same id.
|
|
953
1150
|
*/
|
|
954
1151
|
export declare function corpus(name: string, specs: readonly CorpusSpec[]): Corpus;
|
|
955
|
-
export { type Cell, type ChangeMeasures, type ContainerTest, type Corpus, type CorpusCell, type CorpusEntry, type CorpusGenerator, type CorpusManifest, type CorpusSpec, type CountScale, DEFAULT_TOLERANCE, type Dimension, type DimensionValue, type Direction, EPS, type EdgeCase, type EdgeCaseParams, type FreeSpace, type FreeSpan, type FreeWidthOptions, type FreeWidthResult, type FreeWidthTry, type GeneratedInput, type GeneratorParams, type GeneratorStamp, type Item, type LayoutContainer, type LayoutEdge, type LayoutInput, type LayoutMeasures, type LayoutStrategyOptions, type Margin, type MaxRectsOptions, type MaxRectsRule, type MaxRectsStrategyOptions, type MeasureFamily, type MeasureId, type MeasureOptions, type MeasureSpec, type MetricsOptions, type Obstacle, type ObstacleLayout, type PackContext, type PackHard, type PackInput, type PackLayoutOptions, type PackOptions, type PackOutput, type PackingMetrics, type Placement, type Port, type PushOptions, type PushStrategyOptions, RECORD_EPS, type RectGridParams, type RectScatteredParams, type Region, type ShelfFit, type ShelfOptions, type Side, type Sides, type SizeDistribution, type SizeSearch, type SkylineOptions, type SortOrder, type SpaceRect, type StageTrace, type Strategy, type Supports, type Tolerance, type UiParams, checkInput, turnPoint, turnPort, turnRegion };
|
|
1152
|
+
export { type Cell, type ChangeMeasures, type ContainerTest, type Corpus, type CorpusCell, type CorpusEntry, type CorpusGenerator, type CorpusManifest, type CorpusSpec, type CountScale, DEFAULT_TOLERANCE, type Dimension, type DimensionValue, type Direction, EPS, type EdgeCase, type EdgeCaseParams, type FreeSpace, type FreeSpan, type FreeWidthOptions, type FreeWidthResult, type FreeWidthTry, type GeneratedInput, type GeneratorParams, type GeneratorStamp, type Item, type LayoutContainer, type LayoutEdge, type LayoutInput, type LayoutMeasures, type LayoutStrategyOptions, type Margin, type MaxRectsOptions, type MaxRectsRule, type MaxRectsStrategyOptions, type MeasureFamily, type MeasureId, type MeasureOptions, type MeasureSpec, type MemberTrace, type MetricsOptions, type Obstacle, type ObstacleLayout, type PackContext, type PackHard, type PackInput, type PackLayoutOptions, type PackOptions, type PackOutput, type PackPortfolioOptions, type PackingMetrics, type Placement, type Port, type Portfolio, type PortfolioCell, type PortfolioCellSets, type PortfolioEntry, type PortfolioPick, type PortfolioSetSource, type PortfolioSets, type PortfolioSize, type PortfolioStrategyOptions, type PortfolioTrace, type PortfolioTrainScore, type PushOptions, type PushStrategyOptions, RECORD_EPS, type RectGridParams, type RectScatteredParams, type Region, type SelectLevel, type ShelfFit, type ShelfOptions, type Side, type Sides, type SizeDistribution, type SizeSearch, type SkylineOptions, type SortOrder, type SpaceRect, type SpreadBand, type StageTrace, type Strategy, type Supports, type Tolerance, type UiParams, checkInput, turnPoint, turnPort, turnRegion };
|
|
956
1153
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["Item","Sides","ContractMeasureSpec","Direction","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["Item","Sides","ContractMeasureSpec","Direction","SelectLevel","Portfolio","LayoutContainer","LayoutEdge","LayoutInput","ContainerTest","PackHard"],"sources":["../src/vector.ts","../src/rect.ts","../src/order.ts","../src/contract.ts","../src/space.ts","../src/maxrects.ts","../src/shelf.ts","../src/pack.ts","../src/skyline.ts","../src/free.ts","../src/push.ts","../src/metrics.ts","../src/measures.ts","../src/strategy.ts","../src/adapters.ts","../src/convert.ts","../src/registry.ts","../src/portfolio.ts","../src/layout-input.ts","../src/portfolio-cell.ts","../src/portfolio-sets.ts","../src/portfolio-strategy.ts","../src/check.ts","../src/generators.ts","../src/corpus.ts"],"mappings":";;qBACa;;EAIX,YAAY,YAAO;;MAMf;MACA,EAAE;;MAEF;MACA,EAAE;;EAGN,IAAI,WAAW;;EAMf,MAAM,GAAG;;EAMT,IAAI,OAAO,SAAS;;EAKpB;;EAKA,SAAS;;EAKT,MAAM,KAAK,QAAQ,KAAK,SAAS;;SAQ1B,GAAG,iBAAiB;;SAKpB,IAAI,SAAS,WAAW;;SASxB,IAAI,SAAS,WAAW;;aASpB,YAAY;;;qBCxEZ,KAAK;;;EAKhB,KAAK;;EAEL;;EAEA;;EAEA;;;;;EAKA;;MAGI,YAAY;;MAEZ,QAAQ;;EAGZ;;EAEA;;EAGA,WAAW;;EAOX,YAAY,QAAQ;;EAMpB;;SAGO,OAAO,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKlC,SAAS,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKpC,YAAY,GAAG,OAA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