(****************************************************************** [LibNN - Neural Networks Library] http://libnn.org Copyright (C) 2002 - 2003 LAGACHERIE Matthieu RICORDEAU Olivier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. SPECIAL NOTE (the beerware clause): This software is free software. However, it also falls under the beerware special category. That is, if you find this software useful, or use it every day, or want to grant us for our modest contribution to the free software community, feel free to send us a beer from one of your local brewery. Our preference goes to Belgium abbey beers and irish stout (Guiness for strength!), but we like to try new stuffs. Authors: LAGACHERIE Matthieu Paper mail : 7 rue Delescluzes 94280 LE KREMLIN BICETRE, FRANCE E-mail : matthieu@libnn.org RICORDEAU Olivier Paper mail : 69 avenue d'Italie 75013 PARIS, FRANCE E-mail : olivier@libnn.org *****************************************************************) (** The Env class. Stores LibNN's environment information. @author Matthieu Lagacherie @author Olivier Ricordeau @since 06/08/2003 This class uses the Singleton design pattern in order to provide only one instance of the environment class. The aim is to provide information about the learning environment to the various objects involved in LibNN. //FIXME explain how to use the getEnv method in other classes. @see A PDF document about Design Patterns and OCaml. *) class type environmentType = object (** Displays a string on _channel. *) method toChannel : string -> unit (** A set*. Sets the verbosity level in LibNN. //FIXME Make a detailed description of what each verbosity level (i.e. value of the int) is supposed to do. *) method setVerbosity : int-> unit (** A set*. Sets the random limit for the weights generation *) method setRandLimit : float -> unit (** A get*. Gets the random limit for the weights generation *) method getRandLimit : float end (** The environment itself. *) class environment : environmentType = object (** The verbosity level. *) val mutable _verbosity = 0 (** The weights random generator limit. *) val mutable _randLimit = 2.0 (** The channel on which LibNN is supposed to display its information. *) val mutable _channel = stderr (** Displays a string on _channel. *) method toChannel str = Printf.fprintf _channel "%s\n" str (** Sets the current verbosity level. *) method setVerbosity newval = _verbosity <- newval (** Sets the current random limit. *) method setRandLimit newval = _randLimit <- newval (** Gets the current random limit. *) method getRandLimit = _randLimit end let env : environmentType option ref = ref None (** The function which provides a unique instance on the environment to the various objects in LibNN. *) let getEnv() : environmentType = match !env with None -> let result = new environment in env := Some result; result | Some result -> result