Presentation is loading. Please wait.

Presentation is loading. Please wait.

RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

Similar presentations


Presentation on theme: "RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview."— Presentation transcript:

1 RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview o Input / Output Files o Project File – what and why o BAPS Software Architecture J Coding the BAP Partitioner o BAPS – Main Program o BAP Package o Partitioner, Packer

2 RAS-Group, SoC, NUS (BAP: CS5234) Page 2 BAP Partitioning Challenge J For CS5234, only need to solve BAP Partitioning o Solve only BAP Partitioning Sub-Problem o BAP Packing component is GIVEN TO YOU J What does that mean? o For each vessel, you only need to assign it to a section o NO NEED TO ASSIGN WHARFMARK J What if you like to also do BAP Packing? o Can talk to me to get details, BUT o Do it after the end of the course o No need to jeopardize your grades

3 RAS-Group, SoC, NUS (BAP: CS5234) Page 3 BAPS Software Overview J How to Use the BAPS Software ousage: BAPS o eg: BAPS proj-d001.prj J BAP Project File specifies osection-file, vessel-file, transshipment-file oparameter file (what alg to use for) upartitioning algorithm to use any associated parameters upacking algorithm to use any associated parameters oname of output file, trace file, summary file

4 RAS-Group, SoC, NUS (BAP: CS5234) Page 4 BAPS Software Architecture J BAPS Package Class acts as the interface class; J BAPS Solver Class encapsulates solution; o Initializes BAPPackage; invokes Partitioning and Packing Library Components BAP Classes BAP PackageBAP Solver BAP Partitioning Components BAP Packing Components

5 RAS-Group, SoC, NUS (BAP: CS5234) Page 5 About the BAPS Software J Software belongs to the RAS-Group, SoC, NUS /************************************************************************* * * File Name: BAPS.cpp * BAPS v2.0 * Author : David Ong Tat Wee * Date : 25 Apr 2000 * * Copyright (C) 1998, 1999, 2000 * All Rights Reserved by * The RAS Group, Algorithms Lab * School of Computing * National University of Singapore * *************************************************************************/

6 RAS-Group, SoC, NUS (BAP: CS5234) Page 6 BAPS Software Overview Data Sources BAP-XX Packer BAP-XX Packer BAP Packers BAPTV Partitioner BAP Solver BAP Package GUI Module BAPS Engine

7 RAS-Group, SoC, NUS (BAP: CS5234) Page 7 BAPS Software Overview baps (Main) create call BAP Package BAPSolver Partition Packing BAPPartitioner (Abstract) BAPPacker (Abstract)

8 RAS-Group, SoC, NUS (BAP: CS5234) Page 8 BAP (Main Program) J BAPS Main (baps.cpp) o Checks the command-line parameters o Reads the Project File o Initializes the BAPPackage o Initializes the BAPSolver o Calls BAPSolver.solve();

9 RAS-Group, SoC, NUS (BAP: CS5234) Page 9 baps (Main Program) #include "def.h“// Include important stuffs used #include "BAPPackage.h" #include "BAPSolver.h" int main(int argc, char *argv[]) { if (argc != 2 && argc != 3)// CHECK command-line arguments!! {…} …// Check env variables BAPHOME BAPTMP string ProjectFile(argv[1]);// Get ProjectFile string Job("all"); BAPPackage TheBAP(ProjectFile);// Initializes the BAPPackage BAPSolver Solver(TheBAP, Job);// Initializes the Solver Solver.Solve();// Invokes Solve() method cout << "End of program" << endl; return 0; }

10 RAS-Group, SoC, NUS (BAP: CS5234) Page 10 BAP Solver Class J BAP Solver (BAPSolver.{h,cpp}) o Takes in a BAPPackage and … o Read parameter file to get details of upartitioning algorithm to use upacking algorithm to use, etc, etc o Invokes Partitioning-Solver Class u Creates appropriate Partitioner (with BAPPackage) u Invokes Solve() method of Partitioner u Updates BAPPackage after partitioning; oInvokes appropriate Packing-Solver Class u Creates appropriate Packer (with BAPPackage) u Invokes Solve() method of Packer u Updates BAP Package after packing;

11 RAS-Group, SoC, NUS (BAP: CS5234) Page 11 BAP Solver Class /****************************************************************** * Filename : BAPSolver.cpp * Description : Implements the BAP Solver class * Notes : This class calls the BAP partitioning and packing * algorithms. It serves as an interface between the * BAP Package class and the BAP algorithms. ******************************************************************/ #include "BAPSolver.h" BAPSolver::BAPSolver(BAPPackage& aPackage, string aJob = "all")// CONSTRUCTOR : BAPBase(), mPackage(aPackage), mJob(aJob), mPartitioner("GP"), mPacker("BP") { ReadParameterFile();// GET PARAMETERS } … BAPPackage& BAPSolver::Package() const// GET the BAPPackage { return mPackage; }

12 RAS-Group, SoC, NUS (BAP: CS5234) Page 12 BAP Solver Class (2) … void BAPSolver::Solve()// THE SOLVE() METHOD { if (mJob == "all")// everything is obvious here!! { cout << "running all" << endl; DoPartitioning(); DoPacking(); } else if (mJob == "part") { cout << "running partitioning" << endl; DoPartitioning(); } else if (mJob == "pack") { cout << "running packing" << endl; DoPacking(); } else { cerr << "BAPSolver: unknown job '" << mJob << "'" << endl; }

13 RAS-Group, SoC, NUS (BAP: CS5234) Page 13 The BAP Partitioning Solver Class J Code Given to All of You o One Partitioner – BAPTVPartitioner uinherit from BAPPartitioner oBAP Packer Component – BAPBPPacker uGiven as.h and.o files BAPSolver Class BAP Packing Solver BAP Partitioning Solver BAPPackage

14 RAS-Group, SoC, NUS (BAP: CS5234) Page 14 Generic Partitioner (DoPartitioning) … void BAPSolver::DoPartitioning()// Job: Call the correct BAP Partitioner { BAPPartitioner* Partitioner;// Init Generic Partitioner first if (mPartitioner == "TV")// Check for specified BAP PARTITIONER Partitioner = new BAPTVPartitioner(mPackage);// Create BAPTVPartitioner (with BAPPackage) //else if (mPartitioner=="new partitioner")// PLACE for your NEW PARTITIONER else { cerr << "Unknown partitioner: " << mPartitioner << endl; return; } Partitioner->Solve();// Invokes Solve Method of Partitioner delete Partitioner; }

15 RAS-Group, SoC, NUS (BAP: CS5234) Page 15 Generic Packer (DoPacking) void BAPSolver::DoPacking()// Job: Get the correct BAP Packer { BAPPacker* Packer;// Init generic Packer first if (mPacker == "BP")// Check for specified packer Packer = new BAPBPPacker(mPackage);// Create BP Packer else { cerr << "Unknown packer: " << mPacker << endl; return; } Packer->Solve();// Invokes Solve() method of packer delete Packer; }

16 RAS-Group, SoC, NUS (BAP: CS5234) Page 16 Your Project J Code up another BAP Partitioner oUse BAPTVPartitioner as model oYour partitioner will be very similar J Study code for BAPTVPartitioner oNote the APIs for ucalling BAPPackage’s methods; ucalculating section local/global density; uchecking feasibility for adding a vessel to a section uadding vessel to section; ucalculating transshipment cost

17 RAS-Group, SoC, NUS (BAP: CS5234) Page 17 Software Directory Structure J software-root-dir odoc oman osrc opartitioning opacking obin odatabase oparam oproject osolution oresult

18 RAS-Group, SoC, NUS (BAP: CS5234) Page 18

19 RAS-Group, SoC, NUS (BAP: CS5234) Page 19


Download ppt "RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview."

Similar presentations


Ads by Google