xerus
a general purpose tensor library
contractionHeuristic.h
Go to the documentation of this file.
1 // Xerus - A General Purpose Tensor Library
2 // Copyright (C) 2014-2017 Benjamin Huber and Sebastian Wolf.
3 //
4 // Xerus is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as published
6 // by the Free Software Foundation, either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // Xerus is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
13 //
14 // You should have received a copy of the GNU Affero General Public License
15 // along with Xerus. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // For further information on Xerus visit https://libXerus.org
18 // or contact us at contact@libXerus.org.
19 
25 #pragma once
26 
27 #include <vector>
28 
29 #include "basic.h"
30 
31 namespace xerus {
32  class TensorNetwork;
33 
34  namespace internal {
35  typedef void (*ContractionHeuristic)(double &, std::vector<std::pair<size_t,size_t>> &, TensorNetwork);
36 
37  template<double (*scoreFct)(double, double, double, double, double)>
38  void greedy_heuristic(double &_bestCost, std::vector<std::pair<size_t,size_t>> &_contractions, TensorNetwork _network);
39 
40  double contraction_cost(double _m, double _n, double _r, double _sparsity1, double _sparsity2);
41 
42  double score_size(double _m, double _n, double _r, double _sparsity1, double _sparsity2);
43  double score_mn(double _m, double _n, double _r, double _sparsity1, double _sparsity2);
44  double score_speed(double _m, double _n, double _r, double _sparsity1, double _sparsity2);
45  double score_r(double _m, double _n, double _r, double _sparsity1, double _sparsity2);
46  double score_big_tensor(double _m, double _n, double _r, double _sparsity1, double _sparsity2);
47  double score_littlestep(double _m, double _n, double _r, double _sparsity1, double _sparsity2);
48 
49 
50  void greedy_best_of_three_heuristic(double &_bestCost, std::vector<std::pair<size_t,size_t>> &_contractions, TensorNetwork _network);
51  void exchange_heuristic(double &_bestCost, std::vector<std::pair<size_t,size_t>> &_contractions, TensorNetwork _network);
52 
53  extern const std::vector<ContractionHeuristic> contractionHeuristics;
54  }
55 }
double score_littlestep(double _m, double _n, double _r, double _sparsity1, double _sparsity2)
const std::vector< ContractionHeuristic > contractionHeuristics
Very general class used to represent arbitary tensor networks.
Definition: tensorNetwork.h:42
void greedy_best_of_three_heuristic(double &_bestCost, std::vector< std::pair< size_t, size_t >> &_contractions, TensorNetwork _network)
double contraction_cost(double _m, double _n, double _r, double _sparsity1, double _sparsity2)
The main namespace of xerus.
Definition: basic.h:37
double score_mn(double _m, double _n, double _r, double _sparsity1, double _sparsity2)
void exchange_heuristic(double &_bestCost, std::vector< std::pair< size_t, size_t >> &_contractions, TensorNetwork _network)
void(* ContractionHeuristic)(double &, std::vector< std::pair< size_t, size_t >> &, TensorNetwork)
void greedy_heuristic(double &_bestCost, std::vector< std::pair< size_t, size_t >> &_contractions, TensorNetwork _network)
Header file for shorthand notations that are xerus specific but used throughout the library...
double score_big_tensor(double _m, double _n, double _r, double _sparsity1, double _sparsity2)
double score_r(double _m, double _n, double _r, double _sparsity1, double _sparsity2)
double score_size(double _m, double _n, double _r, double _sparsity1, double _sparsity2)
double score_speed(double _m, double _n, double _r, double _sparsity1, double _sparsity2)