Вы находитесь на странице: 1из 38

1.

ABSTRACT

The aim of this project is to develop an algorithm to find an optimal sequence


whose time is as least as possible. It deals with a set of m sites and n jobs. Each job
will take timet. For m sites there will be m! Sequences among them the optimal
sequence will be calculated. The input for this project is the number of sites, the number
of jobs performed in each site and time taken for each operation at each site will be given
in a text file. The optimal sequence and its time will be displayed on console as output.

2. INTRODUCTION

The m number of sites and n number of jobs are given as input on C program
console. In a text file the time taken by each job at each site will be taken in the form of
2D matrix by a C program. The optimal sequence and its time will be displayed as output
on console.

2.1 Purpose of Project


The purpose of this project is to develop an algorithm to find the optimal
sequence whose time is as least as possible so that it will be easy to know the total time
of completion of the task.

2.2 Existing System


There is no prescribed or preferred tool to generate optimal sequence for any kind
of jobs. Same problem could be solved

by hand i.e. performing a general mathematical calculation to find out the

optimal sequence
by the algorithm of job sequencing with deadlines
by the Job shop scheduling algorithm
by the Johnsons algorithm for job sequencing

2.3 Proposed System


It is a console application to generate optimal sequence. Any number of sites can
be arranged sequentially in order to achieve the job in minimum possible amount of time.
In this regard, we have chosen the Job sequencing algorithm because of its efficiency
over other algorithms that serve for the same purpose. Moreover, this algorithm also
calculates the total turnaround time of the optimal sequence.

3. SOFTWARE REQUIREMENTS AND


SPECIFICATIONS
3.1. Functional and Non-Functional Requirements
The requirements for the Job sequencing machine are organized in the following way
General requirements

Functional Requirements:
Initializing the parameters
If no data is inserted, the system shall display the warning statement, to insert the data.
An error message must be displayed for any kind of functional errors.
The system has to check if the entered card is a valid data.
If the inserted data is valid the system should accept the data and perform the prescribed
algorithm.
The output is however shown on the console, hence there is no other special requirement
regarding the interface.

Nonfunctional Requirements:
Usability Requirement
The system shall allow the users to access the system from the console itself. And of
course can be developed with a console based application. Presently, it uses the C console
as an interface.
Availability Requirement
The system is available 100% for the user and can be used now and then. The system
shall be operational always in any kind of supporting environment.

Efficiency Requirement
Mean Time to Repair (MTTR) The chances of failure are very less in this system.
Even if the system fails, the system will be recovered back up with a reinstallation of
Turbo C.
Accuracy
The system shall accurately provide all the real time information taking into
consideration various concurrency issues. The system shall provide 100% access
reliability.
Performance Requirement
The information is refreshed at regular intervals depending upon whether some updates
have occurred or not. The system shall respond to the member in not less than two
seconds from the time of the request submittal when all the hardware and software
requirements are satisfied coherently. Since, it is just a language compiler. Apparently, the
system shall be allowed to take more time when doing large processing jobs. Responses
to view information shall take no longer than 5 seconds to appear on the screen.
Reliability Requirement
The system shall be 100% reliable due to the importance of data and the damages that can
be caused by incorrect or incomplete data. There is no problem in running the system not
ceased for a much longer time.

3.2. Hardware and Software Requirements


4

Hardware Requirements:

Processor: Pentium 233 MHz or above

RAM Capacity: 4GB

Hard Disk: Minimum of 15GB

Software Requirements:

Operating System: Windows family

Input: Text file

Front end: C programming language

4. ANALYSIS
5

4.1. Introduction
The Analysis Phase is where the project lifecycle begins. The Analysis Phase is where we
break down the deliverables in the high-level Project Charter into the more detailed
requirements. The Analysis Phase is also the part of the project where we identify the
overall direction that the project will take through the creation of the project strategy
documents. Gathering requirements is the main attraction of the Analysis Phase.
This project is divided into two different modules.

User module(presentation module)

Sequence module(programming module

4.2. Modules Description


User Module: User aim is to find the optimal sequence whose time is as least as possible.
User will give the number of sites, number of jobs in each site and time taken for each
job in a text file.
Sequence Module: This module is divided into 3 sub modules. In 1 st module the possible
number of sequences will be generated. In 2nd module the total time of completion will be
calculated for every sequence. In 3rd module the optimal sequence whose time is least will
be found.

4.3. Conclusion:
The process of gathering requirements is usually more than simply asking the users what
they need and writing their answers down. Depending on the complexity of the
application, the process for gathering requirements has a clearly defined process of its
own. This process consists of a group of repeatable processes that utilize certain
techniques to capture, document, communicate, and manage requirements.

5. DESIGN

5.1. Introduction
The Design phase is when you build the plan for how you will take your project through
the rest of the SDL processfrom implementation, to verification, to release. During the
Design phase you establish best practices to follow for this phase by way of functional
and design specifications, and you perform risk analysis to identify threats and
vulnerabilities in your software.
This Project contains two types of design diagrams.

Flow chart diagram


UML diagrams

5.2. Module Design:


Flow chart Diagram: A flowchart is a formalized graphic representation of a logic
sequence, work or manufacturing process, organization chart, or similar formalized
structure. Flowcharts use simple geometric symbols and arrows to define relationships. In
programming, for instance, the beginning or end of a program is represented by an oval.
A process is represented by a rectangle, a decision is represented by a diamond and an
I/O process is represented by a parallelogram.

UML Diagrams:
The Unified

Modeling

Language (UML)

is

general-purpose,

developmental, modeling language in the field of software engineering that is intended to


provide a standard way to visualize the design of a system. The Unified Modeling
Language (UML) offers a way to visualize a system's architectural blueprints in a
diagram (see image), including elements such as any activities individual components of
the system and how they can interact with other software components. How the system
will run, how entities interact with others (components and interfaces) external user
interface.
Although originally intended solely for object-oriented design documentation, the
Unified Modeling Language (UML) has been extended to cover a larger set of design
documentation, and been found useful in many contexts.
The Unified Modeling Language allows the software engineer to express an
analysis model using the modeling notation that is governed by a set of syntactic
semantic and pragmatic rules.
A UML system is represented using five different views that describe the system
from distinctly different perspective. Each view is defined by a set of diagram, which is
as follows.

User Model View


i. This view represents the system from the users perspective.
ii. The analysis representation describes a usage scenario from the
end-users perspective.

Structural model view


i. In this model the data and functionality are arrived from inside the
system.
ii. This model view models the static structures.

Behavioral Model View


It represents the dynamic of behavioral as parts of the system, depicting
the interactions of collection between various structural elements
described in the user model and structural model view.

Implementation Model View

In this the structural and behavioral as parts of the system are represented
as they are to be built.

Environmental Model View

In this the structural and behavioral aspects of the environment in which


UML is specifically constructed through two different domains they are:
The system is to be implemented are represented.UML Analysis modeling, this focuses
on the user model and structural model views of the system.
UML design modeling, which focuses on the behavioral modeling, implementation
modeling and environmental model views.
Use case Diagrams represent the functionality of the system from a users point of view.
Use cases are used during requirements elicitation and analysis to represent the
functionality of the system. Use cases focus on the behavior of the system from external
point of view. There are four types of UML diagrams for this project namely,

Usecase diagram

Sequence diagram

Collaboration diagram

Activity diagram

10

Usecase Diagram:
Usecase diagrams are a set of use cases, actors and their relationships. They represent the
use case view of a system.
A usecase represents a particular functionality of a system.
So usecase diagram is used to describe the relationships among the functionalities and
their internal/external controllers. These controllers are known as actors.
In this project there are 2 actors user and system. The functionalities of each actor are
represented in usecase.

11

Sequence Diagram:
A sequence diagram is an interaction diagram. From the name it is clear that the diagram
deals with some sequences, which are the sequence of messages flowing from one object
to another.
Interaction among the components of a system is very important from implementation
and execution perspective.
So Sequence diagram is used to visualize the sequence of calls in a system to perform a
specific functionality.
In this project the interaction between user and system is represented as shown in below
sequence diagram.

12

Collaboration Diagram:
Collaboration diagram is another form of interaction diagram. It represents the structural
organization of a system and the messages sent/received. Structural organization consists
of objects and links.
The purpose of collaboration diagram is similar to sequence diagram. But the specific
purpose of collaboration diagram is to visualize the organization of objects and their
interaction.
In this project the objects are user and system visualizes the organization and interaction
between them.

13

Activity Diagram:
Activity diagram describes the flow of control in a system. So it
consists of activities and links. The flow can be sequential, concurrent
or branched.
Activities are nothing but the functions of a system. Numbers of activity diagrams are
prepared to capture the entire flow in a system.

14

Activity diagrams are used to visualize the flow of controls in a system. This is prepared
to have an idea of how the system will work when executed.
In this project the activity diagram shows the sequential flow functions/activities.

6. CODING AND IMPLEMENTATION


6.1. Introduction:
The complete assessment and evaluation of a system is done once the design
phase is completed. The next phase is coding phase and implementation phase.
15

The coding phase aims at translating the design created into a set of programs in
some given programming language, so that the design can be implemented in the most
efficient manner. This phase affects the subsequent phases, such as testing and
maintenance, acutely. While coding, the focus has to be on minimizing testing and
maintenance effort. All endeavors while coding should stand for simplicity and easily
understandable.
The Implementation phase is when the end user of your software is foremost in
your mind. During this phase you create the documentation and tools the customer uses
to make informed decisions about how to deploy your software securely. To this end, the
Implementation phase is when you establish development best practices to detect and
remove security and privacy issues early in the development cycle.

6.2. Introduction about technology:


C is a general-purpose programming language, and is used for writing programs
in many different domains, such as operating systems, numerical computing, graphical
applications, etc. It is a small language, with just 32 keywords. It provides high-level
structured programming constructs such as statement grouping, decision making, and
looping, as well as low level capabilities such as the ability to manipulate bytes and
addresses. Since C is relatively small, it can be described in a small space, and learned
quickly. A programmer can reasonably expect to know and understand and indeed
regularly use the entire language. C achieves its compact size by providing Spartan
services within the language proper, foregoing many of the higher-level features
commonly built-in to other languages. For example, C provides no operations to deal
directly with composite objects such as lists or arrays. There are no memory management
facilities apart from static definition and stack-allocation of local variables. And there are
no input/output facilities, such as for printing to the screen or writing to a file. Much of
the functionality of C is provided by way of software routines called functions. The
language is accompanied by a standard library of functions that provide a collection of
commonly used operations. For example, the standard function printf () prints text to the
screen (or, more precisely, to standard outputwhich is typically the screen). The

16

standard library will be used extensively throughout this text; it is important to avoid
writing your own code when a correct and portable implementation already exists.
A C program, whatever its size, consists of functions and variables. A function contains
statements that specify the computing operations to be done, and variables store values
used during the computation.
The following program is the traditional first program presented in introductory C
courses and textbooks.
1 /* First C program: Hello World */
2 #include
3
4 int main(void)
5{
6

printf("Hello World! \n");

7}

6.3. Algorithm:
Input: Number of sites, number of jobs and the text file name are the inputs for this
project.

17

Step1: Construct the text file in the form of matrix a[i][j].Rows indicate the sites (m) and
columns indicate the jobs (n), the values indicate the time taken by each job at each site.
Step2: Enter the number of sites and number of jobs on console.
Step3: Enter the text file name on console.
Step4: The value a[i+1] will be compared with a[j+1] in the matrix.
If a[j+1] is greater than a[i+1] then for a[i+1][j+1] the a[j+1] value will be added and
stored in a[i+1][j+1].
If a[i+1] is greater than a[j+1] then for a[i+1][j+1] the a[i+1] value will be added and
stored in a[i+1][j+1].
Step5: This process will be continued until the last value in matrix a[m][n].
Step6: The optimal sequence and total time of completion will be displayed on console.
Output: the total number of permutations, optimal sequence and its time are the outputs.

6.4. Implementation
Sample Code in C:
#include<stdio.h>
#include<conio.h>

18

#include<malloc.h>
#define maxsites 20
#define maxjobs 15

void swap(long int *,long int*);


void permute(void);
long int noofpermutations();
void store(void);
void enterjobspersite();
void computeprevjobs();
void addlist();
void addq(long int);
void calctimematrix( );
long int totalcost;
struct node{
long int val;
struct node *next;
struct node *nextlist;
};

struct node *head,*head1;

19

long int m,n,q,noofsites,noofjobs,count=0;


long int Compsites=0;
long int Compjobs = 0;
long int a[maxsites];
long int b[maxsites][maxjobs];
long int S[maxsites][maxjobs];
long int costx[maxsites][maxjobs];
long int cost[maxsites][maxjobs];
long int CompressedJob[maxjobs][maxsites];
long int CompS[maxsites][maxjobs];
long int bctr=0;
long int totaltime;
long int before[maxjobs];
int leastcost=9999,leastcostperm=-1;
long int p=-1;

void addlist(){
if (head==NULL)
return;
else {
head1=head;

20

while (head1->nextlist !=NULL)


head1 = head1->nextlist;
}
}

void addq(long int q){


struct node *temp, *temp1;
temp=(struct node*)malloc(sizeof(struct node));
temp->val = q;
temp->next=NULL;
temp->nextlist=NULL;
if (head1->nextlist==NULL)
{head1->nextlist= temp;
head1=temp;
}
else {temp1=head1;
while (temp1->next !=NULL) temp1=temp1->next;
temp1->next= temp;
}
}

21

void computeprevjobs(){
struct node *temp,*temp1;
long int prev,i;

temp=head;
for(i=0;i<noofjobs;i++)
before[i] = -1;
while(temp != NULL) {
temp1 = temp;
prev = temp->val -1;
for(i=0;i<(prev+1);i++)
if (before[i]==-1)
before[i] = i-1;

while (temp1 != NULL) {


before[temp1->val]=prev;
temp1=temp1->next;
}

temp=temp->nextlist;
}

22

}
void calctimematrix(){
long int i,j,k,n,p,m;
long int x;
n = noofpermutations();
for(m=0;m<n;m++){
totalcost=0;
for(j=0;j<noofsites;j++)
{
for(k=0;k<noofjobs;k++)
{
cost[b[m][j]-1][k] = costx[b[m][j]-1][k];
/*

printf("$%d ",cost[b[m][j]-1][k]);*/
}

}
for (i=1;i<noofjobs;i++) {
cost[b[m][0]-1][i] += cost[b[m][0]-1][i-1];
/*

printf("jobs %d",cost[b[m][0]-1][i]);*/
}

for (i=1;i<noofsites;i++)
{cost[b[m][i]-1][0] += cost[b[m][i-1]-1][0];

23

/*

printf("sites %d",cost[b[m][i]-1][0]);*/
}

for(j=1;j<noofsites;j++)
for(k=1;k<noofjobs;k++)
{
if (cost[b[m][j]-1][k-1] > cost[b[m][j-1]-1][k])
x = cost[b[m][j]-1][k-1];
else
x = cost[b[m][j-1]-1][k];

cost[b[m][j]-1][k] += x;
/*

printf("#%d ",cost[b[m][j]-1][k]); */
totalcost = cost[b[m][j]-1][k];
/*printf("\n total time = %d",totalcost);*/

}
/* printf("\n This permutation number : %d whose cost is %d",b[m][r],totalcost);*/
if (totalcost < leastcost)
{
leastcost=totalcost;
/* printf("\n Least cost changed to : %d",leastcost); */
leastcostperm=m;

24

/* printf("\n Least cost permutation changed to : %d", (leastcostperm+1));*/


}
}
printf("\nThe optimal sequence is : \n");
for (i=0;i<noofsites;i++)
printf("S%d ",b[leastcostperm][i]);
printf("\n");
printf("\n Its time is : %d days\n",leastcost);
}

void swap(long int *p1,long int *p2)


{ long int temp;
temp = *p1;
*p1 = *p2;
*p2 = temp;
}

void enterjobspersite(){
long int i, j;
long int a[6][6];
char filename[100];

25

FILE *file1;
clrscr();
printf("Please enter file name (W/O .txt): ");
scanf("%s", filename);

file1 = fopen(filename, "r");

for(i=0;i<noofsites;i++){
for(j=0;j<noofjobs;j++){
fscanf(file1,"%d\t", &S[i][j]);
costx[i][j] = S[i][j];
/*

printf("*%d ",costx[i][j]); */
}
}

}
long int noofpermutations()
{ long int permutations=1,x;
for(x=1;x<=noofsites;x++)
permutations=permutations*x;
return permutations;

26

}
void store()
{ long int x;
/*printf("\n in store %d",bctr+1);*/
for(x=0;x<noofsites;x++)
b[bctr][x]=a[x];
/*totaltime[bctr]=0; */
bctr++;
count++;
}
void permute()
{ long int x,y;
while(count<noofpermutations())
{ for(y=0;y<noofsites-1;y++)
{ swap(&a[y],&a[y+1]);
store();
}
swap(&a[0],&a[1]);
store();
for(y=noofsites-1;y>0;y--)
{ swap(&a[y],&a[y-1]);

27

store();
}
swap(&a[noofsites-1],&a[noofsites-2]);
store();
}
}
void printperm(){
long int i,j,n;
n=noofpermutations();
for(i=0;i<n;i++)
{for(j=0;j<noofsites;j++)
printf("%d ",b[i][j]);
printf("\n");
}
}
main() {
long int x;
char ans;
clrscr();
printf("Enter no. of sites : ");
scanf("%d",&noofsites);

28

if(noofsites<=0)
{
printf("sites cant be zero or less than zero");
exit(1);
}
else
printf("Enter no. of jobs : ");
scanf("%d", &noofjobs);
if(noofjobs<=0)
{
printf("jobs can't be zero or less than zero");
exit(2);
}

/*printf("Processing sites..."); */
for(x=0;x<noofsites;x++)
a[x] = x+1;
/*printf("\n Entering costs per job.."); */
enterjobspersite();

computeprevjobs();

29

/*printf("\nPermutations are : \n");*/


permute();
/*printperm(); */
printf("\nTotal Permutations : %d",noofpermutations());
calctimematrix();
getch();
return 0;
}

Directions to get output:

Enter into C console.


Open the program and compile it.
Enter the number of sites and number of jobs as shown in output screens.
Enter the text file name with extension .txt.
On enter output will be displayed on console.

6.5. Output Screens


Construction of text file will be as shown below.

30

Enter the number of sites and number of jobs.

Enter the file name with .txt extension.

31

The output will be as shown below.

6.6. Conclusion
32

The time taken for a job to complete at a particular site values will be given in a
text file as input. When this text file name is given on console the program will be
executed and the total permutations, optimal sequence and total time taken for all jobs to
complete will be given as output on console.
If the same problem would have solved by hand, it would have taken approximately 3
years to find the optimal sequence after implementing all the sequences manually. To
perform a general mathematical calculation to find out the optimal sequence for the
above problem, it took about two hours for us. Through the algorithm of job sequencing
with deadlines may face the delay time during processing. In Job shop scheduling, it is
very hard to schedule due to high product variability and twisted production flow.
Moreover capacity utilization is very low compared to the job sequencing algorithm.

7. TESTING
33

7.1. Introduction
Software Testing is a critical element of software quality assurance and represents
the ultimate review of specification, design and coding, Testing presents an interesting
anomaly for the software engineer.
Testing Objectives include:
1. Testing is a process of executing a program with the intent of finding an error.
2. A good test case is one that has a probability of finding an as yet undiscovered
error.
3. A successful test is one that uncovers an undiscovered error.
Testing Principles
1. All tests should be traceable to end user requirements.
2. Tests should be planned long before testing begins.
3. Testing should begin on a small scale and progress towards testing in large
Exhaustive testing is not possible.
4. To be most effective testing should be conducted by an independent third party.
Testing Strategies
A Strategy for software testing integrates software test cases into a series of well
planned steps that result in the successful construction of software. Software testing is a
broader topic for what is referred to as Verification and Validation. Verification refers to
the set of activities that ensure that the software correctly implements a specific function
Validation refers he set of activities that ensure that the software that has been built is
traceable to customers requirements.

7.2. Design of test cases and scenarios

34

This program is limited for only 6 sites when the hardware contains 4GB RAM.
Greater than 6 sites will give the error in output. If number of sites input is given as 0 or
less than 0 than the output will be sites cant be zero or less than zero and if number of
jobs input is given as 0 or less than 0 than output will be jobs cant be zero or less than
0 on console.

7.3. Conclusion
35

A test case, in software engineering, is a set of conditions under which a tester will
determine whether an application, software system or one of its features is working as it was
originally established for it to do. The mechanism for determining whether a software program or
system has passed or failed such a test is known as a test oracle. In some settings, an oracle could
be a requirement or use case, while in others it could be a heuristic. It may take many test cases to
determine that a software program or system is considered sufficiently scrutinized to be released.
Test cases are often referred to as test scripts, particularly when written - when they are usually
collected into test suites.

8. CONCLUSION

36

The entire project has been developed and deployed as per the requirements stated
by the user, it is found to be bug free as per the testing standards that are implemented.
Any specification-untraced errors will be concentrated in the coming versions, which are
planned to be developed in near future. The system at present does not take care of the
money payment methods, as the consolidated constructs need SSL standards and are
critically to be initiated in the first face; the application of the credit card transactions is
applied as a developmental phase in the coming days. The system needs more
elaborative technicality for its inception and evolution.

9. BIBLIOGRAPHY
Text Book References:
Software Engineering

37

Pressman

Programming in C

Balaguruswamy

Internet References:

http://www-personal.acfr.usyd.edu.au/tbailey/ctext/ctext.pdf

http://www1.ximb.ac.in/users/fac/Surya/surya.nsf/23e5e39594c064ee8
52564ae004fa010/0f776dc7f3fe2550652574e2002240df/$FILE/N
%20jobs%20and%20M-%20Machine%20Problem.pdf

http://www.airccse.org/journal/ijdps/papers/0512ijdps25.pdf

https://en.wikipedia.org/wiki/Johnson%27s_rule

http://www.geeksforgeeks.org/job-sequencing-problem-set-1-greedyalgorithm/

38

Вам также может понравиться