After a long, self-standing dominance of Newtonian reductionism, at the beginning of the nineteenth century, with the birth of thermodynamics, a new approach began to develop to the study of nature. Indeed, the prediction of the behaviour of a macroscopic material through the knowledge of all the Newtonian trajectories of the molecules composing it was an impossible task because of the insurmountable difficulty of computing them for any initial condition in a time shorter than the age of the universe. Besides this, the computation itself was realized as unfruitful and senseless since, whatever the initial conditions of all the trajectories can be, a macroscopic system always behaves in the same way if subject to the same external physical conditions. Another conceptual approach was requested to overcome such a stalemate: physical phenomena began to be analyzed in the viewpoint of statistical mechanics. Not only were the techniques different, but also the questions to be answered changed. The (hopeless) hunt for the behaviour of every single microscopic component of a system was substituted by the analysis of the statistical ensemble of the configurations in which the system can find itself and by the computation of the average values of the relevant, thermodynamic, observables on such an ensemble. A similar kind of (r)evolution, with a new change of paradigm, is now occurring in physics once again: the shift from statistical mechanics to the theory of complex systems. In a hopefully effective attempt to give a concise explanation, we like the definition of complex systems as those systems ``whose behaviour crucially depends on its details'' \cite{PCM02}. To study such systems, the standard tools of statistical mechanics are not sufficient anymore and new techniques need to be developed. In statistical mechanics, for large systems, what matters is the average of the significant observables and the theory tries to predict its value. For what concerns complex systems, instead, since they are very sensitive to the initial conditions, the maximum information we can get is the probability distribution of all possible behaviours. The main issue is a change of paradigm in predicting the physical properties of a system. Indeed, in this kind of approach, it makes no sense to look at the behaviour of a particular system. Rather, the aim becomes to obtain the general features of the statistical class of systems to which the probed one belongs. The class being characterized by a given probability distribution of possible realizations, where a single realization (i.e., one system) unpredictably depends on the initial conditions. The approach to complex problems is therefore typically a probabilistic one. Hence, the ``complexity'' of the system can be viewed, as the information we would need (but we are not able to obtain) in order to give a complete explanation of the behaviour of one system. The more a system is sensitive to its initial condition, the higher is its complexity and the more difficult it becomes to carefully outline a typical behaviour. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% In our thesis we have considered, in different ways and with different degrees of approximation, a number of topics related to the theory of complex systems. We have been analyzing aspects of glasses, spin glasses and of the optimization problem known as {\em K-SAT problem}. Depending on the specific case we have applied different statistical mechanics techniques, both analytical and numerical. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The study of glass forming materials has been the object of active scientific interest for over half a century, and yet, in spite of the huge amount of accumulated knowledge there is still much to be understood on the nature of the glass phase and on its formation \cite{McKenna89,ASci95,ANMcKMcMMAPR00,Donth01}. In particular, the quest for a satisfying, comprehensive, realistic theoretical model for the glass is still far from being accomplished, even if, in the theoretical field, many interesting and fascinating steps forward have been made in the last two decades. In order to study the mechanisms of glassy dynamics we have been following the approach of kinetically facilitated models. These models usually display a trivial static behaviour, showing, however, the characteristic slowing down of the dynamics occurring in glasses with its main characteristic: aging. Though the imposed separation between statics and dynamics takes us away from real systems, it allows us, anyway, to clarify which properties of the glass can be understood as consequence of the dynamics alone. The outcome is encouraging and, actually, all the basic qualitative features of glass formers can be reproduced by means of such models. Furthermore, using these models, it is also possible to verify the generalized thermodynamic theory of out of equilibrium phenomena, formulated by Nieuwenhuizen~\cite{NPRL97_1,NJPA98,NPRL98,NPRE00}, that could encode into the thermodynamic language the slow aging relaxation of the complex systems here considered. A basic concept to enable such translation is the {\em effective temperature}, as it has appeared in literature in many different ways since Tools formulation, in 1946. To analyze the robustness of such a concept, we have faced the study of a model of harmonic oscillators and spherical spins (HOSS model) evolving on two separated time scales, with a very simple statics and a facilitated, exactly solvable, Monte Carlo dynamics (chapter $3$). We considered two different dynamical versions: the first leading to an Arrhenius law for the relaxation time to equilibrium (strong glass HOSS model), the second one displaying a Vogel-Fulcher-Tammann-Hesse (VFTH) law (fragile glass HOSS model) and a Kauzmann transition, taking place at the VFTH temperature $T_0$, with true discontinuity of specific heat. Our goal was to check whether the chance existed of inserting the effective temperature, $T_e$, into the construction of a consistent out of equilibrium thermodynamic theory. Indeed, the possibility of computing an exact solution for the dynamics allows for a precise formulation of the two temperature picture, including $T_e$ besides the heat bath temperature $T$. Even though the physics of our model is simple, we have formulated general aspects of the results by analyzing them in the thermodynamic language. To a certain extent it is possible to obtain a thermodynamic theory for the aging regime, but this did not turn out to be a universal feature valid in every model for all allowed aging regimes. Another main motivation for the analysis of such a model was to get more insight in the various aspects of the glassy dynamics exploiting the analytical solubility of our model. Thanks to its simplicity, every detected feature of the glassy behaviour can be directly connected with given elements of the model. Certain properties can be even switched on and off tuning the model parameters or implementing the facilitated dynamics in alternative ways. The model we considered was intimately based on time scale separation between fast and slow processes. A direct consequence of this time scale separation is that we encountered a both mathematically and physically well defined configurational entropy, being a function of the dynamic variables of the model. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% We have, then, carried out the inherent structure approach on the HOSS model (Chap. $4$). Decreasing the temperature, the free energy local minima do not split into smaller local minima, just like, for instance, in the $p$-spin model in zero magnetic field \cite{CSJPI95}, because every allowed configuration of harmonic oscillators of the HOSS model is and remains an inherent structure at any temperature. Consequently we were able to set a one-to-one correspondence between the minima of the free energy and those of the potential energy (i.e. the inherent structures). Because of this exact correspondence the dynamics through inherent structures should have been a valid symbolic dynamics for the real system, i.e. at a finite heat-bath temperature $T$. Taking a system in equilibrium at an effective temperature $T_e^{\rm (is)}$, such that the configurations visited by the system at equilibrium are the same as those out of equilibrium at temperature $T$, we defined an effective temperature through the matching of the equilibrium and the out of equilibrium internal energy of the inherent structures (section 4.3.1). For the strong glass model this effective temperature coincides with the finite temperature $T_e$ at low temperature. On the contrary, for the fragile glass HOSS model, we found that this effective temperature was quite different from the effective temperature that we were able to identify in the finite $T$ dynamics. Even proposing a new definition, following a quasi static approach (section 4.3.2), and, thus, exploiting the solvability of the model, the so defined effective temperature was analytically different from the finite $T$ dynamics effective temperature. The inherent structure scheme for the study of dynamics can, then, only be view as an approximation (even if in particular cases a rather good one) of the realistic dynamics of the system. As a consequence, also the derivation of out of equilibrium thermodynamic quantities (e.g. the configurational entropy) obtained making use of this approach could suffer of a systematic deviation from the exact result. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% In chapter $5$ we have considered the disordered Backgammon model (DBG) in which each state is associated with a positive random energy, obtained from a distribution $g(\epsilon)$. When the distribution $g(\epsilon)=\delta(\epsilon-1)$ is chosen, the model is the standard Backgammon (BG) model~\cite{RPRL95}. The DBG model displays slow relaxation due to the presence of entropic barriers. The relaxation at $T=0$ of occupation probabilities $P_k$, $k=0, \ldots, N$ is exactly the same as the original BG model, and, in particular, independent of the disorder distribution $g(\epsilon)$. On the contrary, the relaxation of other observables, such as the energy, displays an asymptotic relaxation which depends on the statistical properties of $g(\epsilon)\sim \epsilon^\nu$ in the limit $\epsilon\to 0$. In the asymptotic long-time regime, relaxation takes place by diffusing particles among states with the lowest values of $\epsilon$. Therefore the asymptotic decay of the energy as well as the one of other observables only depends on the exponent $\nu$ which describes the limiting behavior $g(\epsilon)\to\epsilon^{\nu}$. The DBG model offers a scenario where there are two energy sectors separated by the energy scale $\epsilon^*$ which have very different physical properties. In the out of equilibrium regime entropic barriers are typically higher than the time dependent barrier at the threshold level $\epsilon^*$ and an effective temperature can be defined (it comes out to be $T_e\sim (\epsilon^\star)^{\nu+2}$). For $\epsilon>\epsilon^*$ barriers are lower and equilibrium is rapidly achieved. A method has been proposed to numerically determine the threshold energy scale $\epsilon^*$ by computing the general probability distribution of proposed energy changes in the Monte Carlo dynamics. Preliminary investigations in other glassy models show that this distribution provides a general way to determine the threshold scale $\epsilon^*$. Moreover it gives interesting information about fluctuations in the aging state although future work is still needed to understand better its full implications in our understanding of the aging regime. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% In chapter $6$ we have studied the thermodynamics of a tiling model built by Wang tiles, i.e. a system model with no built-in quenched disorder (unlike the disordered Backgammon model) but a disorder caused by a complex geometry. For this kind of system we have found evidence of a phase transition from a completely disordered phase, in which the tiles on the plane are completely uncorrelated between each other, to a phase in which they begin to present an organized, also if very complicated, structure and we have numerically identified an order parameter. Below the critical point the answer of the system to an external perturbation and the time autocorrelation function depend on the history of the system. The existence of such aging leads to a violation of the fluctuation-dissipation theorem in the low temperature phase. From the behaviour of the response function vs. the correlation function is not clear whether the model belongs to the class of systems showing domain growth or it is rather more similar to a spin glass in magnetic field. Indeed, for very long times (small values of the correlation function) the fluctuation-dissipation ratio goes eventually to zero and it cannot be excluded that the dynamics evolves through domains growth \cite{BPRL98}, even though in our case the nature of the domains of tiles should still be theoretically understood. Nevertheless for a very large interval of time the Fluctuation-Dissipation Ratio is continuously and slowly decreasing to zero like in a spin glass model \cite{MPRRJPA98,PRREPJB99}. Moreover, this is also the prediction we get by linking the dynamical results with the static ones, in the hypothesis of {\em stochastic stability}, making quite difficult the distinction between a domain growth dynamics, where the response function is constant in the aging regime, and a more complicated behaviour where even the response function also relaxes, though extremely slowly in comparison with the aging relaxation of the correlation function. The last two chapters have been dedicated to the study of two models exhibiting a spin glass phase from the static viewpoint instead that from a dynamic one. In chapter 7 we probed a {\em spin glass mean field} model, the Random Blume-Emery-Griffiths-Capel model, a spin glass lattice gas whose equilibrium low temperature phase is stable in the full replica symmetry breaking limit, i.e. it is a true spin glass phase (as opposed to the glass like phase displayed by the disordered mean-field models with discontinuous order parameter and dynamic transition). The interest of this model comes from the fact that it undergoes both a second order phase transition (for values of thermodynamic parameters above a certain critical point) and a true first order thermodynamic phase transition (below the critical point). To calculate the stable full replica symmetry breaking solution a new technique has been developed to solve the differential equations for the functional order parameters that we can obtain making use of the variational approach of Sommers and Dupont~\cite{SDJPC84,CRPRE02,CLCM}. Like in any gas-liquid transition a latent heat is involved in the transformation between paramagnet and spin glass below the tricritical point. Moreover, for a certain range of parameters (between the spinodal lines), no pure phase is achievable, not even as a metastable one, and the two phases coexist. The last chapter is dedicated to the 3-SAT problem, an optimization problem constituted by an ordered string of $N$ boolean variables (bits) that have to satisfy a certain number of conditions. Such conditions are made of three boolean numbers, each one associated with one of three indices referring to the position in the string of a randomly chosen bit. We performed the study of the RSB solution of the 3-SAT problem in the limit of many clauses, mapping it on a slightly diluted spin glass model with long-range random quenched interactions. The mapping to a statistical mechanics model was carried out introducing an artificial temperature and taking, in the end, the limit $T\to 0$, to recover the original model. The structure of the solutions to the problem is of the full RSB kind: in order to get a stable solution the replica symmetry has to be broken in a continuous way, similarly to the SK model (in external magnetic field). The full RSB structure holds down to the interesting limit of zero temperature. No phase transition is expected in the UNSAT phase, other than the SAT-UNSAT transition at zero temperature, driven by the ratio $\alpha$ between the number of clauses and the number of bits and occurring at $\alpha=\alpha_c\simeq 4.2$ Therefore we expect the same full RSB structure of solutions, as found for the over-constrained case ($\alpha \gg \alpha_c$), to hold also in the critical region. We presented the precise procedure to get the full RSB solution of a general class of models that, besides the over-constrained 3-SAT model, includes the SK model, the $p$-spin model and, more generally, models with any combination of $p$ interacting terms. As a consequence, the numerical code developed to solve the present model can be applied to the whole class of models without any relevant change, providing an efficient tool for the analysis of the structure of the solutions of a large number of spin models interacting via quenched random couplings. \begin{thebibliography}{99} \bibitem{PCM02} G. Parisi, {\em e-print} cond-mat/0205297. \bibitem{McKenna89} G.B. McKenna, in {\it Comprehensive Polymer Science 2: Polymer Properties}, C. Booth and C. Price, eds. (Pergamon, Oxford, 1989), p. 311. \bibitem{ASci95} Science {\bf 267} (1995). \bibitem{ANMcKMcMMAPR00} C.A. Angell, K.L. Ngai, G.B. McKenna, P.F. McMillian and S.W. Martin, J. App. Phys. {\bf{86}} (2002) 3113. \bibitem{Donth01} E. Donth: {\em The Glass Transition} (Springer, Berlin 2001). \bibitem{NPRL97_1} Th.M. Nieuwenhuizen, Phys. Rev. Lett. {\bf 78} (1997) 3491. \bibitem{NJPA98} Th.M. Nieuwenhuizen, J. Phys. A {\bf 31} (1998) L201. \bibitem{NPRL98} Th.M. Nieuwenhuizen, Phys. Rev. Lett. {\bf 80} (1998) 5580. \bibitem{NPRE00} Th.M. Nieuwenhuizen, Phys. Rev. E, {\bf 61} (2000) 267. \bibitem{CSJPI95} A. Crisanti and H.J. Sommers, J. Phys. I {\bf{5}} (1995) 805. \bibitem{RPRL95} F. Ritort, Phys. Rev. Lett. {\bf{75}} (1995) 1190. \bibitem{BPRL98} A. Barrat, Phys. Rev. Lett. {\bf 51} (1998) 3629. \bibitem{MPRRJPA98}E. Marinari, G. Parisi, F. Ricci-Tersenghi and J.J. Ruiz Lorenzo, J. Phys. A: Math. Gen. {\bf 31} (1998) 2611. \bibitem{PRREPJB99}G. Parisi, F. Ricci-Tersenghi and J.J. Ruiz Lorenzo, Eur. Phys. J. B {\bf{11}} (1999) 317. \bibitem{SDJPC84} H. J. Sommers, W. Dupont, J. Phys. C {\bf{17}} (1984) 5785. \bibitem{CRPRE02}A. Crisanti, T. Rizzo, Phys. Rev. E {\bf{65}} (2002) 046137. \bibitem{CLCM}A. Crisanti and L. Leuzzi, {\em e-print} cond-mat/0112362. To be published on Phys. Rev. Lett. 2002. \end{thebibliography}