13 #ifndef FAISS_POLYSEMOUS_TRAINING_INCLUDED
14 #define FAISS_POLYSEMOUS_TRAINING_INCLUDED
17 #include "ProductQuantizer.h"
29 double init_temperature;
30 double temperature_decay;
49 virtual double compute_cost (
const int *perm)
const = 0;
53 virtual double cost_update (
const int *perm,
int iw,
int jw)
const;
61 double dis_weight_factor;
63 static double sqr (
double x) {
return x * x; }
67 double dis_weight (
double x)
const;
73 double get_source_dis (
int i,
int j)
const;
76 virtual double compute_cost (
const int *perm)
const override;
80 virtual double cost_update (
const int *perm,
int iw,
int jw)
const override;
84 const double *source_dis_in,
85 const double *target_dis_in,
86 double dis_weight_factor);
88 static void compute_mean_stdev (
const double *tab,
size_t n2,
89 double *mean_out,
double *stddev_out);
91 void set_affine_target_dis (
const double *source_dis_in);
97 struct RandomGenerator;
115 double optimize (
int *perm);
118 double run_optimization (
int * best_perm);
139 int ntrain_permutation;
140 double dis_weight_factor;
143 std::string log_pattern;
151 size_t n,
const float *x)
const;
random generator that can be used in multithreaded contexts
same as _2, but use rank of y+ - rank of y-
SimulatedAnnealingOptimizer(PermutationObjective *obj, const SimulatedAnnealingParameters &p)
logs values of the cost function
int n
size of the permutation
const double * target_dis
wanted distances (size n^2)
double init_cost
remember intial cost of optimization
void optimize_ranking(ProductQuantizer &pq, size_t n, const float *x) const
called by optimize_pq_for_hamming
optimizes the order of indices in a ProductQuantizer
std::vector< double > weights
weights for each distance (size n^2)
parameters used for the simulated annealing method
abstract class for the loss function
std::vector< double > source_dis
"real" corrected distances (size n^2)
void optimize_reproduce_distances(ProductQuantizer &pq) const
called by optimize_pq_for_hamming
void optimize_pq_for_hamming(ProductQuantizer &pq, size_t n, const float *x) const
Simulated annealing optimization algorithm for permutations.