/* 
 *      //\\
 *    ////\\\\	  Project Bayanihan
 *   o |.[].|o 
 *  -->|....|->-  Worldwide Volunteer Computing Using Java
 *  o o.o.o.o\<\  
 * -->->->->->-   Copyright 1999, Luis F. G. Sarmenta.
 *   <\<\<\<\<\   All rights reserved.
 * 
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * and disclaimer appear in all copies.
 *
 * LUIS F. G. SARMENTA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
 * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
 * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. LUIS F. G. SARMENTA
 * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT
 * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 * ----------------------------------------------------------------------------|
 */
package bayanihan.apps.ftsim;

import java.io.*;
import java.util.Enumeration;
import bayanihan.util.*;
import bayanihan.mixer.*;
import bayanihan.api.mw.*;
import bayanihan.api.mw.program.*;
import bayanihan.api.mw.data.*;
import bayanihan.api.mw.work.*;
import bayanihan.api.mw.watch.*;
import bayanihan.api.mw.request.*;
import bayanihan.api.mw.timed.*;
import bayanihan.api.mc.*;

public class MScanProg2 extends MScanProg
{
   //////////////////
   // Constructors //
   //////////////////
   
   public MScanProg2()
   {
      super();
   }
   
   ////////////////////
   // Initialization //
   ////////////////////
   
   public void parameterize( Params params )
   {
      super.parameterize( params );

      this.outFileName = "F2" + this.outFileName;
   }

   
   //////////////////////////////////////
   // Interface implementation methods //
   //////////////////////////////////////

   //////////////////
   // run() method //
   //////////////////
   
   public void run()
   {
      PrintStream out = this.createTextOutputFile( this.outFileName );
      ObjectOutputStream oos = this.createObjectOutputFile( this.outFileName );

      double origCThresh = this.config.cThresh;
      double origProbSpotCheck = this.config.probSpotCheck;
      
      this.config.cF = 0.2;
      this.config.cH = 1.0;

      double f[] = { 0.20, 0.15, 0.10, 0.05, 0.01 };
      
      for ( int i = 0; i < f.length; i++ )
      {
         this.config.fractBad = f[i];
         this.config.cF = f[i];

         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.999999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = true;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );
         
         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.99999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = true;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );
         
         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.9999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = true;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );

         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = true;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );
         
         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.99;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = true;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );
         
         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.999999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = false;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );

         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.99999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = false;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );
         
         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.9999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = false;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );
         
         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.999;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = false;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );
         
         this.config.probSpotCheck = origProbSpotCheck;
         this.config.cThresh = 0.99;
         this.config.m = 1;
         this.config.r = 1;
         this.config.useUpBound = false;

         doSScan( this.sStart, this.sInc, this.sIters, out, oos );

      }

      try
      {
         oos.close();
      } catch ( IOException e )
      {
         Trace.log( 1, "ERROR closing oos: ", e, true );
      }
      
      out.close();
   }
   
   //////////////////////
   // Parallel methods //
   //////////////////////


   protected SimRunResultCollector doConfig( SimRunConfig config )
   {
      return this.doConfig( SimRunWork2.class, config );
   }
      
   
}


