SiGraph: sulcal graphs


anneal.h
Go to the documentation of this file.
1
2#ifndef SI_GRAPH_ANNEALING_H
3#define SI_GRAPH_ANNEALING_H
4
5#include <string>
6#include <vector>
7#include <si/graph/clique.h>
8
9class Vertex;
10
11namespace sigraph
12{
13 class CGraph;
14 class MGraph;
15 class AnnealExtension;
16 class SGProvider;
17
22 {
24 EnergyField( const EnergyField & ef );
25
27 std::vector<Vertex*> vertices;
29 std::vector<std::string> labels;
31 std::map<Clique*, double> involvedCliques;
33 double energy;
35 double expEnergy;
40 };
41
42 // inline
43
44
46 {
47 }
48
59
60
122 class Anneal
123 {
124 public:
138
148
158
166
167 Anneal( CGraph & cg, MGraph & rg );
168 virtual ~Anneal();
169
197 void init( Mode mode, double temp, double tmult, double tICM,
198 double stopProp, unsigned gibbsMaxTrans, bool verbose = true,
199 IterType itType = VERTEX,
200 InitLabelsType voidInitialLabels = INITLABELS_RANDOM,
201 const std::string & voidLabel = "",
202 std::ostream *plotStream = 0,
203 unsigned niterBelowStopProp = 1 );
210 void setVoidMode( VoidMode mode, unsigned occurency = 0 );
212 void addExtension( AnnealExtension* ae, unsigned occurency = 20 );
214 void clear();
216 void reset();
218 void checkStop();
220 void fitStep();
222 void fit();
226 void stepGibbs();
228 void stepICM();
231 void stepVoid();
236 void processPotentials( const std::set<Vertex *> & vertices,
237 std::vector<EnergyField> & en );
244
247
248 const CGraph & cGraph() const { return( _cgraph ); }
249 CGraph & cGraph() { return( _cgraph ); }
251 const MGraph & rGraph() const { return( _mgraph ); }
252 MGraph & rGraph() { return( _mgraph ); }
254 Mode modeI() const { return( _modeI ); }
256 Mode mode() const { return( _mode ); }
258 double tempI() const { return( _tempI ); }
260 double temp() const { return( _temp ); }
262 bool isFinished() const { return( _finished ); }
264 double tMult() const { return( _tmult ); }
266 double tICM() const { return( _tICM ); }
269 double stopProp() const { return( _stopProp ); }
271 unsigned nTrans() const { return( _ntrans ); }
273 unsigned maxTrans() const { return( _maxtrans ); }
276 unsigned gibbsMaxTrans() const { return( _gibbsMaxTrans ); }
278 double deltaE() const { return( _deltaE ); }
280 double stepDeltaE() const { return( _stepDeltaE ); }
281 double initialEnergy() const { return( _initEnergy ); }
282 double energy() const { return( _initEnergy + _deltaE ); }
284 bool verbosity() const { return( _verbose ); }
285 IterType iterType() const { return( _iterType ); }
287 unsigned nIter() const { return( _niter ); }
290 bool doubleDrawingLots() const { return( _doubleDrawingLots ); }
292 const std::string & voidLabel() const { return( _voidLabel ); }
305 void setAllowThreads( bool );
306 bool threadsAllowed() const;
307 void setMaxIterations( unsigned n );
312 unsigned maxIterations() const;
316 unsigned MPMUnrecordedIterations() const;
317 void setMPMUnrecordedIterations( unsigned n );
319
320 protected:
330 double _tempI;
332 double _temp;
334 double _tmult;
335 double _tICM;
336 double _stopProp;
337 unsigned _ntrans;
338 unsigned _maxtrans;
341 double _deltaE;
346 unsigned _niter;
347 std::ostream *_plotStream;
349 std::string _voidLabel;
352 std::vector<AnnealExtension *> _annealExtensions;
357
358 private:
359 struct Private;
360 Private *d;
361
375 void processNodes( const std::set<Vertex *> & ver, std::vector<EnergyField> & ef,
376 bool* npos, unsigned first, unsigned nn,
377 std::string* orLab );
387 void processConfig( const std::set<Vertex *> & ver,
388 std::vector<EnergyField> & ef,
389 bool* npos, std::string* orLab );
390 };
391
392}
393
394#endif
395
396
Extensions au recuit simulé.
const std::string & voidLabel() const
Definition anneal.h:292
void stepMetropolis()
Effectue une passe en mode Métropolis.
virtual ~Anneal()
unsigned gibbsMaxTrans() const
Nombre max.
Definition anneal.h:276
unsigned _niter
Definition anneal.h:346
@ VERTEX
Itération noeud par noeud, ordre aléatoire.
Definition anneal.h:142
@ CUSTOM
Itération sur d'autres groupes de noeuds (je verrai + tard)
Definition anneal.h:146
@ CLIQUE
Itération clique par clique, ordre aléatoire.
Definition anneal.h:144
CGraph & _cgraph
Graphe à étiqueter.
Definition anneal.h:322
CGraph & cGraph()
Definition anneal.h:249
double stepDeltaE() const
Variation d'énergie du graphe à la dernière passe.
Definition anneal.h:280
void reset()
Revient aux conditions initiales.
void checkStop()
Teste le critère d'arrêt et fixe l'état correspondant.
unsigned MPMUnrecordedIterations() const
Number of MPM steps before labels stats are recorded.
void setMaxIterations(unsigned n)
@ INITLABELS_NONE
Pas d'initialisation des labels: prendre ceux qui y sont déjà
Definition anneal.h:162
Mode modeI() const
Mode de recuit initial.
Definition anneal.h:254
unsigned maxIterations() const
Maximum number of iterations before switching to next mode.
unsigned _ntrans
Definition anneal.h:337
double _stopProp
Definition anneal.h:336
double temp() const
Température courante.
Definition anneal.h:260
unsigned nTrans() const
Nombre de transformations acceptées au cours de la dernière passe.
Definition anneal.h:271
double processAllPotentials()
Calcule les potentiels de toutes les cliques.
Mode _mode
Mode courant.
Definition anneal.h:328
unsigned _niterBelowStopProp
Definition anneal.h:355
void deleteExtensions()
std::string _voidLabel
Definition anneal.h:349
double tICM() const
Température de passage en ICM.
Definition anneal.h:266
double _tmult
Definition anneal.h:334
double _tempI
Température initiale.
Definition anneal.h:330
bool _doubleDrawingLots
Definition anneal.h:354
void fitStep()
Effectue une passe de recuit.
@ VOIDMODE_NONE
Pas de mode void.
Definition anneal.h:152
@ VOIDMODE_STOCHASTIC
Mode stochastique.
Definition anneal.h:156
@ VOIDMODE_REGULAR
Mode régulier.
Definition anneal.h:154
double _tICM
Definition anneal.h:335
void stepGibbs()
Effectue une passe en mode Gibbs Sampler.
MGraph & _mgraph
Graphe modèle.
Definition anneal.h:324
unsigned _currentNiterBelowStopProp
Definition anneal.h:356
double energy() const
Definition anneal.h:282
void init(Mode mode, double temp, double tmult, double tICM, double stopProp, unsigned gibbsMaxTrans, bool verbose=true, IterType itType=VERTEX, InitLabelsType voidInitialLabels=INITLABELS_RANDOM, const std::string &voidLabel="", std::ostream *plotStream=0, unsigned niterBelowStopProp=1)
Fixe l'état initial.
unsigned _maxtrans
Definition anneal.h:338
unsigned maxTrans() const
Nombre de transformations proposées au cours de la dernière passe.
Definition anneal.h:273
IterType iterType() const
Definition anneal.h:285
double initialEnergy() const
Definition anneal.h:281
bool doubleDrawingLots() const
Dit si on est en mode DoubleTirage, technologie © JeffProd'00, pour les passes void et extensions.
Definition anneal.h:290
Mode mode() const
Mode courant.
Definition anneal.h:256
const MGraph & rGraph() const
Graphe modèle.
Definition anneal.h:251
double _temp
Température courante.
Definition anneal.h:332
void setVoidMode(VoidMode mode, unsigned occurency=0)
Mode "void": essais de configs où tous les labels sont remplacés par void.
void setAllowThreads(bool)
enables or disables the use of multiple threads during annealing.
double stopProp() const
Proportion de transformations acceptées en dessous de laquelle on arrête le recuit.
Definition anneal.h:269
void processPotentials(const std::set< Vertex * > &vertices, std::vector< EnergyField > &en)
Calcule les différentes énergies des transitions possibles d'un groupe de noeuds, en Gibbs Sampler ou...
@ ICM
ICM (déterministe)
Definition anneal.h:132
@ METROPOLIS
Algorithme original de Métropolis.
Definition anneal.h:128
@ GIBBS
Gibbs Sampler.
Definition anneal.h:130
@ MPM
MPM (Maximum Posterior Marginal)
Definition anneal.h:134
@ SPECIAL
Internal mode.
Definition anneal.h:136
double _initEnergy
Definition anneal.h:342
void clear()
Libère les structures allouées dans les graphes.
double _deltaE
Definition anneal.h:341
MGraph & rGraph()
Definition anneal.h:252
unsigned _extensionPassOccurency
Definition anneal.h:353
void addExtension(AnnealExtension *ae, unsigned occurency=20)
InitLabelsType _initialLabelsType
Definition anneal.h:348
bool threadsAllowed() const
void stepVoid()
Effectue une passe en mode Void (essais de configs ou tout un label est enlevé)
double deltaE() const
Variation d'énergie du graphe depuis le début du recuit.
Definition anneal.h:278
const CGraph & cGraph() const
Graphe à étiqueter.
Definition anneal.h:248
double _stepDeltaE
Definition anneal.h:340
Mode _modeI
Mode initial.
Definition anneal.h:326
void setMPMUnrecordedIterations(unsigned n)
void setDoubleDrawingLots(bool t)
Definition anneal.h:291
std::ostream * _plotStream
Definition anneal.h:347
SGProvider * _sgProvider
Definition anneal.h:345
Anneal(CGraph &cg, MGraph &rg)
IterType _iterType
Definition anneal.h:344
unsigned _gibbsMaxTrans
Definition anneal.h:339
std::vector< AnnealExtension * > _annealExtensions
Definition anneal.h:352
double tempI() const
Température initiale.
Definition anneal.h:258
unsigned _voidoccurency
Definition anneal.h:351
bool verbosity() const
dit si les affichages sont autorisés ou interdits
Definition anneal.h:284
unsigned nIter() const
Nb d'itérations de recuit effectuées.
Definition anneal.h:287
bool isFinished() const
Retourne true si le recuit est fini.
Definition anneal.h:262
void fit()
Effectue tout le recuit.
double tMult() const
Multiplicxateur de température.
Definition anneal.h:264
VoidMode _voidmode
Definition anneal.h:350
void stepICM()
Effectue une passe en mode ICM déterministe.
Graphes avec étiquettes et gestion de cliques (classe abstraite).
Definition cgraph.h:37
Graph modèle (classe abstraite).
Definition mgraph.h:48
Fabrique de sous-graphes.
Definition sgiterator.h:41
double energy
Modification d'énergie pour ces changements de labels.
Definition anneal.h:33
std::map< Clique *, double > involvedCliques
Cliques impliquées par ces noeuds, énergies recalculées correspondantes.
Definition anneal.h:31
std::vector< Vertex * > vertices
Noeuds dont on modifie les labels.
Definition anneal.h:27
double expEnergy
exp( - Denergy / temp )
Definition anneal.h:35
double probability
Probabilité de cette configuration.
Definition anneal.h:37
std::vector< std::string > labels
Labels choisis pour ces noeuds.
Definition anneal.h:29
double probabilitySum
Probabilité cummulée.
Definition anneal.h:39