|
16 | 16 |
|
17 | 17 | """
|
18 | 18 | $TYPEDEF
|
19 |
| - GenericTensorNetwork(problem::ConstraintSatisfactionProblem; openvertices=(), fixedvertices=Dict(), optimizer=GreedyMethod()) |
| 19 | + GenericTensorNetwork(problem::ConstraintSatisfactionProblem; openvertices=(), fixedvertices=Dict(), optimizer=GreedyMethod(), slicer=nothing) |
20 | 20 |
|
21 | 21 | The generic tensor network that generated from a [`ConstraintSatisfactionProblem`](@ref).
|
22 | 22 |
|
23 | 23 | Positional arguments
|
24 | 24 | -------------------------------
|
25 |
| -* `problem` is the graph problem. |
26 |
| -* `code` is the tensor network contraction code. |
27 |
| -* `fixedvertices` is a dictionary specifying the fixed dimensions. |
| 25 | +- `problem` is the constraint satisfaction problem. |
| 26 | +
|
| 27 | +Keyword arguments |
| 28 | +------------------------------- |
| 29 | +- `openvertices` is a vector of open indices, which are the degrees of freedoms that appears in the output tensor. |
| 30 | +- `fixedvertices` is a dictionary specifying the fixed degrees of freedom. For example, If I want to fix the variable `5` to be 0, I can set `fixedvertices = Dict(5 => 0)`. |
| 31 | +- `optimizer` is the contraction order optimizer for the generated tensor network. |
| 32 | +- `slicer` is the slicer for the tensor network, it can reduce the memory usage at the cost of computing time by slicing the tensor network. |
| 33 | +
|
| 34 | +For more information about contraction order optimization and slicing, please refer to the [OMEinsumContractionOrders documentation](https://tensorbfs.github.io/OMEinsumContractionOrders.jl/dev/). |
28 | 35 | """
|
29 | 36 | struct GenericTensorNetwork{CFG, CT, LT}
|
30 | 37 | problem::CFG
|
31 | 38 | code::CT
|
32 | 39 | fixedvertices::Dict{LT,Int}
|
33 | 40 | end
|
34 |
| -function GenericTensorNetwork(problem::ConstraintSatisfactionProblem; openvertices=(), fixedvertices=Dict(), optimizer=GreedyMethod()) |
| 41 | +function GenericTensorNetwork(problem::ConstraintSatisfactionProblem; openvertices=(), fixedvertices=Dict(), optimizer=GreedyMethod(), slicer=nothing) |
35 | 42 | rcode = rawcode(problem; openvertices)
|
36 |
| - code = _optimize_code(rcode, uniformsize_fix(rcode, num_flavors(problem), fixedvertices), optimizer, MergeVectors()) |
| 43 | + code = _optimize_code(rcode, uniformsize_fix(rcode, num_flavors(problem), fixedvertices), optimizer, MergeVectors(), slicer) |
37 | 44 | return GenericTensorNetwork(problem, code, Dict{labeltype(code),Int}(fixedvertices))
|
38 | 45 | end
|
39 | 46 | # a unified interface to optimize the contraction code
|
40 |
| -_optimize_code(code, size_dict, optimizer::Nothing, simplifier) = code |
41 |
| -_optimize_code(code, size_dict, optimizer, simplifier) = optimize_code(code, size_dict, optimizer, simplifier) |
| 47 | +_optimize_code(code, size_dict, optimizer::Nothing, simplifier, slicer) = code |
| 48 | +_optimize_code(code, size_dict, optimizer, simplifier, slicer) = optimize_code(code, size_dict, optimizer; simplifier, slicer) |
42 | 49 |
|
43 | 50 | function Base.show(io::IO, tn::GenericTensorNetwork)
|
44 | 51 | println(io, "$(typeof(tn))")
|
|
0 commit comments