@! ============================================================================ @! The CGAL Library @! Implementation: Basic Stuff for Optimisation Algorithms @! ---------------------------------------------------------------------------- @! file : web/Optimisation_basic.aw @! author: Sven Schönherr @! ---------------------------------------------------------------------------- @! $CGAL_Chapter: Geometric Optimisation $ @! $CGAL_Package: Optimisation_basic WIP $ @! $Id$ @! $Date$ @! ============================================================================ @documentclass[twoside]{article} @usepackage[latin1]{inputenc} @usepackage{a4wide2} @usepackage{amssymb} @usepackage{cc_manual,cc_manual_index} @article \input{cprog.sty} \setlength{\skip\footins}{3ex} \pagestyle{headings} @! LaTeX macros \newcommand{\remark}[2]{[\textbf{#1:} \emph{#2}]} \newcommand{\linebreakByHand}{\ccTexHtml{\linebreak[4]}{}} \newcommand{ \newlineByHand}{\ccTexHtml{\\}{}} \newcommand{\SaveSpaceByHand}{} %%%%% [2]{\ccTexHtml{#1}{#2}} \renewcommand{\sectionmark}[1]{\markboth{\uppercase{#1}}{}} @! ============================================================================ @! Title @! ============================================================================ \thispagestyle{empty} \RCSdef{\rcsRevision}{$Id$} \RCSdefDate{\rcsDate}{$Date$} \newcommand{\cgalWIP}{{\footnotesize{} (\rcsRevision{} , \rcsDate) }} @t vskip 20 mm @t title titlefont centre "Basic Stuff for" @t vskip 0 mm @t title titlefont centre "Optimisation Algorithms*" @t vskip 10 mm @t title smalltitlefont centre "Sven Schönherr" \begin{center} \textbf{ETH Z{\"u}rich} \end{center} @t vskip 10 mm {\small \begin{center} \begin{tabular}{l} \verb+$CGAL_Package: Optimisation_basic WIP+\cgalWIP\verb+$+ \\ \verb+$CGAL_Chapter: Geometric Optimisation $+ \\ \end{tabular} \end{center} } @t vskip 30 mm \renewcommand{\thefootnote}{\fnsymbol{footnote}} \footnotetext[1]{This work was supported by the ESPRIT IV LTR Projects No.~21957 (CGAL) and No.~28155 (GALIA), and by a grant from the Swiss Federal Office for Education and Sciences for the latter.} \renewcommand{\thefootnote}{\arabic{footnote}} @! -------- @! Abstract @! -------- \begin{abstract} We provide macros for checking assertions, pre- and postconditions and warnings, for encapsulating code for debugging, and a failure function for the checking functions of the optimisation algorithms. \end{abstract} @! -------- @! Contents @! -------- \clearpage \newlength{\defaultparskip} \setlength{\defaultparskip}{\parskip} \setlength{\parskip}{1ex} \tableofcontents \setlength{\parskip}{\defaultparskip} @! ============================================================================ @! Introduction @! ============================================================================ \clearpage \markright{\uppercase{Introduction}} \section{Introduction} We provide macros for checking assertions, pre- and postconditions and warnings, for encapsulating code for debugging, and a failure function for the checking functions of the optimisation algorithms. @! ============================================================================ @! Macros @! ============================================================================ \clearpage \section{Macros} @! ---------------------------------------------------------------------------- @! Checking @! ---------------------------------------------------------------------------- \subsection{Checking} The following macros are used to perform several checks. We distinguish four groups of checks, namely checking for assertions, for preconditions, for postconditions and for warnings. Each group consists of macros for normal checks, exactness checks, expensive checks, and expensive exactness checks. @macro(2) many = @begin @(@1,@2) @(@1,@2) @(@1,@2) @(@1,@2) @end @! ---------------------------------------------------------------------------- \subsubsection{Normal Checks} @macro(2) many = @begin #if ( defined( CGAL_OPTIMISATION_NO_@1S) \ || defined( CGAL_NO_@1S) || defined( NDEBUG)) # define CGAL_optimisation_@2(EX) ((void)0) # define CGAL_optimisation_@2_msg(EX,MSG) ((void)0) # define CGAL_optimisation_@2_code(CODE) # undef CGAL_OPTIMISATION_@1_TAG #else # define CGAL_optimisation_@2(EX) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,0)) # define CGAL_optimisation_@2_msg(EX,MSG) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,MSG)) # define CGAL_optimisation_@2_code(CODE) CODE # define CGAL_OPTIMISATION_@1_TAG 1 #endif // optimisation @2s @end @! ---------------------------------------------------------------------------- \subsubsection{Exactness Checks} @macro(2) many = @begin #if ( ! ( defined( CGAL_OPTIMISATION_CHECK_EXACTNESS) \ || defined( CGAL_CHECK_EXACTNESS) ) \ || defined( CGAL_OPTIMISATION_NO_@1S) \ || defined( CGAL_NO_@1S) || defined( NDEBUG)) # define CGAL_optimisation_exactness_@2(EX) ((void)0) # define CGAL_optimisation_exactness_@2_msg(EX,MSG) ((void)0) # define CGAL_optimisation_exactness_@2_code(CODE) # undef CGAL_OPTIMISATION_EXACTNESS_@1_TAG #else # define CGAL_optimisation_exactness_@2(EX) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,0)) # define CGAL_optimisation_exactness_@2_msg(EX,MSG) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,MSG)) # define CGAL_optimisation_exactness_@2_code(CODE) CODE # define CGAL_OPTIMISATION_EXACTNESS_@1_TAG 1 #endif // optimisation exactness @2s @end @! ---------------------------------------------------------------------------- \subsubsection{Expensive Checks} @macro(2) many = @begin #if ( ! ( defined( CGAL_OPTIMISATION_CHECK_EXPENSIVE) \ || defined( CGAL_CHECK_EXPENSIVE) ) \ || defined( CGAL_OPTIMISATION_NO_@1S) \ || defined( CGAL_NO_@1S) || defined( NDEBUG)) # define CGAL_optimisation_expensive_@2(EX) ((void)0) # define CGAL_optimisation_expensive_@2_msg(EX,MSG) ((void)0) # define CGAL_optimisation_expensive_@2_code(CODE) # undef CGAL_OPTIMISATION_EXPENSIVE_@1_TAG #else # define CGAL_optimisation_expensive_@2(EX) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,0)) # define CGAL_optimisation_expensive_@2_msg(EX,MSG) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,MSG)) # define CGAL_optimisation_expensive_@2_code(CODE) CODE # define CGAL_OPTIMISATION_EXPENSIVE_@1_TAG 1 #endif // optimisation expensive @2s @end @! ---------------------------------------------------------------------------- \subsubsection{Expensive Exactness Checks} @macro(2) many = @begin #if ( ! ( defined( CGAL_OPTIMISATION_CHECK_EXACTNESS) \ || defined( CGAL_OPTIMISATION_CHECK_EXPENSIVE) \ || defined( CGAL_CHECK_EXACTNESS) \ || defined( CGAL_CHECK_EXPENSIVE) ) \ || defined( CGAL_OPTIMISATION_NO_@1S) \ || defined( CGAL_NO_@1S) || defined( NDEBUG)) # define CGAL_optimisation_expensive_exactness_@2(EX) \ ((void)0) # define CGAL_optimisation_expensive_exactness_@2_msg(EX,MSG) \ ((void)0) # define CGAL_optimisation_expensive_exactness_@2_code(CODE) # undef CGAL_OPTIMISATION_EXPENSIVE_EXACTNESS_@1_TAG #else # define CGAL_optimisation_expensive_exactness_@2(EX) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,0)) # define CGAL_optimisation_expensive_exactness_@2_msg(EX,MSG) \ ((EX)?((void)0): ::CGAL::@2_fail( # EX ,__FILE__,__LINE__,MSG)) # define CGAL_optimisation_expensive_exactness_@2_code(CODE) CODE # define CGAL_OPTIMISATION_EXPENSIVE_EXACTNESS_@1_TAG 1 #endif // optimisation expensive exactness @2s @end @! ---------------------------------------------------------------------------- @! Debugging @! ---------------------------------------------------------------------------- \subsection{Debugging} The \ccc{CGAL_optimisation_debug} macro can be used to encapsulate code, that should not be compiled into the production version, e.g.~diagnose output. The following piece of code @macro zero = @begin CGAL_optimisation_debug { // do something } @end is expanded to @macro zero = @begin if ( 1) { // do something } @end in development versions, and to @macro zero = @begin if ( 0) { // do something } @end in production versions of the program. The latter will be discarded if compiled with the \ccc{-O} option. @macro = @begin #if ( defined( CGAL_OPTIMISATION_NO_DEBUG) \ || defined( CGAL_NO_DEGUG) || defined( NDEBUG)) # define CGAL_optimisation_debug if ( 0) #else # define CGAL_optimisation_debug if ( 1) #endif // optimisation debug @end @! ============================================================================ @! Functions @! ============================================================================ \section{Functions} @! ---------------------------------------------------------------------------- @! Function _optimisation_is_valid_fail @! ---------------------------------------------------------------------------- \subsection{Function \ccFont \_optimisation\_is\_valid\_fail} This function is called from the checking functions of the optimisation algorithms if a check fails. First, we declare the function. @macro = @begin bool _optimisation_is_valid_fail( CGAL::Verbose_ostream& verr, const char* message); @end The function prints a failure \ccc{message} to the \cgal\ verbose stream \ccc{verr}. @macro = @begin bool _optimisation_is_valid_fail( CGAL::Verbose_ostream& verr, const char* message) { verr << "FAILED." << std::endl; verr << " --> " << message << std::endl; verr << " object is NOT valid!" << std::endl; return( false); } @end @! ========================================================================== @! Files @! ========================================================================== \clearpage \section{Files} @i share/namespace.awi @! ---------------------------------------------------------------------------- @! assertions.h @! ---------------------------------------------------------------------------- \subsection{include/CGAL/Optimisation/assertions.h} @file = @begin @( "include/CGAL/Optimisation/assertions.h", "assertion macros for optimisation algorithms", "Geert-Jan Giezeman") #ifndef CGAL_OPTIMISATION_ASSERTIONS_H #define CGAL_OPTIMISATION_ASSERTIONS_H // macro definitions // ================= // assertions // ---------- @("ASSERTION","assertion") // preconditions // ------------- @("PRECONDITION","precondition") // postconditions // -------------- @("POSTCONDITION","postcondition") // warnings // -------- @("WARNING","warning") #endif // CGAL_OPTIMISATION_ASSERTIONS_H @ @end @! ---------------------------------------------------------------------------- @! debug.h @! ---------------------------------------------------------------------------- \subsection{include/CGAL/Optimisation/debug.h} @file = @begin @( "include/CGAL/Optimisation/debug.h", "debug macro for optimisation algorithms") #ifndef CGAL_OPTIMISATION_DEBUG_H #define CGAL_OPTIMISATION_DEBUG_H // macro definitions // ================= // debug // ----- @ #endif // CGAL_OPTIMISATION_DEBUG_H @ @end @! ---------------------------------------------------------------------------- @! basic.h @! ---------------------------------------------------------------------------- \subsection{include/CGAL/Optimisation/basic.h} @file = @begin @( "include/CGAL/Optimisation/basic.h", "basic things for optimisation algorithms") #ifndef CGAL_OPTIMISATION_BASIC_H #define CGAL_OPTIMISATION_BASIC_H // includes #ifndef CGAL_BASIC_H # include #endif #ifndef CGAL_OPTIMISATION_ASSERTIONS_H # include #endif #ifndef CGAL_OPTIMISATION_DEBUG_H # include #endif #ifndef CGAL_IO_VERBOSE_OSTREAM_H # include #endif @("CGAL") // Function declarations // ===================== // is_valid failure function // ------------------------- @ @("CGAL") #endif // CGAL_OPTIMISATION_BASIC_H @ @end @! ---------------------------------------------------------------------------- @! basic.C @! ---------------------------------------------------------------------------- \subsection{src/Optimisation/basic.C} @file = @begin @( "src/Optimisation/basic.C", "basic things for optimisation algorithms") #include @("CGAL") // Function implementations // ======================== // is_valid failure function // ------------------------- @ @("CGAL") @ @end @! ---------------------------------------------------------------------------- @! optimisation_Window_stream.h @! ---------------------------------------------------------------------------- \subsection{include/CGAL/IO/optimisation\_Window\_stream.h} @file = @begin @( "include/CGAL/IO/optimisation_Window_stream.h", "graphical output to window stream for optimisation algorithms") #include #include @ @end @! ---------------------------------------------------------------------------- @! File Header @! ---------------------------------------------------------------------------- \subsection*{File Header} @i share/file_header.awi And here come two specific file headers for the product files of this web file. @macro (2) many = @begin @ @(@1) @( "Optimisation_basic", "Geometric Optimisation", "Optimisation_basic", "$Id$","$Date$", "Sven Schönherr ", "ETH Zürich (Bernd Gärtner )", "@2") @end @macro (3) many = @begin @ @(@1) @( "Optimisation_basic", "Geometric Optimisation", "Optimisation_basic", "$Id$","$Date$", "@3, Sven Schönherr ", "ETH Zürich (Bernd Gärtner )", "@2") @end @! ===== EOF ==================================================================