/*
 * Copyright (c) 2005, Stanford University. All rights reserved. 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions
 * are met: 
 *  - Redistributions of source code must retain the above copyright 
 *    notice, this list of conditions and the following disclaimer. 
 *  - Redistributions in binary form must reproduce the above copyright 
 *    notice, this list of conditions and the following disclaimer in the 
 *    documentation and/or other materials provided with the distribution. 
 *  - Neither the name of the Stanford University nor the names of its 
 *    contributors may be used to endorse or promote products derived 
 *    from this software without specific prior written permission. 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE. 
 */

/*
 * Created on September 12, 2006
 * Original author: Mark Friedrichs
 */
package org.simtk.isimsu;

// Model in which to store adjustable parameters for computation

class ISIMParameters {
    
  private int _randomSeed              = 4357;
  private int _totalMonteCarloSteps    = 5000;
  private int _equilibrationStepCount  = 200;
  private int _potentialFrequency      = 100;
  private int _defaultOutputFrequency  = 1000;
  private boolean  _addHydrationRadii  = false;

  public ISIMParameters( ){
      System.out.println("ISIMParameters constructor");
  }

  public ISIMParameters( ISIMParameters isimParameters ){
      copyFrom( isimParameters );
  }

  // random seed accessors
  
  public boolean setRandomSeed( int randomSeed ){
      _randomSeed = randomSeed;
      return true;
  }
  
  public int getRandomSeed( ){
     return _randomSeed;
  }
  
  // total MonteCarlo steps accessors
  
  public boolean setTotalMonteCarloSteps( int totalMonteCarloSteps ){
      if( totalMonteCarloSteps > 0 ){
         _totalMonteCarloSteps = totalMonteCarloSteps;
         return true;
      } else {
          return false;
      }
  }
  
  public int getTotalMonteCarloSteps( ){
     return _totalMonteCarloSteps;
  }
  
 // equilibrationStepCount accessors
  
  public boolean setEquilibrationStepCount( int equilibrationStepCount ){
      if( equilibrationStepCount > 0 ){
    	  _equilibrationStepCount = equilibrationStepCount;
         return true;
      } else {
         return false;
      }
  }
  
  public int getEquilibrationStepCount( ){
     return _equilibrationStepCount;
  }

  // Frequency to calculate Potential accessors
  
  public boolean setPotentialFrequency( int potentialFrequency ){

     if( potentialFrequency > 0 ){
         _potentialFrequency = potentialFrequency;
         return true;
     } else {
         return false;
     }
  }
  
  public int getPotentialFrequency( ){
     return _potentialFrequency;
  }
  
  // default frequency to output various observables
  
  public boolean setDefaultOutputFrequency( int defaultOutputFrequency ){

     if( defaultOutputFrequency > 0 ){
         _defaultOutputFrequency = defaultOutputFrequency;
         return true;
     } else {
         return false;
     }
  }
  
  public int getDefaultOutputFrequency( ){
     return _defaultOutputFrequency;
  }
  
  // add solvent diameter to ionic radii?
  
  public boolean setAddHydrationRadii( boolean addHydrationRadii ){
     _addHydrationRadii = addHydrationRadii;
     return true;
  }
  
  public boolean getAddHydrationRadii( ){
     return _addHydrationRadii;
  }
  
  public boolean equals( Object o ){
      if( !(o instanceof ISIMParameters) ) return false;
      ISIMParameters p2 = (ISIMParameters) o;

      if( _randomSeed              != p2.getRandomSeed() )               return false;
      if( _totalMonteCarloSteps    != p2.getTotalMonteCarloSteps() )     return false;
      if( _potentialFrequency      != p2.getPotentialFrequency() )       return false;
      if( _defaultOutputFrequency  != p2.getDefaultOutputFrequency() )   return false;
      if( _addHydrationRadii       != p2.getAddHydrationRadii() )        return false;
      if( _equilibrationStepCount  != p2.getEquilibrationStepCount() )   return false;

      return true;
  }
  
  void copyFrom( ISIMParameters otherParameters) {
	  setRandomSeed( otherParameters.getRandomSeed() );
	  setTotalMonteCarloSteps( otherParameters.getTotalMonteCarloSteps() );
	  setPotentialFrequency( otherParameters.getPotentialFrequency() );
	  setDefaultOutputFrequency( otherParameters.getDefaultOutputFrequency() );
	  setRandomSeed( otherParameters.getRandomSeed() );
	  setAddHydrationRadii( otherParameters.getAddHydrationRadii() );
	  setEquilibrationStepCount( otherParameters.getEquilibrationStepCount() );
	  
  }
  
  public int hashCode() {
      return (new Integer(_randomSeed).hashCode() +
              new Integer(_totalMonteCarloSteps).hashCode() +
              new Integer(_potentialFrequency).hashCode() 
              );
  }
}

