FD.io VPP  v16.06
Vector Packet Processing
anneal.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2011 Cisco and/or its affiliates.
3 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16 
17 #ifndef __included_anneal_h__
18 #define __included_anneal_h__
19 
20 #include <vppinfra/clib.h>
21 #include <vppinfra/format.h>
22 #include <vppinfra/random.h>
23 #include <math.h>
24 
25 typedef struct {
26  /* Initial temperature */
28 
29  /* Temperature fraction at each step, 0.95 is reasonable */
31 
32  /* Number of temperatures used */
34 
35  /* Number of configurations tried at each temperature */
37 
39 #define CLIB_ANNEAL_VERBOSE (1<<0)
40 #define CLIB_ANNEAL_MINIMIZE (1<<1) /* mutually exclusive */
41 #define CLIB_ANNEAL_MAXIMIZE (1<<2) /* mutually exclusive */
42 
43  /* Random number seed, set to ensure repeatable results */
45 
46  /* Opaque data passed to callbacks */
47  void * opaque;
48 
49  /* Final temperature (output) */
51 
52  /* Final metric (output) */
54 
55  /* Suggested initial temperature (output) */
57 
58 
59  /*--- Callbacks ---*/
60 
61  /* objective function to minimize */
62  f64 (*anneal_metric)(void * opaque);
63 
64  /* Generate a new configuration */
65  void (*anneal_new_configuration)(void * opaque);
66 
67  /* Restore the previous configuration */
68  void (*anneal_restore_previous_configuration)(void * opaque);
69 
70  /* Save best configuration found e.g at a certain temperature */
71  void (*anneal_save_best_configuration) (void * opaque);
72 
73  /* restore best configuration found e.g at a certain temperature */
74  void (*anneal_restore_best_configuration) (void * opaque);
75 
77 
79 
80 #endif /* __included_anneal_h__ */
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
u32 number_of_configurations_per_temperature
Definition: anneal.h:36
u32 number_of_temperatures
Definition: anneal.h:33
f64 temperature_step
Definition: anneal.h:30
void clib_anneal(clib_anneal_param_t *p)
Definition: anneal.c:52
f64 final_temperature
Definition: anneal.h:50
f64 initial_temperature
Definition: anneal.h:27
f64 suggested_initial_temperature
Definition: anneal.h:56
unsigned int u32
Definition: types.h:88
double f64
Definition: types.h:140
Linear Congruential Random Number Generator.