/* Copyright (C) 1997,1998,1999,2000,2001 Franz Josef Och mkcls - a program for making word classes . 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. */ #include "IterOptimization.h" #include "ProblemTest.h" ostream *GraphOutput; IterOptimization::IterOptimization(Problem& p,int m) : maxNonBetterIterations(0),problem(p),maxStep(m),initialisiert(0) { } IterOptimization::IterOptimization(IterOptimization& o) : Optimization(),problem(o.problem) { maxNonBetterIterations=o.maxNonBetterIterations; curValue = o.curValue; bestStep = o.bestStep; bestValue = o.bestValue; maxStep = o.maxStep; initialisiert = o.initialisiert; endFlag = o.endFlag; endFlag2 = o.endFlag2; } double IterOptimization::minimize(int steps) { if( !initialisiert ) zInitialize(); if( steps==0 ) return curValue; int t=0; int every=(steps<0)?10000:(steps/1000+1); do { curStep++; t++; if(verboseMode&&(curStep%1000==0)) { if(steps>0) cout << "Processed: " << 100.0*(curStep/(double)max(maxStep,1)) << " percent. (IterOptimization run) " << curValue << " max:" << maxStep << " " << steps << " \r"; else cout << "In step:" << curStep << " currentValue: " << curValue << " bestValue: " << bestValue-curValue << " " << curStep-bestStep << ". \r"; cout.flush(); } ProblemChange *change= &(problem.change()); double delta=problem.valueChange(*change); abkuehlen(); if( accept(delta) ) { problem.doChange(*change); curValue+=delta; if( curValue1 ) cout<<"in step: "<maxNonBetterIterations && maxNonBetterIterations>0) endFlag=1; if(curStep - bestStep>2*maxNonBetterIterations && maxNonBetterIterations>0) endFlag2=1; if( GraphOutput&&((curStep%every)==0) ) { makeGraphOutput(); *GraphOutput<<" "<