OpenTS Tutorial
Main Program
Instantiating our Objects

Here we'll instantiate our Tabu Search objects. We'll go over the details later, but for now it's important to see that we're simply creating the components that are necessary to create a org.coinor.opents.TabuSearch object.

import org.coinor.opents.*;

public class Main
{

    public static void main( String[] args )
    {
        // Initialize our objects
java.util.Random r = new java.util.Random( 12345 ); double[][] customers = new double[20][2]; for( int i = 0; i < 20; i++ ) for( int j = 0; j < 2; j++ ) customers[i][j] = r.nextDouble()*200; ObjectiveFunction objFunc = new MyObjectiveFunction( customers ); Solution initialSolution = new MySolution( customers ); MoveManager moveManager = new MyMoveManager(); TabuList tabuList = new SimpleTabuList( 7 ); // In OpenTS package
// Create Tabu Search object // ... // Start solving // ... // Show solution // ... } // end main ... } // end class Main

After setting the number of customers we wish to solve for, just 20 for now, we create a 20x2 matrix with random x and y coordinates in the range [0,200). By creating a random number generator with a set seed, we get predictable random numbers (an oxymoron at best) that will help with the inevitable debugging.

Now that we've made our objects (don't worry, we'll look at what these are exactly in just a bit), we need to create an OpenTS Tabu Search object. That's up next...