下载了一个java 神经网络工具包,但不知道如何使用,高手请进下载网址
http://sourceforge.net/project/downloading.php?group_id=11618&use_mirror=nchc&filename=jgap_3.4.3_src.zip&a=17233848
http://sourceforge.net/project/downloading.php?group_id=11618&use_mirror=nchc&filename=jgap_3.4.3_src.zip&a=17233848
import org.jgap.FitnessFunction;/**
* This class provides an implementation of the classic "Make change" problem
* using a genetic algorithm. The goal of the problem is to provide a
* specified amount of change (from a cash purchase) in the fewest coins
* possible. This example implementation uses American currency (quarters,
* dimes, nickels, and pennies).
*
* This example may be seen as somewhat significant because it demonstrates
* the use of a genetic algorithm in a less-than-optimal problem space.
* The genetic algorithm does best when there is a smooth slope of fitness
* over the problem space towards the optimum solution. This problem exhibits
* a more choppy space with more local optima. However, as can be seen from
* running this example, the genetic algorithm still will get the correct
* answer virtually everytime.
*/
public class MinimizingMakeChangeFitnessFunction extends FitnessFunction
{
private final int m_targetAmount; /**
* Constructs this MinimizingMakeChangeFitnessFunction with the desired
* amount of change to make.
*
* @param a_targetAmount The desired amount of change, in cents. This
* value must be between 1 and 99 cents.
*/
public MinimizingMakeChangeFitnessFunction( int a_targetAmount )
{
if( a_targetAmount < 1 || a_targetAmount > 99 )
{
throw new IllegalArgumentException(
"Change amount must be between 1 and 99 cents." );
} m_targetAmount = a_targetAmount;
}
/**
* Determine the fitness of the given Chromosome instance. The higher the
* return value, the more fit the instance. This method should always
* return the same fitness value for two equivalent Chromosome instances.
*
* @param a_subject: The Chromosome instance to evaluate.
*
* @return A positive integer reflecting the fitness rating of the given
* Chromosome.
*/
public double evaluate( IChromosome a_subject )
{
// The fitness value measures both how close the value is to the
// target amount supplied by the user and the total number of coins
// represented by the solution. We do this in two steps: first,
// we consider only the represented amount of change vs. the target
// amount of change and calculate higher fitness values for amounts
// closer to the target, and lower fitness values for amounts further
// away from the target. If the amount equals the target, then we go
// to step 2, which adjusts the fitness to a higher value for
// solutions representing fewer total coins, and lower fitness
// values for solutions representing a larger total number of coins.
// ------------------------------------------------------------------
int changeAmount = amountOfChange( a_subject );
int totalCoins = getTotalNumberOfCoins( a_subject );
int changeDifference = Math.abs( m_targetAmount - changeAmount ); // Step 1: Determine the distance of the amount represented by the
// solution from the target amount. Since we know the maximum amount
// of change is 99 cents, we'll subtract from that the difference
// between the solution amount and the target amount. That will give
// the desired effect of returning higher values for amounts close
// to the target amount and lower values for amounts further away
// from the target amount.
// ------------------------------------------------------------------
double fitness = ( 99 - changeDifference ); // Step 2: If the solution amount equals the target amount, then
// we add additional fitness points for solutions representing fewer
// total coins.
// -----------------------------------------------------------------
if( changeAmount == m_targetAmount )
{
fitness += 100 - ( 10 * totalCoins );
} return fitness;
}..................
**********************************
http://jgap.sourceforge.net/doc/tutorial.html
里面说的很多了。