/* * Simple TSP using branch & bound */ package edu.ucsb.cs.jicos.examples.tsp; import edu.ucsb.cs.jicos.applications.branchandbound.*; import edu.ucsb.cs.jicos.services.*; import edu.ucsb.cs.jicos.services.shared.*; import java.rmi.*; import java.util.*; /** * @author Peter Cappello * @version 1.0 */ public class Application { public static void main (String args[]) throws Exception { if ( args.length != 2 ) { System.out.println("Command line: "); System.exit(1); } // get Hsp machine's domain name from the command line. String hspDomainName = args[ 0 ]; // construct pseudo-random TSP instance int nodes = Integer.parseInt( args[1] ); long seed = nodes; int maxEdgeWeight = nodes; TSP tsp = new TSP( nodes, seed, maxEdgeWeight ); // construct Shared upperBound Shared upperBound = new IntUpperBound( Integer.MAX_VALUE ); // construct the computation's Environment Environment environment = new Environment( tsp, upperBound ); // construct root task Solution emptySolution = new TspSolution( nodes ); Task task = new BranchAndBound( emptySolution ); // get a reference to a Host Service Provider HspAgent agent = new HspAgent( hspDomainName ); Client2Hsp hsp = agent.getClient2Hsp(); // login hsp.login( environment ); // compute Solution solution = (Solution) hsp.compute( task ); // logout Invoice invoice = hsp.logout(); // print the solution & invoice System.out.println( solution ); System.out.println( invoice ); } }