/* This problem generator should generate a problme(s) which contains: typed packages, trucks, and airplanes. */ /* generator for translog domain */ #include #include #include #include #define NUM_CITY 5 #define NUM_LOC 15 #define NUM_AIRPORT 5 #define NUM_T 8 #define NUM_P 20 #define NUM_K 20 #define NUM_TYPE_T 4 #define NUM_TYPE_P 4 #define NUM_TYPE_K 4 typedef struct package { char *origin, *destination, *origin_city, *destination_city, *type, *name; } package; //add struct for trucks and airplanes typedef struct truck { char *origin, *origin_city, *type, *name; // origin is a location or an airport } truck; typedef struct plane { char *origin, *origin_city, *type, *name; // origin is an airport } plane; // 5 cities char * cityList[NUM_CITY]={"CITY1", "CITY2", "CITY3", "CITY4", "CITY5"}; // 3 locations in each city char * locationList[NUM_LOC]={"CITY1-CL1", "CITY1-CL2", "CITY1-CL3", "CITY2-CL1", "CITY2-CL2", "CITY2-CL3", "CITY3-CL1", "CITY3-CL2", "CITY3-CL3", "CITY4-CL1", "CITY4-CL2", "CITY4-CL3", "CITY5-CL1", "CITY5-CL2", "CITY5-CL3"}; // 1 airport in each city char * airportList[NUM_AIRPORT]={"CITY1-AP1", "CITY2-AP2", "CITY3-AP3", "CITY4-AP4", "CITY5-AP5"}; // 8 trucks in each city char * truckList[NUM_CITY * NUM_T] = {"TRUCK1-1", "TRUCK2-1", "TRUCK3-1", "TRUCK4-1", "TRUCK5-1", "TRUCK6-1", "TRUCK7-1", "TRUCK8-1", "TRUCK1-2", "TRUCK2-2", "TRUCK3-2", "TRUCK4-2", "TRUCK5-2", "TRUCK6-2", "TRUCK7-2", "TRUCK8-2", "TRUCK1-3", "TRUCK2-3", "TRUCK3-3", "TRUCK4-3", "TRUCK5-3", "TRUCK6-3", "TRUCK7-3", "TRUCK8-3", "TRUCK1-4", "TRUCK2-4", "TRUCK3-4", "TRUCK4-4", "TRUCK5-4", "TRUCK6-4", "TRUCK7-4", "TRUCK8-4", "TRUCK1-5", "TRUCK2-5", "TRUCK3-5", "TRUCK4-5", "TRUCK5-5", "TRUCK6-5", "TRUCK7-5", "TRUCK8-5"}; // 20 planes char * planeList[NUM_P] = {"PLANE1", "PLANE2", "PLANE3", "PLANE4", "PLANE5", "PLANE6", "PLANE7", "PLANE8", "PLANE9", "PLANE10", "PLANE11", "PLANE12", "PLANE13", "PLANE14", "PLANE15", "PLANE16", "PLANE17", "PLANE18", "PLANE19", "PLANE20"}; // 20 packages char * packageList[NUM_K] = {"PACKAGE1", "PACKAGE2", "PACKAGE3", "PACKAGE4", "PACKAGE5", "PACKAGE6", "PACKAGE7", "PACKAGE8", "PACKAGE9", "PACKAGE10", "PACKAGE11", "PACKAGE12", "PACKAGE13", "PACKAGE14", "PACKAGE15", "PACKAGE16", "PACKAGE17", "PACKAGE18", "PACKAGE19", "PACKAGE20"}; /* a package can be defined as: genPackage, bigPackage, medPackage, or smlPackage */ char * packagetype[NUM_TYPE_K]={"PACKAGE", "BIGPACKAGE", "MEDIUMPACKAGE", "SMALLPACKAGE"}; char * trucktype[NUM_TYPE_T]={"TRUCK", "BIGTRUCK", "MEDIUMTRUCK", "SMALLTRUCK"}; char * planetype[NUM_TYPE_P]={"PLANE", "BIGPLANE", "MEDIUMPLANE", "SMALLPLANE"}; truck *trk; package *pkg; plane *pln; void print_constants(); void print_package(const package p); void print_truck(const truck t); void print_plane(const plane p); void main(int argc, char *argv[]) { int cur_city, cur_truck, cur_plane, cur_package, cur_location, des_city, des_location; int i, j, k; int randomList[4]; int done, duplicate; // Initialize packages pkg = new package[NUM_K]; for ( cur_package = 0; cur_package < NUM_K; cur_package++ ) { pkg[cur_package].name = packageList[cur_package]; pkg[cur_package].type = packagetype[cur_package % NUM_TYPE_K]; } // Initialize trucks trk = new truck[NUM_CITY * NUM_T]; for ( cur_city = 0; cur_city < NUM_CITY; cur_city++ ) { for ( cur_truck = 0; cur_truck < NUM_T; cur_truck++ ) { trk[cur_city * NUM_T + cur_truck].name = truckList[cur_city * NUM_T + cur_truck]; trk[cur_city * NUM_T + cur_truck].type = trucktype[cur_truck % NUM_TYPE_T]; } } // Initialize planes pln = new plane[NUM_P]; for ( cur_plane = 0; cur_plane < NUM_P; cur_plane++ ) { pln[cur_plane].name = planeList[cur_plane]; pln[cur_plane].type = planetype[cur_plane % NUM_TYPE_P]; } srandom(time(NULL)); /* write the problem file for SHOP */ cout<<"(defproblem UMtranslog"<