Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gp.regression.optimizer.SenseChecker.java

Here you can find all the information about the file org.dgpf.gp.regression.optimizer.SenseChecker.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-08-09 09:50:58
 * Original Filename: org.dgpf.gp.regression.optimizer.SenseChecker.java
 * Version          : 1.0.0
 * Last modification: 2006-08-09
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.dgpf.gp.regression.optimizer;

import org.dgpf.gp.regression.base.AggregationContext;
import org.dgpf.gp.regression.base.Calculation;
import org.dgpf.gp.regression.base.CalculationAccessor;
import org.dgpf.gp.regression.base.Formula;
import org.sfc.utils.Typesafe;

/**
 * The internal sense checker class helps us to find out whether a
 * calculation makes any sense at all.
 *
 * @author Thomas Weise
 */

public  final class SenseChecker  extends CalculationAccessor
  {

/**
 * Nah, no instantiation is happening here.
 */

  private SenseChecker()
    {
    Typesafe.do_not_call();
    }
  
/**
 * Perform the sense check.
 * @param p_source  The source calculation.
 * @param p_context The context.
 * @return <code>true</code> if and only if the calculation makes sense,
 *         <code>false</code> otherwise.
 */

  public static final boolean makes_sense(final Calculation        p_source,
                                          final AggregationContext p_context)
    {
    byte[]    l_v;
    Formula[] l_ff;
    int       l_i, l_l, l_u;
    boolean   l_z1, l_z2, l_z3;
    
    l_v = get_variable_types(p_source);
    l_l = l_v.length;
    
    l_z1 = false;
    l_z2 = false;
    l_z3 = false;
main:
    for(l_i = (l_l-1); l_i >= 0; l_i--)
      {
      l_u = p_source.get_variable_usage(l_i);
      
      if( ((l_v[l_i] & Calculation.TARGET_VARIABLE) != 0) &&
          ((l_u & 2) == 0)) return false;
      
      if( ((l_v[l_i] & Calculation.OUTPUT_VARIABLE) != 0) &&
          ((l_u & 2) != 0)) l_z1 = true;
      
      if( ((l_v[l_i] & Calculation.INPUT_VARIABLE) != 0) &&
          ((l_u & 1) != 0)) l_z2 = true;
      
      if( ((l_v[l_i] & Calculation.PROVIDED_VARIABLE) != 0) &&
          ((l_u & 1) != 0)) l_z3 = true;
      }
        
    if(l_z1 & l_z2 & l_z3)
      {
      if(l_l != get_start_values(p_source).length) return false;
      
      l_ff = get_formulas(p_source);
      for(l_i = (l_ff.length-1); l_i >= 0; l_i--)
        {
        if(l_ff[l_i].get_variable_count() > l_l) return false;
        }
      
      return true;
      }
    
    return false;
    }
  }

File Information:

file name:SenseChecker.java
package:org.dgpf.gp.regression.optimizer
qualified name:org.dgpf.gp.regression.optimizer.SenseChecker.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gp/regression/optimizer/SenseChecker.java
size:3.250 KB (3329 B)
uploaded: 2015-07-22 04:10:56 GMT+0000
last update: 2006-08-12 09:45:30 GMT+0000
last access: 2017-11-23 00:45:23 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-23 05:29:10 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo