design and implementation of automated software … · 1.1 background to the study 1 1.1.2 standard...

129
i DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE FOR THE PUSH AND PULL METHOD OF SOLVING LINEAR PROGRAMMING PROBLEMS. By NZEKWE OSEKOSOR THEOPHILUS MATRIC NO.: AAU/SPS/FNS/11/MSC/03840 DEPARTMENT OF COMPUTER SCIENCE, FACULTY OF PHYSICAL SCIENCES, AMBROSE ALLI UNIVERSITY, EKPOMA, NIGERIA. OCTOBER, 2017

Upload: others

Post on 23-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

i

DESIGN AND IMPLEMENTATION OF AUTOMATED

SOFTWARE FOR THE PUSH AND PULL METHOD OF

SOLVING LINEAR PROGRAMMING PROBLEMS.

By

NZEKWE OSEKOSOR THEOPHILUS

MATRIC NO.: AAU/SPS/FNS/11/MSC/03840

DEPARTMENT OF COMPUTER SCIENCE,

FACULTY OF PHYSICAL SCIENCES,

AMBROSE ALLI UNIVERSITY,

EKPOMA, NIGERIA.

OCTOBER, 2017

Page 2: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

ii

DESIGN AND IMPLEMENTATION OF AN AUTOMATED

SOFTWARE FOR THE PUSH AND PULL METHOD OF

SOLVING LINEAR PROGRAMMPING PROBLEMS.

By

NZEKWE OSEKOSOR THEOPHILUS

MATRIC NO.: AAU/SPS/FNS/11/MSC/03840

M.Sc. Computer Science (A.A.U Ekpoma).

A THESIS IN THE DEPARTMENT OF COMPUTER SCIENCE,

SUBMITTED TO THE SCHOOL OF POSTGRADUATE

STUDIES, IN PARTIAL FULFILLMENT OF THE

REQUIREMENTS FOR THE AWARD OF THE DEGREE OF

MASTERS OF SCIENCE IN COMPUTER SCIENCE, AMBROSE

ALLI UNIVERSITY, EKPOMA, NIGERIA.

OCTOBER, 2017

Page 3: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

iii

CERTIFICATION

This is to certify that this research work titled: Design And Implementation of An

Application Software for the Push And Pull method of Solving Linear Programming

Problems was carried out by NZEKWE, OSEKOSOR THEOPHILUS with Matriculation No:

AAU/SPS/FNS/11/MSC/03840 in the Department of Computer Science, Faculty of Physical

Sciences, School of Post Graduate Studies, Ambrose Alli University, Ekpoma, Edo State,

Nigeria.

……………………………… ….…….……………..

PROF. F. O. IKPOTOKIN DATE

(Supervisor)

Department of Computer Science,

Faculty of Physical Sciences,

Ambrose Alli University, Ekpoma, Nigeria.

……………………………… …..……………..........

PROF. I. B. A. MOMODU DATE

(Head of Department)

Department of Computer Science,

Faculty of Physical Sciences,

Ambrose Alli University, Ekpoma, Nigeria.

……………………………… …..……………..........

External Examiner DATE

Page 4: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

iv

DEDICATION

This thesis work is Dedicate to the Almighty, Holy and Ever Living GOD; My Father, my

Creator, my Maker, my King, my Master, my Healer, my Provider, my Prosperity, my Refuge,

my Righteousness, my Strength, my Deliverer, my Banner, my Rewarder, my peace, my All, my

LORD and my GOD; for HIS Mercy, Protection, and Guidance during the course of the work,

and also to my Parents, Mr and Mrs Christopher N. Ozor J.P.

I THANK YOU MY GOD

Page 5: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

v

ACKNOWLEDGEMENT

My profound gratitude goes to my academic mentor, my career model, and my

Supervisor; Prof. F. O. Ikpotokin, who shepherd me through the course of this work. May GOD

richly bless and reward you for your assistance and excellent patience towards me.

My sincere thanks goes to my parents; Mr. and Mrs. Christopher Nzekwe O. for my

upbringing, their provision and prayers all through my life unto this day, and their wonderful

contributions and financial support towards this program. May GOD richly bless you with long

life to eat the fruit of your labour; Amen.

My sincere acknowledgement goes to my H.O.D., Prof. I. B. A. Momodu, my Internal

Examiner; Dr. S. E. Nnebe, my External Examiner and my Post Graduate Representative. I also

extend my appreciation to other staff and lecturers of Computer Science Department, Ambrose

Alli University, Ekpoma. May GOD Bless you all, Amen.

I will love to express my gratitude to my siblings: Ken, Nkonye, Nicky and Ehi for their

unmatched assistance, love and prayers, and also to my Uncle Chekwube, for his financial

assistance and good wishes, May GOD replenish your purse in a hundred folds. You all lifted my

spirit and gave me joy, GOD Bless you all.

I also wish to appreciate my Uncle and my Aunty, Prof. and Bar. (Mrs.) I.B.A Momodu

for their care and encouragement.

I cannot fail to specially remember and appreciate my friend and my brother; Mr. Eriata

Frank, your contributions. I thank GOD for knowing and meeting you in this life. May GOD

richly bless you and your family and meet you at every point of your need; Amen.

I won’t fail to acknowledge my Pastor, Dr. Dania Steve for his prayers, care and

assistance, may GOD increase you anointing and grant you power to do exploit.

May GOD richly bless you all and every other person that has contributed to the success

of this program, in Jesus Christ’s wonderful and mighty Name: Amen!

Above all, I wish to express my absolute and profound gratitude to GOD Almighty for the

gift of life, good state of mind, soul and body, knowledge, wisdom and understanding throughout

the process of carrying out this thesis work until this day and beyond.

Page 6: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

vi

TABLE OF CONTENTS

TITLE PAGE i

CERTIFICATION iii

DEDICATION iv

ACKNOWLEDGEMENT v

TABLE OF CONTENT vi

LIST OF TABLES viii

LIST OF FIGURES viii

ABSTRACT ix

CHAPTER ONE 1

INTRODUCTION 1

1.1 BACKGROUND TO THE STUDY 1

1.1.2 STANDARD FORMS AND EXPRESSIONS OF LINEAR PROGRAMMING

PROBLEMS 3

1.2 STATEMENT OF RESEARCH PROBLEM 5

1.4 JUSTIFICATION OF THE STUDY 5

1.3 SCOPE OF THE STUDY 7

1.5 AIM OF THE STUDY 7

1.7 DEFINITIONS AND TERMINOLOGIES IN LINEAR PROGRAMMING 7

CHAPTER TWO 9

LITERATURE REVIEW 9

2.1 OVERVIEW OF LINEAR PROGRAMMING 9

2.2 REVIEW OF RELATED WORKS 9

2.3 ALGORITHMS USED IN DEVELOPING LP APPLICATION PROGRAMS 11

2.4 LP APPLICATION SOFTWARE DEVELOPMENT 13

CHAPTER THREE 15

SYSTEM ANALYSIS AND DESIGN 15

3.1 RESEARCH METHODOLOGY 15

3.2 THEORETICAL METHODOLOGY 15

3.3 ANALYSIS OF EXISTING METHODS FOR MANUALLY SOLVING LINEAR

PROGRAMMING PROBLEMS 16

3.4 PROBLEMS OF EXISTING SYSTEMS 17

3.5 ANALYSIS OF THE PROPOSED SYSTEM ALGORITHM 18

3.6 SOFTWARE SYSTEM DESIGN 23

Page 7: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

vii

3.7 ADVANDTAGES OF THE PROPOSED ALGORITHM AND SOFTWARE 27

CHAPTER FOUR 28

IMPLEMENTATION AND RESULTS 28

4.1 MANUAL IMPLEMENTATION WITH NUMERICAL EXAMPLE 28

4.2 APPLICATION PROGRAM USER INTERFACE 29

4.2 COMPUTER IMPLEMENTATION OF NUMERICAL EXAMPLES 32

4.3 DISCUSSION OF RESULT 33

4.4 FINDINGS OF THIS RESEARCH 33

4.5 CONTRIBUTION TO KNOWLEDGE 34

CHAPTER FIVE 35

CONCLUSION AND RECOMMENDATIONS 35

5.1 CONCLUSION 35

5.2 RECOMMENDATION 35

REFERENCE 36

APPENDIX I: APPLICATION INTERFACES

APPENDIX II: MANUAL IMPLEMENTATION AND RESULT OF NUMERICAL

EXAMPLES

APPENDIX III: COMPUTER IMPLEMENTATION AND RESULT OF NUMERICAL

EXAMPLES

APPENDIX IV: PROGRAM SOURCE CODES

Page 8: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

viii

LIST OF TABLES

Table 1. Previous Applications Software design for solving Linear Programming Problems

13

LIST OF FIGURES

Figure 3.1 Flowchart showing the algorithmic strategic process

Figure 3.2 Flowchart showing the algorithmic strategic process of the Simplex method.

Figure 3.3 Software Architecture

Figure 4.1: The Single Problem Menu

Figure 4.2: Definition Tab

Figure 4.3: Result Summary Tab

Figure 4.4: Result Details Tab

Page 9: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

ix

ABSTRACT

This research work focused on solving Linear Programming Problems with the objective of

identifying and reducing the computational complexities or complications involved in solvling

these problems. In this work, we presented two algorithms; the Standard Simplex method and a

newer solution algorithm called Push and Push algorithm. The Simplex method has been one of

the oldest and the best methods for efficiently solving Linear Programming (LP) problems until

recently. In this work, a manual and computerized comparison for the Simplex algorithm and the

Push and Pull algorithm has been achieved. We presented an automated software for the Simplex

and the Push and Pull algorithms for solving a wide range of Linear Programming problems, in

which the computational comparison of the two methods was carried out. The software was

developed using Visual Basic 6.0 on a Visual Studio .NET Framwork 3.5, and on a Windows

Vista operating system. This research work was carried out using theoretical methodology. The

software was designed using an algorithm called, Algorithm Implementation Modules. In the

course of this work, we found out that for LP Problems with ≤ constraints (Maximization cases),

the computational complexity slightly differed, though the Push and Pull method still exhibits

less number of computations, while for LP Problems with constraints (Minimization cases), the

computational complexity greatly differed; with the Push and Pull method having much lesser

number of computations. We therefore concluded that the Push and Pull method is a preferable

alternative to the Simplex method in solving LP problems.

Page 10: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

1

CHAPTER ONE

INTRODUCTION

1.1 BACKGROUND TO THE STUDY

The world of computing is rapidly gaining priority in almost every area of human

endeavour that involves the use of data that can be converted into digital form for processing.

The various branches of computer technology where developed to meet the needs and

requirements of other fields of study such as; mathematics, engineering, business, education,

medicine etc, with mathematics has its closest field. Before the introduction of computer, many

concepts, laws, precepts, procedures and methods in real life situations have been converted into

mathematical models to solve the problems that come along with them. The development and

evolution of computer was to tackle complicated, solvable mathematical problems with great

speed and accuracy. In this work, we looked into Linear Programming, a branch of operation

research in the field of mathematics. We are interested in this topic due to its importance to the

fields of business and economy which are bases of national growth and development. Linear

Programming has become one of the most applied basic forms of optimization for desirable,

expected, realistic and deterministic values which may be an input to or an output from activities

or transaction of profitable field labours, especially in commercial field. Due to the complicated

nature of solving and determining accurate results from linear programming problems, various

methods and algorithms have been developed, and various computer application programs have

been designed and developed using one or more of these methods and algorithms to efficiently

solve such problems with reliable outcomes and speed.

Linear programming is one of the most basic forms of optimization. Its theory and

algorithms can not only be applied to linear optimization problems but also to relaxations of

nonlinear problems and branch-and-bound methods for mixed-integer and global optimization

problems. Frederick et al (2001) stated that the development of linear programming has been

ranked among the most important scientific advances of the mid-20th century, and we must agree

with this assessment. Its impact since just 1950 has been extraordinary. Today, it is a standard

tool that has saved thousands to millions of dollars for most companies or businesses of even

moderate size in the various industrialized countries of the world; and its use in other sectors of

society has been spreading rapidly. A major proportion of all scientific computation on

computers is devoted to the use of linear programming. The Simplex method is one of the oldest,

most widely used, and arguably a remarkable efficient solution procedure for solving linear

programming.

An active research area of linear programming is to construct initial Simplex tableau, and

to improve its pivoting selection strategies efficiently, Vieira and Lins (2005). In this study, we

Page 11: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

2

present a new approach to the problem of initialization and pivoting rules: the algorithm is free

from any artificial variables and artificial constraints, known as the big-M methods. By supplying

the Simplex method without using any large numbers, therefore the result is computationally

stable and provides a better initial basis that reduces the number of pivoting iterations efficiency.

This thesis discusses a new general-purpose solution algorithm, called Push-and-Pull,

which obviates the use of artificial variables. The algorithm consists of preliminaries for setting

up the initialization followed by two main phases. The Push Phase develops a basic variable set

(BVS) which may or may not be feasible. Unlike simplex and dual simplex, this approach starts

with an incomplete BVS initially, and then variables are brought into the basis one by one. If the

BVS is complete, but the optimality condition is not satisfied, then Push Phase pushes until this

condition is satisfied, using the rules similar to the ordinary simplex. Since the proposed strategic

solution process pushes towards an optimal solution, it may generate an infeasible BVS. The Pull

Phase pulls the solution back to feasibility using pivoting rules similar to the dual simplex

method. All phases use the usual Gauss pivoting row operation and it is shown to terminate

successfully or indicates unboundedness or infeasibility of the problem. A computer application

software which is capable of executing the Push-and-Pull and simplex algorithms

simultaneously, and also displaying the computational complexity of each algorithm at the end of

each execution has been presented for this research.

According to Frederick and Gerald (2001), “Linear programming uses a mathematical

model to describe the problem of concern. The adjective linear means that all the mathematical

functions in this model are required to be linear functions. The word programming does not refer

here to computer programming; rather, it is essentially a synonym for planning. Thus, linear

programming involves the planning of activities to obtain an optimal result, i.e., a result that

reaches the specified goal best (according to the mathematical model) among all feasible

alternatives”.

According to Ikpotokin (2012), Linear programming (LP) is essentially a method of

determining an optimum program of the candidates or inter-dependent activities which are

competing for limited resources under assumptions of linearity. He went further to explain that

Linear programming is a type of solution method in Operation Research for solving problems in

order to obtain the best or optimal solution for the problem under various considerations.

Over the years, many authors have presented various application software that are capable

of solving linear programming problems which include; Microsoft Excel solver, Lindo, Lingo,

MATLAB, LiPS, TORA, GLPK, LP_Solve, CLP, SCIP, Cplex, Xpress, Gurobi, etc. These LP

solvers although accurate, but some are strenuous in inputting data items especially for large

variable and constraints, and all are also designed to specifically input linear programming

Page 12: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

3

problem data and give out only desired output. This will not be the case for the proposed or

expected application software that will be presented in this research.

Linear programming is considerably a field of optimization for several reasons. Many

practical problems in operations research can be expressed as linear programming problems.

Certain special cases of linear programming, such as network flow problems and multi-

commodity flow problems are considered important enough to have generated much research on

specialized algorithms for their solution. A number of algorithms for other types of optimization

problems work by solving LP problems as sub-problems. Historically, ideas from linear

programming have inspired many of the central concepts of optimization theory, such

as duality, decomposition, and the importance of convexity and its generalizations. Likewise,

linear programming is heavily used in planning, production, transportation, technology and other

issues. Although the modern management issues are ever-changing, most companies would like

to maximize profits or minimize costs with limited resources. Therefore, many issues can be

characterized as linear programming problems.

A typical example would be taking the limitations of materials and labor, and then

determining the "best" production levels for maximal profits under those conditions.

In "real life", linear programming is part of a very important area of mathematics called

"optimization techniques". This field of study (or at least the applied results of it) is used every

day in organizations and allocation of resources. These "real life" systems can have dozens,

hundreds or more variables. These problems are converted into mathematical model such that

they meet some conditions to become a linear program (LP). The conditions for mathematical

model to become a linear program include;

a. All variables must be continuous. This is to say that all variables may take up fractional

values.

b. There should be a single objective to be maximized or minimized; otherwise, we have a

multi-objective programming problem.

c. The objectives and constraints must be linear; this implies that any term is either a

constant or a constant multiple of an unknown.

1.1.1 STANDARD FORMS AND EXPRESSIONS OF LINEAR PROGRAMMING

PROBLEMS

Standard form simply means is the usual and most intuitive form of description; in this

case, describing a linear programming problem. A linear programming problem consists of the

following three parts:

Page 13: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

4

a. A linear function to be maximized or minimized

f (x1, x2, …., xn) =

………………. (1.1)

b. Problem constraints

….…………… (1.2)

c. Non-negative variables

xj ≥ 0, j = 1, 2, … , n

The problem is usually expressed in matrix form, and then becomes:

Max{cTx | Ax ≤ b, ˅ x 0} ………………. (1.3)

Other forms, such as minimization problems, problems with constraints on alternative

forms, as well as problems involving negative variables can always be rewritten into an

equivalent problem in standard form.

1.1.2 Further Illustration

Suppose that a farmer has a piece of farm land, say L km2, to plant either wheat or barley

or some combination of the two. The farmer has a limited amount of fertilizer, F kilograms, and

insecticide, P kilograms. Every square kilometer of wheat requires F1 kilograms of fertilizer,

and P1 kilograms of insecticide, while every square kilometer of barley requires F2 kilograms of

fertilizer, and P2 kilograms of insecticide. Let S1 be the selling price of wheat per square

kilometer, and S2 be the selling price of barley. If we denote the area of land planted with wheat

and barley by x1 and x2 respectively, then profit can be maximized by choosing optimal values

for x1 and x2. This problem can be expressed with the following linear programming problem in

the standard form:

n

j = 1

aij xij ≤ bi

n

j = 1

cj xj

Page 14: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

5

Maximize: (maximize the revenue—revenue is the

"objective function")

Subject to:

x1 + x2 ≤ L

(limit on total area)

F1 . x1 + F2 . x2 ≤ F (limit on fertilizer)

P1 . x1 + P2 . x2 ≤ P2 (limit on insecticide)

x1 ≥ 0, x2 ≥ 0 (cannot plant a negative area).

Which in matrix form becomes:

Maximize:

subject to:

1.2 STATEMENT OF RESEARCH PROBLEM

Since the creation of the Simplex solution algorithm for Linear Programming (LP)

problems in 1947 by Dantzig, this topic has enjoyed a considerable and growing interest by

researchers and students of many fields. However, experience shows there are still computational

difficulties in solving LP problems in which some constraints are in (≥) form with the right-hand

side (RHS) non-negative, or in ( = ) form.

One version of the simplex known as the two-phase method introduces an artificial

objective function, which is the sum of artificial variables, while the other version adds the

penalty terms which is the sum of artificial variables with very large positive coefficients. The

latter approach is known as the Big-M method.

The simplex algorithm requires artificial variables for solving linear programs, which lack

primal feasibility at the origin point and complicates computational procedures especially for

beginners.

Therefore, an active research area of linear programming is on how to construct simple

and less complex initial tableaus, to improve its pivoting selection strategies efficiently and

reduced computation steps Vieira and Lins (2005).

1.3 JUSTIFICATION OF THE STUDY

It is beyond doubt from theoretical and practical experience that solving Linear

Programming problems involve series of sophisticated steps and procedures that require a lot of

time, focus and diligence to achieve the desired result manually. Sometimes the result may not

still be correct and/or accurate.

Page 15: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

6

Many researchers have proposed different algorithms to identify the redundancies and

have removed them to get a reduced model for linear programming. In 1965, Zionts et al (1983),

suggested some improvements upon the implementation of Boot method, but not to the point

where it achieved practical value. In addition, a number of other methods were developed that

dealt with redundancy, among which the geometric vertex enumeration method is the most well

known. In geometric vertex enumeration method, the essential characteristic is the establishment

of a number of situations in which redundancy can be recognized immediately without further

computations.

According to Arsham et al, (2003), “LP problems, which lack feasibility at the origin

point, have raised difficulties since the beginning of LP. For such problems, the ordinary Simplex

algorithm requires additional variables (i.e., artificial variables) along with large penalty terms in

the objective function. Unfortunately, adding these extraneous variables creates computational

instability and increases the computational complexity”.

In the aspect of computerization, Frederick and Gerald (2001), stated that; a large amount

of computation is usually required to deal most effectively with the complex problems typically

considered by Operations Research (OR). Doing this by hand would often be out of the question.

Therefore, the development of electronic digital computers, with their ability to perform

arithmetic calculations thousands or even millions of times faster than a human being can and

was a tremendous boon to OR.

Paparrizos (1990), introduced an algorithm which avoids the use of artificial variables

through a tedious evaluation of a series of extra objective functions besides the original objective

function. The algorithm checks both the optimality and feasibility conditions after completion of

iterations. He indicates ’’We have not been able to construct such rules’’, for entering and exiting

variables to and from the basic variable set. The pivot and probe type algorithm suggested in

Sethi and Thompson (1984), is much complicated. Spivey and Thrall (1970) also made an

attempt to come up with an algorithm; however it is not for general purpose. Arsham (2003),

introduced an artificial-free algorithm for general linear programs and the classical network

problems.

According to Keil and Jansson (2006), recent research shows that against intuition, bad

condition numbers frequently occur in linear programming. To take this into account, reliability

is required. Here we investigate rigorous results obtained by verification methods. We will

examine different current techniques and software tools for varied linear programming and

compare numerical results for existing implementations. Rounding errors inevitably introduced

by floating point arithmetic can well deteriorate the result of numerical computations. This is

Page 16: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

7

especially true for problems being ill-posed, which 71% of the linear programs in the Netlib

collection are, as observed by Ordonez and Freund (2003).

Moreover, classroom experience shows that some students, particularly non-mathematical

majors, have difficulty in understanding the intuitive notion behind the computational procedure

in performing linear programming operations (especially in minimization cases) (Arsham, 1997).

As information technology has undoubtedly become a more efficient, effective and an accurate

means of carrying out computational jobs, an application program will be presented for this

purpose which will accurately and with consistent output, solve linear programming problems

with great speed compared to manual/traditional application. This will also show the

computational differences between Push and Pull and Simplex method at the end of every

execution of a problem.

1.4 SCOPE OF THE STUDY

This research focused on the design and implementation of an application software that

will solve LP Problems using the Push and Pull and Simplex methods. Further, computational

complexity of Push and Pull algorithm and Simplex methods for solving linear programming

problems has been developed.

1.5 AIM OF THE STUDY

The overall aim of this study is to design, automated software for solving LP Problems

using the Push and Pull algorithm and the Simplex algorithm, while comparing the computational

complexity between the two algorithms.

1.6 OBJECIVES OF THE STUDY

The specific objectives of this research/study are to:

a. design a computer application program to implement the Push and Pull algorithm and

its computational comparison with Simplex method in solving linear programming

problems.

b. show that Push and Pull method, although a new and rarely used algorithm can be

used as a preferable alternative to the Simplex method in solving linear programming

problems in terms of reduced the computational steps and complexity of the Simplex

tableau (especially in minimization cases).

c. compare the computation steps involved in using Push and Pull method and Simplex

method to solve linear programming problem.

1.7 DEFINITIONS AND TERMINOLOGIES IN LINEAR PROGRAMMING

Constraint: A constraint is a condition that must be satisfied by a solution.

Page 17: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

8

Hyperplanes: The hyperplanes described by the equalities ai.x = bi.

Feasible set: A feasible set is the set of points that satisfy all the constraints.

Inequality form: Inequality form is the formulation of the linear programming problem where

all the constraints are weak inequalities ai.x ≤ bi.

Infeasible problem: An infeasible problem is a problem with an empty feasible set.

Linear Equation: A Linear equation is a mathematical expression that has an equal sign and

linear expressions.

Linear Expression: A Linear expression is a mathematical statement that performs functions of

addition, subtraction, multiplication and division.

Linear Programming: Linear Programming is a method of solving problems associated to some

situation with quantifiable entities (input and output values) by converting those values into a

mathematical model that satisfies the requirement of a linear program in order to obtain the best

value/outcome from the situation.

Nondegenerate problem: A non-degenerate problem is a problem where at each vertex

precisely d constraints are tight.

Pivot rule: Pivot rule is the rule by which a neighboring vertex is chosen.

Polytope: A polytope is a geometric object with flat sides, and may exist in any general number

of dimensions n as an n-dimensional polytope of n-polytope.

Random-Edge simplex algorithm: This is a randomized variant of the Simplex method where

the neighboring vertex is chosen uniformly at random.

Simplex Method: Simplex method is a method that seeks an optimal vertex by iteratively

moving from one vertex to a better neighboring vertex for a non-degenerate problem in

inequality form

Strongly polynomial-time algorithm: A strong polynomial-time algorithm is an algorithm for

which the total number of arithmetic operations and comparisons (on numbers whose size is

polynomial in the input length) is bounded by a polynomial in n and d alone.

Tight constraint: A tight constrain is an inequality constraint is tight at a certain point if the

point lies on the corresponding hyperplane.

Unbounded problem: An unbounded problem is a problem with no finite maximum.

Vertex: A vertex is a feasible point where at least the linearly independent constraints are tight.

Page 18: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

9

CHAPTER TWO

LITERATURE REVIEW

2.1 OVERVIEW OF LINEAR PROGRAMMING

Linear programming remains one of the most important forms of optimization in the field

of computing. As exemplified by Lovasz (1980): “If one would take statistics about which

mathematical problem is using up most of the computer time in the world, then (not including

database handling problems like sorting and searching) the answer would probably be linear

programming”. Eugene (1980), of Berkeley summarized: “It [linear programming] is used to

allocate resources, plan production, schedule workers, plan investment portfolios and formulate

marketing (and military) strategies. The versatility and economic impact of linear programming

in today's industrial world is truly awesome”. Looking at the documentation of collections of

linear programming problems like the Netlib LP library reveals such diverse applications as oil

refinery problems, flap settings on aircraft, industrial production and allocation, and image

restoration.

2.2 REVIEW OF RELATED WORKS

Many researchers have proposed different algorithms to identify the redundancies and

removed them to get a reduced model for linear programming. In 1965, Zionts et al (1983),

suggested some improvements upon the implementation of Boot method, but not to the point

where it achieved practical value. In addition, a number of other methods were developed that

dealt with redundancy, among which the geometric vertex enumeration method is the most well

known. In geometric vertex enumeration method, the essential characteristic is the establishment

of a number of situations in which redundancy can be recognized immediately without further

computations.

According to Arsham et al, (2003), “LP problems, which lack feasibility at the origin

point, have raised difficulties since the beginning of LP. For such problems, the ordinary Simplex

algorithm requires additional variables (i.e., artificial variables) along with large penalty terms in

the objective function. Unfortunately, adding these extraneous variables creates computational

instability and increases the computational complexity”.

In the aspect of computerization, Frederick and Gerald (2001), stated that; a large amount

of computation is usually required to deal most effectively with the complex problems typically

considered by OR. Doing this by hand would often be out of the question. Therefore, the

development of electronic digital computers, with their ability to perform arithmetic calculations

thousands or even millions of times faster than a human being can and was a tremendous boon to

Operation Research.

Page 19: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

10

Paparrizos (1990), introduced an algorithm which avoids the use of artificial variables

through a tedious evaluation of a series of extra objective functions besides the original objective

function. The algorithm checks both the optimality and feasibility conditions after completion of

iterations. He indicates ’’We have not been able to construct such rules’’, for entering and exiting

variables to and from the basic variable set. The pivot and probe type algorithm suggested in

Sethi and Thompson (1984), is much complicated. Spivey and Thrall (1970) also made an

attempt to come up with an algorithm; however it is not for general purpose. Arsham (2003),

introduced an artificial-free algorithm for general linear programs and the classical network

problems.

In 1971, Lisy used the rules given by Ziont to identify all redundant constraints in

systems of linear constraints. Gal (1979), enlarged this approach by adding rules for situations in

which constraints can be identified immediately as being nonredundant. Gal proposed another

method to classify constraints as redundant or necessary. They produce results that are

unconditionally correct; they perform iterations of an active set linear programming algorithm.

Later Caron et al (1989) appended the above methods by adding rules to deal with degeneracy.

Brearly et al. (1975), proposed a simple method to identify redundant constraints from a system

of linear constraints. This method involves the lower and upper bounds of the variables. Telgan

(1983), proposed a deterministic method to identify redundant constraints by using minimum

ratio criteria as in simplex method. Stojković and Stanimirović (2001), proposed a method to

identify redundant constraints by applying the maximum and minimum principle.

Paulraj et al. (2006), proposed a heuristic method to identify redundant constraints by

using the intercept matrix of constraints of a linear programming problem. Gutman and Ioslovich

(2007), described a new approach to preprocess nonnegative large-scale problems so as to reduce

the dimensions considerably by defining and removing redundant constraints and variables. This

test is applicable to all nonnegative large-scale linear programming problem with group

constraints. Group constraints only contain zeros and ones coefficients. Constraints and variables

are removed by primal and dual tests. This method is applicable to constraints of knapsack

problems.

According to C. Keil (2006), recent research shows that against intuition bad condition

numbers frequently occur in linear programming. To take this into account reliability is required.

Here we investigate rigorous results obtained by verification methods. We will examine different

current techniques and software tools for varied linear programming and compare numerical

results for existing implementations. Rounding errors inevitably introduced by floating point

arithmetic can well deteriorate the result of numerical computations. This is especially true for

Page 20: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

11

problems being ill-posed, which 71% of the linear programs in the Netlib collection are, as

observed by Ordóñez and Freund (2003).

2.3 ALGORITHMS USED IN DEVELOPING LP APPLICATION PROGRAMS

The available software capable of producing rigorous results for LPs can be categorized

into four groups according to the algorithms they use, these Algorithms include;

a. Verified Constraint Programming,

b. Rational arithmetic,

c. Verified Global Optimization Algorithms using Interval Arithmetic, and

d. Verified linear programming with uncertainties (algorithms specifically designed to

rigorously solve LPs in the presence of rounding errors and uncertainties in the input

data).

2.3.1 VERIFIED CONSTRAINT PROGRAMMING

Algorithms for constraint programming search for points satisfying a given set of

constraints. Rigorous versions return a list of interval vectors (boxes) that may contain feasible

points and a list of boxes that are verified to contain satisfying points. These lists are exhaustive,

if both are empty, the problem is claimed to have no feasible solution.

Constraint programming algorithms do not support the concept of an objective function.

Nevertheless rigorous bounds for the optimal value of an LP can be derived in the following way.

Assume we have an approximation 𝑓 ̅ and choose a small ∆ > 0. Now we applied a verified

constraint programming algorithm to the original set of constraints, adding a constraint on the

objective function of the form cTx ≤ (1−∆). 𝑓.̅ If the algorithm recognizes this set of constraints

to be infeasible, we know (1−∆). 𝑓 ̅to be a rigorous lower bound on the true optimal value. A

rigorous upper bound could be computed using a similar approach for the dual problem with the

additional overhead of explicitly forming the dual in the first place. Obtaining an upper bound

from a box verified to contain feasible points is considerably more involved from an algorithmic

point of view. In the linear programming case the feasible points form a continuum, which is

difficult to handle. Research into this area has only recently begun. An implementation of a

verified constraint programming algorithm is RealPaver in Granvilliers and Benhamou (2006). It

uses a branch-and-prune algorithm, the pruning step merges constraint satisfaction techniques

with the interval Newton method.

2.3.2 RATIONAL ARITHMETIC

Algorithms of this group exploit the fact that the solution of an LP with floating point

(rational) coefficients is itself rational. This has been done by Gaertner (1999) for problems

where either the number of variables or constraints does not go well beyond 30. Dhiflaoui et al

Page 21: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

12

(2003), combined the rational approach with an approximate standard LP solver. They build on

the premise that the approximate optimal basis computed by a standard LP solver is close to the

true optimal one, counting simplex steps. Starting from an approximate basis, they perform

rational simplex steps until they arrive at the true optimum. Koch (2003), provides an

implementation just checking the optimality of a basis together with results on all Netlib

problems. He remarks in cases where the basis proves to be suboptimal, increasing the precision

of the approximate computations may help the LP solver to find the true optimal basis. This

observation in turn has recently been used by Applegate et al. (2006), who iteratively increased

the precision of the approximate computations until the computed basis proves to be optimal.

The implementation by Koch, perPlex (2003), checks the optimality of a given basis but

does not offer any means to compute it in the first place or go on from there if it proves to be

suboptimal. Applegate et al., published their ideas in the solver; QSopt_ex.

2.3.3 VERIFIED GLOBAL OPTIMIZATION

Verified global optimization solvers handle problems with objective function and

constraints defined by smooth algebraic expressions. Thus they can solve LPs rigorously. Their

output consists of candidate and verified to be enclosures of feasible points and an enclosure of

the optimal value or the verified claim that no feasible point exists. Implementations include

COSY, GlobSol, ICOS, and Numerica in Berz et al, Kearfott, Lebbah and Van et al (1997).

COSY uses a branch-and-bound scheme featuring a Taylor model arithmetic for the bounding

step.

2.3.4 VERIFIED LINEAR PROGRAMMING WITH UNCERTAINTIES

Finally there are the algorithms especially designed for verified linear programming in the

presence of rounding errors and uncertainties in the input data. Considering rounding errors in

linear programming goes back to Krawczyk (1975). His aim was to compute a rigorous enclosure

of the optimal solution by verifying the optimality of a basic index set. From this, rigorous

bounds on the optimal value can be derived easily. He also considered errors in the input data,

allowing the algorithm to be applied to problems with interval data. His ideas were used and

refined by Beeck (1978) and Rump(1983). Jansson (1988) introduced means to also handle

degenerate solutions starting from a basic index set and applying a graph search method to a

graph of the adjacent basic index sets. Requiring the solution of interval linear systems, all these

methods share a computational work being cubic in min{m+p, n}. Several years later,

independently and at the same time Neumaier and Shcherbina (2004) and Jansson (2004) devised

methods to rigorously bound the optimal value with a quadratic complexity. This is achieved by

Page 22: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

13

deriving the rigorous bounds from certain duality properties. The output here consists of rigorous

enclosures of the optimal value and feasible but suboptimal points. Neumaier and Shcherbina did

this for the case where finite simple bounds on all variables are known, Jansson also considered

the case of unbounded and free variables.

2.4 LP APPLICATION SOFTWARE DEVELOPMENT

Each of these methods, involves an iterative process from initial to the final stage. The

solution procedure enumerated above are very tasking during manual application or computation.

In addition, Ovuworie and Ikpotokin (1997) considered a heuristics for solving a class of linear

programming problem in one Fell Swap without going through the iterative processes of the

simplex techniques. Other additional work worthy of mention are Ikpotokin and Ovuworie

(2000), Ovuworie and Ikpotokin (2001) and Ikpotokin and Oboro (2004). In the later, a Java

applet was developed for solving any size of linear programming problem.

Earlier, series of application software were developed over the years to enhance the

speed, accuracy, efficiency and effectiveness of solving linear programming problems. Some of

these application software include; Microsoft Excel solver, Lindo, Lingo, iMATLAB, LiPS,

TORA, GLPK, LP_Solve, CLP, SCIP, Cplex, Xpress, Gurobi, etc. A list of some of these

application software are briefly detailed in the table below.

Table 1. Previous Applications Software design for solving Linear Programming Problems

Application Author(s) Language Algorithm Commercial

Status

Platform

APOS 1. Erling D.

Andersen

2. Knud D.

Andersen

C++ Primal-Dual

Interior Point

Dash

Associates

The

Optimisation

Company

Any platform

ASLO Neculai Andrei Fortran Simplex On request,

from authors

Platform

Any machine

with a

reasonable

amount of

memory and

a Fortran.

BPMPD Csaba

Meszaros

FORTRAN Interior point Free PC

CPLEX ILOG CPLEX

Division

FORTRAN,

C++

Primal

Simplex,

Dual

Simplex,

Primal-Dual

Interior Point

Not disclosed Not disclosed

FortMP Mathematical

Programming

Group, Brunel

FORTRAN Simplex

(Primal and

Dual),

Pricing:

Single User

Executable

Platform

DOS,

Win3.x,

Page 23: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

14

University.

Directed by

Professor G.

Mitra.

Interior Point

Method

based on the

Primal-Dual

(Educational)

£1250

Single User

Executable

(lndustrial)

£2500

Win95,

WinNT,

UNIX, AIX

HOPDM Jacek Gondzio FORTRAN

(F77)

Interior Point free PC, Unix

LIPSOL Yin Zhang Matlab 4.2 Interior Point free DEC (Ultrix),

SGI (IRIX

4.1 and 5.2),

Sun Sparcs

LOQO Robert J.

Vanderbei

C++ Interior point Not disclosed Executables

for major

platforms

LP_Solve Michael

Berkelaar

ANSI C Simplex free UNIX, PC

LPABO Prof. Park

Soondal

C Interior point.

Infeasible-

primal-dual

barrier

method with

multiple

centrality

corrections

free PC, UNIX

MOPS Uwe H. Suhl FORTRAN Simplex Not Disclosed any platform

PCx Joe Czyzyk,

Michael

Wagner and

Stephen

Wright

FORTRAN,

C++

Interior Point free Unix

Most of these packages are of commercial status. The few available ones that are free for

public use are demo versions. This means that the complete application for such version is not

available to the public. Hence, large scale application of linear programming packages to

industrial, commercial, education, etc in this country is very limited. As a result, this research

seek to design and develop an application software using the Push and Pull and Simplex

algorithm that could serve as a general purpose software for solving linear programming

problems. Also, linear programming applications although accurate, some are strenuous in

inputting data items especially for large variable and constraints, and most are also designed to

specifically input linear programming problem data and give out only desired output. The

application software for this research will not only aim at improving operation of the former but

will also include the complexity analysis of the Push and Pull and the Simplex method to

determine which solution algorithm is best for solving linear programming problem.

Page 24: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

15

CHAPTER THREE

SYSTEM ANALYSIS AND DESIGN

3.1 RESEARCH METHODOLOGY

System analysis deals with all issues related to the development of systems, and as such,

it is of central importance to the information systems discipline. The system design and analysis

section provides the opportunity for discussing research related to systems development

methodologies and methods used and activities occurring throughout the systems development

life cycle. It may also include; analysis of existing systems, requirements determination,

modeling techniques and languages, agile systems development practices, empirical evaluation of

analysis and design methods, user involvement in systems development, open source

development, design systems architecture, and other technical and organization issues is system

development depending on the area of study.

In academic context, research is used to refer to the activity of diligent and systematic

inquiries or investigations in an area or field of study, with the objective of discovering or

revising facts, theories, applications etc. The major goal of a research is to discover and

disseminate new knowledge.

In computer science research work, there are 3 major methods that can be used in

carrying out a research which include; Experimental Method, Simulation Methods and

Theoretical Method. For the purpose of this research work, we will be using the Theoretical

Method of research.

3.2 THEORETICAL METHODOLOGY

This is a research approach in computer science that is based on the classical

methodology, as they are related to logic and mathematics. Some ideas are the existence of

conceptual and format models (data models and algorithms). Since theoretical computer science

inherits its bases from logic and mathematics, some of the main techniques when dealing with

problems are iteration, recursion and induction. Theory is essential to build methodologies to

develop logical and semantic models and to reason about the programs in order to prove their

correctness. Theoretical computer science is dedicated to the design and algorithm analysis in

order to find solutions or better solutions (e.g. for performance issues). Encompassing all fields

in computer science, the theoretical methodologies also tries to define the limits of computation

and the computational paradigm. In other words we can say that we can use the theoretical

methods to model a new system. However, the theoretical method can help in finding new

mathematical models or theories, but this method still needs other methods to prove the

efficiency of the new models or theories.

Page 25: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

16

In this research work, different information sources such as, textbooks, e-book, journals,

thesis etc, related to linear programming problems were obtained from libraries and the internet.

These provided information on previous works done on linear programming. Furthermore,

various application software for solving Linear Programming Problems were obtained, tested and

reviewed. Some of these application software include; Microsoft Excel solver, Lindo, Lingo,

LiPS, TORA, and LP_Solve.

3.3 ANALYSIS OF EXISTING METHODS FOR MANUALLY SOLVING LINEAR

PROGRAMMING PROBLEMS

a. Simplex Method: The first class of algorithms to solve LPs attempt to find the optimal

solution by searching the boundary of the constraint polytope. These methods use ”pivot

rules” to determine the next direction of travel once a basic point is reached. If no direction

of travel yields an improvement to the objective function, then the basic point is the optimal

solution. The first algorithm to use this idea was the Simplex Method from George Dantzig in

1947. Though these methods perform well in practice, it is not known if any “pivot rule”

algorithm can run in polynomial time. In particular, an example has been given that takes

exponential time using the Simplex Method.

i. Primal Simplex Method: Starting with feasible basis, look for optimal basis while

keeping feasibility.

ii. Dual Simplex Method: Starting with optimal basis, look for feasible basis while keeping

optimality

b. Polynomial Time Algorithm: The first polynomial time algorithm for solving an LP was

derived from the Ellipsoid Method of Shor, Nemirovsky, and Yudin. This algorithm provides

a way of finding a feasible solution to an optimization problem. The idea is to enclose

feasible solutions in an ellipse. Then, check to see center of the ellipse is a feasible solution.

If not, find a violating constraint using a separation oracle. Then, enclose the half of the

ellipse where the feasible solutions must lie in another ellipse. Since this next ellipse is at

least a fixed constant times smaller, by repeating we are able to hone in on a solution

exponentially fast. Khachiyan was able to adapt this method of finding a feasible solution to

give a polynomial time solution to LPs. Though this result was a breakthrough in the theory,

the algorithm usually takes longer than the Simplex Method in practice.

c. Interior Point Method: The next class of algorithms for solving LPs are called ”interior

point” methods (also referred to as barrier methods). As the name suggests, these algorithms

start by finding an interior point of the constraint polytope and then proceeds to the optimal

solution by moving inside the polytope.

Page 26: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

17

A subset P of ℜn is a polytope if P is the convex hull of finite number of vectors.

Therefore

3x1,...,x t∈ℜn

s.t.

P = convex({x1,...,x t}).

Interior point methods are a certain class of algorithms to solve linear and nonlinear convex

optimization problems. The interior point method was invented by John von Neumann. Von

Neumann suggested a new method of linear programming, using the homogeneous linear

system of Gordan (1873) which was later popularized by Karmarkar's algorithm, developed

by Narendra Karmarkar in 1984 for linear programming. The method consists of a self-

concordant barrier function used to encode the convex set. Contrary to the Simplex method, it

reaches an optimal solution by traversing the interior of the feasible region. His method is not

only polynomial time like the Ellipsoid Method, but it also gave good running times in

practice like the Simplex Method.

d. Active Set Method: The active set is particularly used in optimization theory as it determines

which constraints will influence the final result of optimization. For example, in solving the

linear programming problem, the active set gives the hyperplanes that intersect at the solution

point.

There are other solution algorithms that are also used in solving linear programming

problems which are not mentioned here.

3.4 PROBLEMS OF EXISTING SYSTEMS

The existing systems for solving Linear Programming Problems (LPP), has some inherent

problems. Some of these problems associated with manual methods and algorithms in solving

Linear Programming Problems include;

a. The Simplex method makes use of extraneous variables, which can lead to too many

tableaus and more than normal iterations.

b. The Graphical method is limited to LP problems involving two decision variables and a

limited number of constraints due to the difficulty of graphing and evaluating more than

two decision variables. The restriction severely limits the use of the graphical method for

real-world problems.

The aforementioned problems above makes linear programming difficult for instructors to

teach and for students (especially those with poor mathematical background or non-mathematics

majors) to understand.

Page 27: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

18

In the same vain, some problems associated with the existing applications software for

solving Linear Programming Problems include;

a. Most computerized LPP solvers such as Microsoft Excel are very stressful and difficult to

use, especially when it comes to entering large variables and constrains.

b. Existing LPP solvers have limited number of variables and constraints they can

accommodate.

c. Existing LPP solvers have limited result details and summary

3.5 ANALYSIS OF THE PROPOSED SYSTEM ALGORITHM

The Push and Pull Algorithm

The proposed solution algorithm is a three-phase simplex-type method, which avoids the

use of large numbers known as Big-M’s. It combines the primal and dual simplex method;

however it uses parts of objective function as an auxiliary objective function whenever necessary

to locate a corner point. In phase 1 some constraints are relaxed to make the origin being feasible

(if possible). After solving the relaxed problem using the current solution as the starting point,

Phase 2 applies the dual simplex to solve the original problem while Phase 3 applies the primal

simplex. Whenever the feasible region is unbounded, in Phase 1 the origin is served as the

starting point for Phase 2 to generate a proper corner point by using a ‘‘temporary’’ objective

function. Phase 3 restores the original objective function and applies the primal simplex rule to a

conclusion. Our initial experimental study with some small size problems indicates that the

proposed algorithm is more efficient than both the primal and the dual simplex in terms of the

number of iterations.

3.5.1 ALGORITHM REPRESENTATION AND IMPLEMENTATION

The New Solution Algorithm

Consider any LP problem in the following standard form:

Max ∑ nj=1 CjXj

subject to

AX(≤, =, ≥) B ; X ≥ 0 and B ≥ 0 ………….. 1)

A is the respective matrix of constraint coefficients, and B is the respective RHS vectors

(all with appropriate dimensions). This LP problem can be rewritten in the form

Max CX

subject to

Max ∑ nj=1 Aj Xj = Bj; Xj ≥ 0 …………... 2)

Without loss of generality we assume all the Right Hand Side (RHS) elements are non-

negative. We will not deal with the trivial cases such as when A = 0, (no constraints) or B = 0 (all

Page 28: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

19

boundaries pass through the origin point). The customary notation is used: Cj for the objective

function coefficients (known as cost coefficients), and X = {Xj} for the decision vector.

3.5.2 PROCESS FOR THE NEW SOLUTION ALGORITHM

Solving LP problems in which some constraints are in ( ≥ ) form, with the right-hand side

(RHS) non-negative, or in ( = ) form, has been difficult since the beginning of LP. One version of

the Simplex method, known as the two-phase method, introduces an artificial objective function,

which is the sum of the artificial variables. The other version is the Big-M method which adds a

penalty term, which is the sum of artificial variables with very large positive coefficients. Using

the dual Simplex method has its own difficulties. For example, when some coefficients in the

objective function are not dual feasible, one must introduce an artificial constraint. Also handling

( = ) constraints is very tedious.

The algorithm consists of preliminaries for setting up the initialization followed by three

main phases: Push, Push Further, and Pull phases. The Push Phase develops a basic variable set

(BVS), which may or may not be feasible. Unlike simplex and dual simplex, this approach starts

with an incomplete BVS initially, and then variables are brought into the basis one by one. If the

BVS is complete, but the optimality condition is not satisfied, then Push Further Phase pushes

until this condition is satisfied. This strategy pushes towards an optimal solution. Since some

solutions generated may be infeasible, the next step, if needed, the Pull Phase pulls the solution

back to feasibility. The Push Further Phase satisfies the optimality condition, and the Pull Phase

obtains a feasible and optimal basis. All phases use the usual Gauss pivoting row operation.

3.5.2.1 THE INITIAL TABLEAU

Construct a table called initial tableau for inputting data for the variables and constraints

respectively. The initial tableau may be empty, partially empty, or contain a full basic variable set

(BVS).

3.5.2.2 PHASES IN THE NEW SOLUTION ALGORITHM

After constructing the initial tableau, the proposed scheme goes further to consist of the

following three strategic phases:

The Push Phase: Fill-up the BVS completely by pushing it toward the optimal corner point,

while trying to maintain feasibility.

The Push Further Phase: If the BVS is complete, but the optimality condition is not satisfied,

then push further until this condition is satisfied.

The Pull Phase: If pushed too far in Phase I, pull back toward the optimal corner point (if any).

If the BVS is complete, and the optimality condition is satisfied but infeasible, then pull back to

the optimal corner point; i.e., a dual simplex approach.

Page 29: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

20

Note: Not all LP problems must go through the Push, Push further and Pull sequence of steps, as

will be shown in the numerical examples letter in this work.

3.5.2.3 PRELIMINARIES

To start the algorithm the LP problem, the following preliminaries are necessary:

a) There must be a maximization problem

b) RHS must be non-negative

c) All variables must be non-negative and all inequality constraints (except the non-

negativity conditions) should be converted into equalities by introducing slack/surplus

variables.

a) Convert into a maximization problem: If the problem is a minimization problem convert it

to maximization by multiplying the objective function by -1. By this operation the optimal

solution remains the same, then use the original objective function to get the optimal value by

substituting the optimal solution.

b) RHS must be non-negative: Any negative RHS can be converted by multiplying it by -1 and

changing its direction if it is an inequality, optimal solution remains unchanged. To avoid the

occurrence of a possible degeneracy, convert all inequality constraints with RHS = 0 into 0

by multiplying each one of them by -1.

c) All variables must be non-negative: Convert any unrestricted variable Xj to two non-

negative variables by substituting y − Xj for every Xj everywhere. This increases the

dimensionality of the problem by one only (introduce one y variable) irrespective of how

many variables are unrestricted. If there are any equality constraints, one may eliminate the

unrestricted variable(s) by using these equality constraints. This reduces dimensionality in

both number of constraints as well as number of variables. If there are no unrestricted

variables do remove the equality constraints by substitution, this may create infeasibility. If

any Xj variable is restricted to be non-positive, substitute y−Xj for Xj everywhere.

3.5.3 PSEUDOCODE AND FLOWCHART SHOWING THE PROCESS OF THE PUSH

AND PULL ALGORITHM

The following three phases is the Pseudocode that describe how the algorithm works. It

terminates successfully for any type of LP problems since there is no loop-back between the

phases.

The Push Phase:

Step 1. Introducing slack or surplus variables, convert all inequalities (except non-negativity)

constraints into equalities. The coefficient matrix must have full row rank, since otherwise either

no solution exists or there are redundant equations.

Step 2. Construct the initial tableau containing all slack variables as basic variables.

Page 30: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

21

a. If it is a maximization problem, then go to step 3.

b. If it is a Minimization problem, multiply All Cj by -1

Step 3. Generate a basic variable (BV) set, not necessarily feasible, as follow:

i. Incoming variable is Xj with the largest Cj (the coefficient of Xj in the objective function, it

could be negative), and if possible with smallest non-negative C/R. Otherwise try the next

variable to enter. If there are alternatives, break the ties arbitrarily.

ii. Is Xj the last variable to enter into BV set? If yes, enter it into the empty row and generate the

next tableau (if impossible to pivot, go to Step 3(1) and choose the next Cj) and go to Step 4.

Otherwise its row position is the row having the smallest non-negative C/R. Do not consider

the rows, which are already occupied. If there are alternative, break the ties arbitrarily.

Generate the next tableau and go to Step 3(1). If there is no positive C/R, then select the row

having smallest non-negative C/R.

Step 4. Are all Cj 0 in the current tableau? If yes, go to Step 5a; otherwise go to Step 5b.

The Push Further Phase:

Step 5b. Use the standard simplex pivoting rule:

1. Identify incoming variable (having largest Cj).

2. Identify outgoing variable (with the smallest non-negative C/R). If none, unbounded

solution. (If more than one choose any one, this may be the sign of degeneracy.) Generate the

next tableau and go to Step 4. If Step 5b fails, then go to step 7a.

Step 7a If all RHS 0 , then the optimal solution is unbounded. Stop

The Pull Phase:

Step 5a. Are all RHS 0 in the current tableau? If yes, go to Step 8. Otherwise go to Step 6.

Step 6. Use the dual simplex pivoting rules to identify the outgoing variable (smallest RHS).

Identify the incoming variable having negative coefficient in the pivot row in the current tableau,

if there are alternatives choose the one with the smallest positive row ratio (R/R), [that is, a new

row with elements: row Cj/pivot row]; if otherwise generate the next tableau and to Step 5a. If

Step 6 fails, then go to Step 7b.

Step 7b. The problem is infeasible. Stop.

Step 8. This is the optimal solution, which could be unbounded. Find out all multiple solutions if

they exist (the if the number of Cj = 0 is larger than the size of the BV set, this is a necessary

condition).

Page 31: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

22

Figure 3.1 is the flowchart showing the algorithmic strategic process of the Push and Pull

algorithm.

Figure 3.1: Flowchart showing the algorithmic strategic process for the Push and Pull Algorithm.

Proof: The general LP problem is deformed into a sequence of sub-problems, each of which is

handled by either simplex or dual simplex as appropriate. The proof that these algorithms

terminate successfully is well known. The details of the deformation and reformation of the

problem is given in sufficient detail that the proof that the algorithm works and terminates

successfully for all cases becomes obvious.

Notice that the proposed algorithm starts with a basic solution to the sub-problem and

then reduces the dual and primal infeasibility in phases II and III, respectively. The algorithm

Page 32: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

23

takes advantage of the optimal solution available from the previous iteration (i.e. re-optimization

rather that solving each problem from any scratches). Figure 3.2 is the Flowchart showing the

process of the simplex method.

Figure 3.2: Flowchart showing the algorithmic strategic process of the Simplex method.

3.6 SOFTWARE SYSTEM DESIGN

In this section we presented the software architecture and the computer implementation

system, which is developed to enable the reader to run one or both algorithms, Push-and-Pull and

simplex, for solving different linear programming problems. The system also creates a

comparison analysis between the two algorithms.

3.6.1 SOFTWARE ARCHITECTURE

Software application architecture is the process of defining a high level structured

solution that meets all the technical and operational requirements, while optimizing common

Page 33: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

24

quality attributes such as performance, security, and manageability. It can be seen as a single or a

set of structures needed to describe the software system, which comprises the software elements,

the relationship between them, and the properties of both elements and relation. Figure 3.3 shows

the software application architecture for the proposed software system.

Figure 3.3: Software Architecture of the developed system

3.5.2 PLATFORM AND PROGRAMMING LANGUAGE SOURCE CODE

The programming language source code that will be used for developing this application

is Visual Basic 6.0 (as shown in APPENDIX IV), and on a Visual Studio .NET framework 3.5.

The program design and coding will be on a Window Vista operating system. Data values for the

problem will be inputted into textboxes and grids, and the result or solution will be outputted on

grids and Labels. The compiled version of the application should be able to run on all recent

window operating system platforms and architecture.

3.6.3 OVERVIEW OF APPLICATION SYSTEM

The system is object oriented; its functionality is based on the object structure, that

consists of main functional objects, accompanied by useful supporting objects. The system is

event-driven: the objects mostly communicate amongst themselves as well as the graphical user

interface elements (user controls); thus by raising and watching for certain events.

User can communicate with the system through a graphical user interface. It is a multi

window interface consisting of three main windows with their own functional purpose and

1b

1a

2

3

4

5

6

7

Repository UTILITY MODULE

Constants

Enumerators

Subs and Function

ANALYSIS MODULE

Efficient separation of

problem for each

methods

PIVOTING MODULE

Gaussian Pivoting and

other support functions

Push & Pull Simplex

Push & Pull Simplex

Problem

Definition

Table

SINGLE LPP

HANDLER

MODULE

Problem

Execution

RESULT

Summary

Details

Push & Pull Simplex

Events

Events

USER INTERFACE AUTOMATED WORKFLOW SYSTEM ENGINE

Page 34: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

25

elements. Most of elements are User Controls: controls designed to fit the exact problem or

deliver the exact functionality. That enhances the usability of the graphical user interface, and

accompanied with appliance of error management using error handling routines, makes the

system more stable and robust.

There is an on-line help integrated in the system, which can be easily accessed and can

provide useful information to the user about the system and how to use it.

3.6.4 DATA ORGANIZATION AND MANAGENENT

Data is organized in three groups: definition data, result summary data and result detailed

data. The definition and result summary data for each linear programming problem are stored in

one plain text file. The first part of the file contains general data of the problem such as name,

source and some comments. The second part contains data of the objective function, number of

constraints, number of variables, equalities and inequalities and right hand side values. The third

and/or fourth parts of the file are created when one or both algorithms were executed. They

represent the result summary data. The data consists of the algorithm’s name, the status of the

result, optimal value of objective function (if exists), basic variable set BVS values, objective

function variables x(j) values, degeneracy indicator, different efficiency counters (number of

iterations, additions / subtractions, multiplications / divisions, loops and decisions), time stamp

and the result detailed file name. Detailed result shows a step-by-step algorithm execution by

recording relevant data like basic variable sets, tableaus, outgoing, incoming variables and

comments explaining the previous and/or next action for each iteration. All data files and data

operations are handled by a subsystem called the Repository. User communicates with the

Repository subsystem through the graphical user interface, especially through the Repository

window which is explained in detailed later. That means that users need not worrying about data

handling operations, data structure or file locations – the Repository subsystem does all that,

including the creation of all required subfolders if they do not exist already.

3.6.5 ANALYSIS OF SYSTEM ALGORITHM

The two algorithms are implemented in separate modules (MS Visual Studio, MS Visual

Basic). There are actually three modules. The first two main modules implement iterative loops,

one for Push-and-Pull algorithm and the other for ordinary simplex algorithm. The third is a

supporting module with Gauss pivoting row operations.

The system uses a predefined algorithm called Algorithm Implementation Modules. This

is carried out by calling a single module procedure (subroutine), which acts as the module entry

point. The parameter passed is a reference to the problem object, where the results are stored and

returned to the system. The advantage of the modular implementation algorithm lies in the

Page 35: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

26

possibility of using the DLL (Dynamic Link Library) technology. With little system redesign,

user (i.e. programmers using Visual Basic 6.0 enhanced version) could write their own

implementations and compile them to a DLL. That would enable these programmers to test,

analyze and use their own implementations for any number of variable and constraint.

3.6.6 OBJECT STRUCTURE

3.6.6.1 MAIN OBJECTS

A group of main objects is used to handle linear programming problems as a whole, from

problem definition to the results given by each (Push-and-Pull as well as ordinary simplex)

algorithm. Classes representing those objects are: Problem, Problem Definition and Problem

Result. The Problem class is a parent class for Problem Definition and Problem Result classes

and represents a single problem on a higher level. It consists of methods that support operations

like creating new problem object structure and its initiation, methods for working with reading

and writing data from files as well as methods that cause different ways of displaying a problem.

The class through its properties holds information about a problem object structure, by

maintaining references to child objects, and links to user interface, by maintaining references to

user controls that handle different ways of displaying a problem data.

The Problem Definition class is a child of the Problem Class. It handles problem

definition data in detail. Its methods support operations like reading and writing the definition-

part of problem data to file (in collaboration with its parent objects r/w methods) as well as

definition data editing with data validation. Contained information consists of values defining a

linear problem. The Problem Result class is also a child of the Problem Class. It has two

instances, for each linear programming algorithm one. It handles problem result data in detail

through methods that support read/write operations as well as different display operations for the

result-part data. The information the class keeps consists of algorithm result data - both summary

and detailed.

3.6.6.2. SUPPORTING OBJECTS

Functionality of the system is enhanced by useful supporting objects such as various

counters, sorted lists and result detailed file handlers represented by Counters, Output Detail File,

Sorted List and Item in Sorted List Class.

The Counters Class is a part of each Result Class. Its function is to handle and store

analytic-purpose counters: iteration, addition / subtraction, multiplication / division, loop and

decision count.

The Output Detail File Class is a part of each Result Class. Its function is to handle

write-to-file operations during the linear programming algorithm run. Output is a result detailed

file.

Page 36: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

27

The Sorted List Class is involved with Push-and-Pull algorithm execution. It is a simple

class representing a sorted list of elements. Its role in the System is to maintain and handle the Cj

values as a sorted list. The elements of the list consist of the Item in Sorted List Class objects.

The Item in Sorted List Class is a part of the Sorted List Class. It represents a single

element with its value and reference to the next element in the list.

3.7 ADVANDTAGES OF THE PROPOSED ALGORITHM AND SOFTWARE

This section discusses the advantages of the new solution algorithm: the Push and Pull

algorithm and software developed to carry out the computational complexity over existing

methods and software.

3.7.1 ADVANTAGES OF THE PROPOSED ALGORITHM

The advantages of the proposed algorithm are;

a. Formulating the initial tableau is easier especially for minimization problems.

b. It is free from artificial variables in solving minimization problems which greatly reduces

complexity of the tableau and the data contained in it.

c. It is easier to use, teach and understand since it is free from all the troubles that come with

introducing artificial variables.

3.7.2 ADVANTAGES OF THE PROPOSED APPLICATION SOFTWARE

The advantages of the proposed application software are;

a. Friendly user interface.

b. Supports up to 1000+ variables and constraints.

c. Displays the computation complexity at the end of each executed problem.

d. The application can run on any Windows Operating System platform.

e. It requires low system memory usage.

Page 37: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

28

CHAPTER FOUR

IMPLEMENTATION AND RESULTS

4.1 MANUAL IMPLEMENTATION WITH NUMERICAL EXAMPLE

In this chapter, we discussed the results of implementing the Push and Pull algorithm and

the Simplex method, using manual method and also using the application program designed for

the purpose of carrying out this work. Both results for the proposed algorithm and the Simplex

method will be placed side by side each other for clear comparison in the Appendix section.

Below are some of the hands-on examples we carried out on some linear programming

problems.

Example 1:

Minimize Z = 3X1 + 2.5X2

S.T: 2X1 + 4X2 ≥ 40

3X1 + 2X2 ≥ 50

X1 , X2 ≥ 0

Example 2:

Minimize Z = 2X1 + 2X2 – 5X3

S.T: 3X1 + 2X2 – 4X3 = 7

X1 – X2 + 3X3 = 2

X1, X2, X3, ≥ 0

Example 3:

Maximize Z = 4X1 + 6X2 + 10X3 + 12X4

S.T: X1 + X2 + 2X3 + 4X4 ≤ 5

X1 + 3X2 + 5X3 + 3X4 ≤ 15

X1, X2, X3, X4 ≥ 0

Example 4:

Minimize Z = X1 + 2X2 + 0X3 - X 4

S.T: X1 - X2 + 3X3 + 0X4 = 1

0X1 + 2X2 - 4X3 + 2X4 = 2

3X1 + X2 + X3 + 4X4 = 7

X1, X2, X3, X4 ≥ 0

Example 5:

Minimize Z = X1 + 3X2 + 4X3 + 10X4

S.T: X1 + 0X2 + X3 + X4 ≥ 10

0X1 + X2 + 2X3 + 2X4 ≥ 25

X1 + 2X2 + 0X3 + X4 ≥ 20

X1, X2, X3, X4 ≥ 0

The figures in Appendix II show the manual computation of the numerical examples of

the above five (5) linear programming problems involving both Maximization and Minimization

cases. Its is obvious that the Simplex method uses (in most cases) more number of tableaus, and

these tableaus are usually more complicated (especially in Minimization cases) than the Push and

Page 38: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

29

Pull method. The simplicity and lightness of the tableaus in Push and Push algorithm as seen

above is because it lacks any;

a. extraneous artificial variables,

b. artificial objective function,

c. extraneous objective functions and

d. artificial constraint.

We can also see that both methods use the Gaussian elimination method for pivoting elements of

the tableau.

4.2 APPLICATION PROGRAM USER INTERFACE

The application user interface is a computer window element that displays the

components of an application software that allows the user to interact with the computer and the

application software. In the following subsections, we discussed the main window and its

subcomponents.

4.2.1 THE MAIN WINDOW

The main window of the application user Interface is a multi-document interface, using an

MDI Form (the Main Window) as a container for three functional windows: the Repository

Window and the Single Problem Window (which further contains three (3) tabs; Definition,

Result Summary and Result Details tab) as can be seen (highlighted in red) in Figures below.

The Main Window Interface of the application program is shown in Appendix I. The code

for activating the operation of the Main Window is seen in Appendix IV (page 70).

4.2.2 REPOSITORY WINDOW

The Repository Window serves as an interface between the user and the Repository sub-

system, which, as mentioned above, handles all data storage operations. It has a problem-level

approach, meaning, that the main tasks concern a problem as a whole. Those tasks are selecting,

opening, creating new, renaming, duplicating, adding to analysis, and deleting problems.

As is shown in Appendix I, the Repository Window, beside a standard window bar,

consists of three main elements: the Repository Menu, the Trash Bin and the Problems

Repository List. The code is seen in Appendix IV (on page 71).

The Repository Menu is a MyActiveLabels user-control with menu options that execute

the Repository tasks.

The Trash Bin is a MyFileListView user control. It acts as a container for deleted

problems. With some Repository Menu options they can become permanently deleted or can be

restored to the Problem Repository.

The Problem Repository is a MyFileListView user control, too. It is the main Repository

display element, showing the collection of existing problems. With other Repository Window

elements it takes care of the execution of the Repository sub-system tasks.

Page 39: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

30

The Repository Window Interface of the application program is also shown in

Appendix I.

4.2.3 SINGLE PROBLEM WINDOW

The purpose of the Single Problem Window is to help the user to work with single

(selected) problem and its details more easily. It consists, as is shown in Appendix I, of four main

elements (beside a standard window bar with the name of currently opened problem): the Single

Problem Menu, the Definition, Result Summary and Result Details area.

The Single Problem Window Interface of the application program is also shown in

Appendix I. The code for initiating and activating this window is seen in Appendix IV, page 71,

and under the program comment; ‘activate the sinlge problem window.

The Single Problem Menu as shown in Figure 4.1 helps executing tasks, such as saving

and printing selected problem, and executing and resetting results for selected algorithms. It

consists of a MyActiveLabels and MyCheckLabels usercontrols. The problem general variables

area is located immediately under the menu. It consists of six general variables, defining the

linear programming problem: the objective function, the number of variables, the number of

constraints, the problem name and two comment variables (the source of the problem and a

general comment the user can give to the problem). All those variables can be edited, with

exception of the problem name.

Figure 4.1 The Single Problem Menu

The Definition tab as shown in Figure 4.2, contains the Problem Definition Tableau. It is based

on a MyGrid user-control, and displays the problem definition in detail. The Tableau can be

easily edited.

Figure 4.2: Definition Tab

Page 40: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

31

Figure 4.3 shows the Result Summary tab which contains the Result Summary Table (it is also

based on a MyGrid user-control) where the characteristic result values for one or both algorithm

are displayed. There is also a column added, that displays a calculated difference between

algorithm results.

Figure 4.3: Result Summary Tab

The Result Details tab contains a MyRichTextBox user-control. This control shows the contents

of both algorithm detail files (empty, if it does not exists) for currently opened single problem. It

displays the problem equation, the tableaus, notes and result of every executed problem as shown

below in Figure 4.4.

Figure 4.4: Result Details Tab

Page 41: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

32

4.2 COMPUTER IMPLEMENTATION OF NUMERICAL EXAMPLES

In this section, we displayed the result of the computerized implementation of some of the

numerical examples initially carried out manually. Below are the examples of the linear

programming problems;

Example 1:

Minimize Z = 3X1 + 2.5X2

S.T: 2X1 + 4X2 ≥ 40

3X1 + 2X2 ≥ 50

X1 , X2 ≥ 0

Example 2:

Minimize Z = 2X1 + 2X2 – 5X3

S.T: 3X1 + 2X2 – 4X3 = 7

X1 – X2 + 3X3 = 2

X1, X2, X3, ≥ 0

Example 3:

Maximize Z = 4X1 + 6X2 + 10X3 + 12X4

S.T: X1 + X2 + 2X3 + 4X4 ≤ 5

X1 + 3X2 + 5X3 + 3X4 ≤ 15

X1, X2, X3, X4 ≥ 0

Example 4:

Minimize Z = X1 + 2X2 + 0X3 - X 4

S.T: X1 - X2 + 3X3 + 0X4 = 1

0X1 + 2X2 - 4X3 + 2X4 = 2

3X1 + X2 + X3 + 4X4 = 7

X1, X2, X3, X4 ≥ 0

Example 5:

Minimize Z = X1 + 3X2 + 4X3 + 10X4

S.T: X1 + 0X2 + X3 + X4 ≥ 10

0X1 + X2 + 2X3 + 2X4 ≥ 25

X1 + 2X2 + 0X3 + X4 ≥ 20

X1, X2, X3, X4 ≥ 0

The figures in Appendix III also show the computerized computation of the numerical

examples of the above five (5) linear programming problems involving both Maximization and

Minimization cases. It is seen that the Simplex method uses (in most cases) more number of;

tableaus, operators (Plus, minus, multiplication and division), iterations, and loops, but with less

decisions. On the other hand, it is seen that the Push and Pull algorithm uses (in most cases) less

number of; tableaus, operators, iterations, and loops, but with more decisions.

Page 42: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

33

4.3 DISCUSSION OF RESULT

4.3.1 EXPECTED OUTCOME OF THE DEVELOPED APPLICATION SOFTWARE

The expected outcome of the developed application software is as follows;

i. To generate the tableaus for each iteration involved in the process of executing a roblem.

ii. To display the result of each executed problem, which may include; the actual desired

solution or problems associated with solving linear programming problems such as;

degenerate and unbounded solution.

iii. To display the computational complexity of the Push and Pull algorithm and the Simplex

method after the successful execution of each problem.

4.4 FINDINGS OF THIS RESEARCH

In this research word, we found out that:

i. The algorithm’s working space is the space of the original variables. The tableau is

simpler since the row operations are performed directly on Cj ’s. Additionally, there is no

need for the reduced cost row (known as Cj − Zj). The proposed algorithm has simplicity

and potential for wide adaptation by instructors. The entire variables are the natural parts

of the LP problem: decision variables (Xj), and the slack/surplus variable (Si) for

resource/production types of constraints respectively, with significant managerial and

economical meanings and applications.

ii. The proposed solution algorithm is a general-purpose method for solving any LP type

problems. More specialized methods exist that can be used for solving LP problems with

specific structure. The new algorithm is most suitable for LP problems with a large

number of equality (=) and/or production constraints (_), such as network models with

lower bound on their arc capacities.

iii. It is well known that the initial basic solution by the primal simplex could be far away

from the optimal solution. The BVS augmentation concept which pushes toward faces of

the feasible region which may contain an optimal rather than jumping from a vertex to an

improved adjacent one to provide a ”warm-start”.

iv. A computer implementation system is developed to enable the reader to run one or both

algorithms. The system also creates a detailed and comparison analysis between Push-

and-Pull and ordinary simplex.

Page 43: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

34

4.5 CONTRIBUTION TO KNOWLEDGE

In this research work, we have contributed to the knowledge of our society in the following

ways:

i. We have introduced a new solution algorithm for solving linear programming problem –

the Push and Pull algorithm, which is a better alternative to the well known and widely

used Simplex method.

ii. Because it lacks extraneous variables, it will support easy teaching for tutors of this area

(teachers and lecturers), easy learning for students and simpler for users to apply.

iii. The computer application program presented in this research will enable users to solve a

wide range of LPP, with appreciable speed, and with very large variables and constraints.

iv. User of the application program will be able to have detailed and summarized result of

every program they execute.

Page 44: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

35

CHAPTER FIVE

CONCLUSION AND RECOMMENDATIONS

5.1 CONCLUSION

LP problems, which lack feasibility at the origin point, have raised difficulties since the

beginning of LP. For such problems, the ordinary simplex algorithm requires additional variables

(i.e., artificial variables) along with large penalty terms in the objective function. Unfortunately,

adding these extraneous variables creates computational instability and increases the

computational complexity. Moreover, classroom experience shows that some students,

particularly non-mathematical majors, have difficulty in understanding the intuitive notion of

such requirements.

We proposed a new general solution algorithm, which is easy to understand, and it is free

from any extraneous variables. The algorithm consists of two major phases and an optional third

phase (the Push Further phase). The Push Phase uses the rules similar to the ordinary simplex in

generating a basic variable set (BVS). The Pull Phase (if needed) generates a BVS which is the

optimal (if it exists). The algorithm working space is the space of the original variables with a

geometric interpretation of its strategic process.

5.2 RECOMMENDATION

A comparative study has also been done, which compares Push-and-Pull to ordinary

simplex. The result of this study shows that the new proposed algorithm is preferable and faster

than the well known Simplex method, especially in solving minimization problems. At this stage,

a convincing evaluation for the reader would be the application of this approach to a problem

he/she has solved by any other methods.

The application software is recommended for tutors and students for further research in

this field, because of;

i. the elaborate details and summary associated with every executed linear programming

problem carried out.

ii. its ability to accommodate very large number of problem variables and constraints.

Page 45: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

36

REFERENCES

Andersen E. D. and Andersen K. D., (1995): Presolving in linear programming. Mathematical

Programming, Series B, vol. 71, no. 2, pp. 221–245.

Applegate D. L., Cook W., Dash S., and Espinoza D. G. (2006): Exact solutions to linear

programming problems. Submitted to Operations Research Letters.

Arsham H . (2007): A computationally stable solution algorithm for linear programs. Applied

Mathematics and Computation 188 (2007) 1549–1561

Arsham H. (1997): Initialization of the simplex algorithm: An artificial-free approach, SIAM

Review, 39(4): 736-744.

Arsham H., Cimperman G. B., Damij N. C., Damij C. T., Grad J. D. (2003): A Computer

Implementation of a Computationally Stable Algorithm and its Comparison With the

Simplex method.

Balinski M. L. (1961): An algorithm for finding all vertices of convex polyhedral sets. Journal of

the Society for Industrial and Applied Mathematics, vol. 9, no. 1, pp. 72–88.

Beasley J. E. (1990): Distributing test problems by electronic mail. Journal of Operational

Research Society, vol. 41, pp. 1069–1107.

Beeck H. (1978): Linear Programming with Inexact Data. Tech. Rep. 7830, Abteilung

Mathematik, TU München.

Berz M. (2015): COSY. World Wide Web. http://www.bt.pa.msu.edu/index_files/cosy.htm

(2015).

Boneh A., Boneh S., and Caron R. J. (1993): Constraint classification in mathematical

programming. Mathematical Programming, vol. 61, no. 1, pp. 61–73.

Boot J. C. G. (1962): On trivial and binding constraints in programming problems,”

Management Science, vol. 8, no. 4, pp. 419–441.

Brearley A. L., Mitra G., and Williams H. P. (1975): Analysis of mathematical programming

problems prior to applying the simplex algorithm. Mathematical Programming, vol. 8, pp.

54–83. View at Publisher · View at Google Scholar.

Caron R. J., McDonald J. F., and Ponic C. M., (1989): A degenerate extreme point strategy for

the classification of linear constraints as redundant or necessary. Journal of Optimization

Theory and Applications, vol. 62, no. 2, pp. 225–237.

Dhiflaoui M., Funke S., Kwappik C., Mehlhorn K., Seel M., Schömer E., Schulte R., and Weber

D. (2003). Certifying and repairing solutions to large LPs how good are LP-solvers?, in

SODA, pp. 255-256.

Page 46: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

37

Eugene L. (1980). Linear Programming in Economic Development. University of California,

Berkeley.

Frederick S. H. and Gerald J. L. (2001): Introduction to Operations Research.7th Edition.

Published by McGraw-Hill, an imprint of The McGraw-Hill Companies, Inc., 1221

Avenue of the Americas, New York. Pp 2.

Frederick S. H. and Gerald J. Lieberman (2001): Introduction to operation research. 7th ed, pp.

24.

Gal T. (1979): Weakly redundant constraints and their impact on post optimal analysis.

European Journal of Operational Research, vol. 60, pp. 315–326.

Gärtner B. (1999): Exact arithmetic at low cost – a case study in linear programming,

Computational Geometr. pp. 121 – 139.

Granvilliers L. and Benhamou F. (2006): Algorithm 852: RealPaver: An Interval Solver using

Constraint Satisfaction Techniques. ACM Transactions on Mathematical Software, 32,

pp. 138-156. http://doi.acm.org/10.1145/1132973.1132980 (2015).

Greenberg H. J. (1996): Consistency, redundancy, and implied equalities in linear systems.

Mathematics and Artificial Intelligence, vol. 17, pp. 37–83.

Gutman P. O. and Isolovich I. (2007): Robust redundancy determination and evaluation of the

dual variables of linear programming problems in the presence of uncertainty, on the

generalized wolf problem: preprocessing of nonnegative large scale linear programming

problems with group constraints. Technion-Israel Institute of Technology, vol. 68, no. 8,

pp. 1401–1409.

Ikpotokin F. O. (2012): Introduction to the study of Operations Research Techniques. Thommy

Prints & Co. Ekpoma, Edo State, Nigeria.

Ikpotokin F. O. and Oboro H. A. (2004): A Java Algorithm code for solving linear Programming

Problems. Advances in Natural and Applied Sciences Research, Vol. 2, No. 1, Pp 148 –

159.

Ikpotokin F. O.and Ovuworie G. C. (2000): Simultaneous Computation of a Simplified Product

form of the Inverse and Shadow Price Elements. Nigerian Journal of Engineering

Management, Vol. 2, No. 1, Pp. 55 – 64.

Jansson C. (1988): A Self-Validating Method for Solving Linear Programming Problems with

Interval Input Data. Computing, Suppl. 6 , pp. 33-45.

Jansson C. (2004): Rigorous Lower and Upper Bounds in Linear Programming. SIAM J.

Optimization (SIOPT), 14 , pp. 914-935.

Junior H., and Lin S. (2005): An improved initial basis for the Simplex algorithm, Computers &

Operations Research, 32(8).

Page 47: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

38

Kearfott R. B.: GlobSol. World Wide Web. http://interval.louisiana.edu (2015).

Keil C. (2006): Lurupa - Rigorous Error Bounds in Linear Programming, in Algebraic and

Numerical Algorithms and Computer-assisted Proofs, B. Buchberger, S. Oishi, M. Plum,

and S. Rump, eds., no. 05391 in Dagstuhl Seminar Proceedings, Internationales

Begegnungsund Forschungszentrum fuer Informatik (IBFI), Schloss Dagstuhl, Germany.

http://drops.dagstuhl.de/opus/volltexte/2006/445 (2015).

Keil C. and Jansson C. (2006), Computational Experience with Rigorous Error Bounds for the

Netlib Linear Programming Library, Reliable Computing, 12, pp. 303-321.

Koch T. (2003): Perplex. World Wide Web. http://www.zib.de/koch/perplex (2015).

Koch T. (2003): The final netlib-lp results. Tech. Rep. 03-05, Konrad-Zuse-Zentrum für

Informationstechnik Berlin, Takustraÿe 7, D-14195 Berlin-Dahlem, Germany.

Krawczyk R. (1975): Fehlerabschätzung bei linearer Optimierung, in Interval Mathematics. K.

Nickel, ed., vol. 29 of Lecture Notes in Computer Science, Springer Verlag, Berlin, pp.

215-222.

Lebbah Y.: ICOS (Interval COnstraints Solver). World Wide Web.

http://www.essi.fr/lebbah/icos/index.html (2015).

Lisy J. (1971): Metody pro nalezini redundantnich omezeni vulohach linerniho programovani.

Ekonomicko Matematics. Obzor, vol. 7, no. 3, pp. 285–298.

Lovasz L. (1980): A New Linear Programming Algorithm - Better or Worse Than the Simplex

Method?, The Mathematical Intelligencer. pp. 141-146.

Maros I. (2002): Computational Techniques of the Simplex Method. Kluwer Publishers.

Mattheis T. H. (1973), “An algorithm for determining irrelevant constraints and all vertices in

systems of linear inequalities,” Operations Research, vol. 21, pp. 247–260.

Netlib problems (2015): http://ftp.zib.de/pub/mp-testdata/madlib/node2.html.

Netlib, Netlib Linear Programming Library (2015): http://www.netlib.org/lp

Neumaier A. (2004), Complete Search in Continuous Global Optimization and Constraint

Satisfaction. Acta Numerica, 13, pp. 271-369.

Neumaier A.and Shcherbina O. (2004): Safe bounds in linear and mixed-integer programming.

Mathematical Programming, Ser. A, 99, pp. 283-296.

Ordonez F. and Freund R. M. (2003): Computational experience and the explanatory value of

condition measures for linear optimization. SIAM J. Optimization. pp. 307-333.

Ovuworie G. C. and Ikpotokin F. O. (1997): A new and Efficient Heuristics for solving A class of

Linear Programming Problems. Journal of Peace Research and Conflict Resolution, Vol.

1 No. Pp. 70 – 91, National War College, Abuja, Nigeria.

Page 48: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

39

Ovuworie G. C. and Ikpotokin F. O. (2001): In search of a Non-Iterative Technique for solving A

Class of Linear Programming Problem. Nigerian Journal of Engineering Management,

Vol. 2, Pp. 24 – 33.

Papparrizos K. (1990): The two phase simplex without artificial variables. Methods of

Operations Research 61:73–83

Papparrizos K. (1990): The two phase simplex without artificial variables, Methods of

Operations Research, 61, 73–83

Paulraj S., Chellappan C., and Natesan T. R. (2006): A heuristic approach for identification of

redundant constraints in linear programming models. International Journal of Computer

Mathematics, vol. 83, no. 8-9, pp. 675–683.

Roos C., Terlaky T., and Vial J. (1997): Theory and Algorithms for Linear Optimization: An

Interior Point Approach, Wiley, UK.

Rump S. M. (1983): Solving Algebraic Problems with High Accuracy. Habilitationsschrift, in A

New Approach to Scientic Computation, U. Kulisch and W. Miranker, eds., Academic

Press, New York, pp. 51-120.

Sethi A. and Thompson G. (1984): The pivot and probe algorithm for solving a linear program,

Mathematical Programming 29:219–233.

Spivey A. and Thrall W. (1970): Linear Optimization. Holt, Rinehart & Winston, London.

Stojković N. V. and Stanimirović P. S. (2001): Two direct methods in linear programming.

European Journal of Operational Research, vol. 131, no. 2, pp. 417–439. View at

Publisher · View at Google Scholar · View at Zentralblatt MATH · View at MathSciNet.

https://www.ams.org/mcom/1994-63-208/S0025-5718-1994-1250776-4/ (1994).

Telgan J. (1983): Identifying redundant constraints and implicit equalities in system of linear

constraints. Management Science, vol. 29, no. 10, pp. 1209–1222. View at Zentralblatt

MATH. https://www.hindawi.com/journals/mpe/2010/723402/ (2010).

Thompson G. L., Tonge, F. M. and Zionts S. (1996): Techniques for removing nonbinding

constraints and extraneous variables from linear programming problems. Management

Science, vol. 12, no. 7, pp. 588–608.

Van Hentenryck P., Michel P., and Deville Y. (1997): Numerica; A Modelling Language for

Global Optimization. MIT Press Cambridg.

Vieira H. Jr., Lins M. (2005): An improved initial basis for the simplex algorithm, Computers &

Operations Research 32.

Vu X. H., Sam-Haroud D., and Silaghi M. C. (August, 2002): Approximation techniques for non-

linear problems with continuum of solutions, in Proceedings of The 5th International

Symposium on Abstraction, Reformulation and Approximation (SARA'2002), R. C. H.

Page 49: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

40

Sven Koenig, ed., vol. LNAI 2371 of Lecture Notes in Computer Science - Lecture Notes

in Artificial Intelligence, Canada, Springer-Verlag, pp. 224-241.

Zionts S., Karwan M. H., Lotfi V.and Telgen J. Eds. (1983): Redundancy in Mathematical

Programming: A State-of-the-Art Survey. Springer, Berlin, Germany.

Zionts S. (1965): Size of reduction techniques of linear programming and their applications.

Dissertation, Carnegie Institute of Technology.

Page 50: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

41

APPENDIX I

APPLICATION INTERFACES

The Main Window Interface: The first interface that is displayed when the program is run.

Page 51: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

42

The Repository Window: This window displays saved problem examples which can be executed at ease.

The Single Problem Window: This window consist of all that is required to enter the data of a given

problem.

Page 52: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

43

APPENDIX II

MANUAL IMPLEMENTATION AND RESULT OF NUMERICAL EXAMPLES

Figure 1: NUMERICAL EXAMPLE 1

Page 53: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

44

Figure 2: NUMERICAL EXAMPLE 1 Cont.

Page 54: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

45

Figure 3: NUMERICAL EXAMPLE 2

Page 55: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

46

Figure 4: NUMERICAL EXAMPLE 2 Cont.

Figure 5: NUMERICAL EXAMPLE 3.

Page 56: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

47

Page 57: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

48

Figure 6: NUMERICAL EXAMPLE 3 Cont.

Page 58: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

49

Figure 7: NUMERICAL EXAMPLE 4

Page 59: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

50

Figure 8: NUMERICAL EXAMPLE 4 Cont.

Page 60: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

51

Figure 9: NUMERICAL EXAMPLE 5

Page 61: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

52

Figure 10: NUMERICAL EXAMPLE 5 Cont.

Page 62: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

53

APPENDIX III

COMPUTER IMPLEMENTATION AND RESULT OF NUMERICAL EXAMPLES

Page 63: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

54

Page 64: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

55

Page 65: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

56

NUMERICAL EXAMPLE 2

Page 66: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

57

Page 67: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

58

Page 68: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

59

NUMERICAL EXAMPLE 3

Page 69: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

60

Page 70: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

61

NUMERICAL EXAMPLE 4

Page 71: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

62

Page 72: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

63

Page 73: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

64

Page 74: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

65

NUMERICAL EXAMPLE 5

Page 75: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

66

Page 76: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

67

Page 77: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

68

Page 78: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

69

APPENDIX IV

PROGRAM SOURCE CODES

‘ SPLASH SCREEN Option Explicit Private CountDown As Long Private Sub Form_Activate() CountDown = 8 lblTimer.Caption = CountDown End Sub Private Sub Form_Click() Unload Me End Sub Private Sub Form_KeyPress(KeyAscii As Integer) Unload Me End Sub Private Sub Frame1_Click() Unload Me End Sub Private Sub imgLogo_Click() Unload Me End Sub Private Sub Label1_Click() Unload Me End Sub Private Sub Label3_Click() End Sub Private Sub lblCompanyProduct_Click() Unload Me End Sub Private Sub lblProductName_Click() Unload Me End Sub Private Sub lblWarning_Click() Unload Me End Sub Private Sub Timer1_Timer() CountDown = CountDown - 1 lblTimer.Caption = CountDown If CountDown <= 0 Then Unload Me End Sub

Page 79: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

70

' MODULE MAIN: ENTRY POINT OF THE APPLICATION Public lastOpenProblemDir As String ' store last open directory Public lastImportProblemDir As String ' store last import directory Public lastSaveProblemDir As String ' store last save directory Public lastSaveAnalysisDir As String ' store last save directory Public selectedProblemFolder As String ' selected problem folder: adding to analysis Public RepositoryFolder As String Public TrashFolder As String Public runningExe As Boolean ' ' application entry point ' Public Sub Main() runningExe = (App.EXEName = "SixPap") Dim devTest As String devTest = IIf(runningExe, "", "\..") ' ModuleMain.RepositoryFolder = App.Path & devTest & "\Repository" ModuleMain.RepositoryFolder = App.Path & "\Repository" ModuleMain.TrashFolder = RepositoryFolder & "\Trash" ' App.HelpFile = App.Path & devTest & "\SixPap.hlp" App.HelpFile = App.Path & "\SixPap.hlp" ' test for nexessary folder existance, create if don't exist If Dir(RepositoryFolder, vbDirectory) = "" Then MkDir RepositoryFolder If Dir(RepositoryFolder & "\Solutions", vbDirectory) = "" Then MkDir RepositoryFolder & "\Solutions" If Dir(TrashFolder, vbDirectory) = "" Then MkDir TrashFolder If Dir(TrashFolder & "\Solutions", vbDirectory) = "" Then MkDir TrashFolder & "\Solutions" ' lastSaveProblemDir = App.Path & devTest & "\Problems" ' lastOpenProblemDir = App.Path & devTest & "\Problems" ' lastImportProblemDir = App.Path & devTest ' lastSaveAnalysisDir = App.Path & devTest & "\Analyses" ' selectedProblemFolder = App.Path & devTest & "\Problems" FormSplash.Show 1 Load FormMain Load FormSingleProblem Load FormAnalysis Load FormRepository FormMain.Show ' FormMain.SetDefaultPosition ' FormSingleProblem.NewProblem FormRepository.SetFocus End Sub ' MDI FORM MAIN: APPLICATION CONTAINER Private ArrangeState As Integer ' type of child windows arranging ' load main form

Page 80: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

71

Private Sub MDIForm_Load() MenuWindowArrange_Click 3 End Sub Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) If Not FormSingleProblem.TestCurrentForSave Then Exit Sub End End Sub ' Main form resize ' Private Sub MDIForm_Resize() If Me.WindowState <> 1 Then MenuWindowArrange_Click ArrangeState End If End Sub ' exit application Private Sub MenuExit_Click() If Not FormSingleProblem.TestCurrentForSave Then Exit Sub End End Sub ' ' Activate help ' Private Sub MenuHelpInstructions_Click() With CommonDialogHelp .HelpFile = App.HelpFile .HelpContext = 1 .HelpCommand = cdlHelpContext .ShowHelp End With End Sub ' ' menu Repository click ' Private Sub MenuRepository_Click() FormRepository.SetFocus If FormRepository.WindowState = 1 Then FormRepository.WindowState = 0 End Sub ' ' ACTIVATING THE SINGLE PROBLEM WINDOW ' Private Sub MenuProblem_Click() FormSingleProblem.SetFocus If FormSingleProblem.WindowState = 1 Then FormSingleProblem.WindowState = 0 End Sub

Page 81: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

72

' ' activate the analysis window ' Private Sub MenuAnalysis_Click() FormAnalysis.SetFocus If FormAnalysis.WindowState = 1 Then FormAnalysis.WindowState = 0 End Sub ' ' arrange windows ' Private Sub MenuWindowArrange_Click(Index As Integer) If Index < 3 Then Me.Arrange Index Else SetDefaultPosition End If ArrangeState = Index End Sub ' ' show about box ' Private Sub MenuHelpAbout_Click() FormAbout.Show 1, Me End Sub ' ' set default position of the child forms ' Public Sub SetDefaultPosition() Dim tempWidth As Long With FormRepository .Show .WindowState = 0 .Move 0, 0, FormRepository.SignificantWidth, Me.ScaleHeight End With With FormSingleProblem .Show .WindowState = 0 tempWidth = Me.ScaleWidth - FormRepository.Width If tempWidth > 0 Then _ .Move FormRepository.Width, 0, tempWidth, Me.ScaleHeight / 2 End With With FormAnalysis .Show .WindowState = 0 tempWidth = Me.ScaleWidth - FormRepository.Width If tempWidth > 0 Then .Move FormRepository.Width, Me.ScaleHeight / 2, _ tempWidth, Me.ScaleHeight / 2 End With FormRepository.SetFocus Docked = True End Sub

Page 82: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

73

' MODULE: UTILITY CONSTANTS, ENUMERATORS, SUBS AND FUNCTIONS ' error number constants: ClassProblemDefinition Public Const errorNumberDefinitionFile = 2000 ' handling definition file error Public Const errorNumberBadData = 2001 ' bad data input (reading data) ' error number constants: ClassProblemResult Public Const errorNumberDetailFile = 3000 ' detail file error Public Const errorNumberDefinitionAppend = 3001 ' append to definition file error Public Const errorNumberReadResultData = 3002 ' open read result file error ' error number constants: ModuleUtilities Public Const errorNumberStringToArray = 4000 ' convert string to array error Public Const errorNumberOpenFile = 4001 ' error opening file ' enumerating method Public Enum EnumMethod UnknownMethod = 0 PushPull = 1 Simplex = 2 End Enum ' enumerating result statuses Public Enum EnumStatus UnknownStatus = -1 NotCalculated Optimal Infeasible Unbounded MaxIterationsExceeded TestFailed Trivial End Enum ' enumerating file name return style Public Enum EnumReturnFileNameStyle returnFileFull returnFilePath returnFileName returnFileExtension returnNameInFile End Enum ' enumerating open file modifiers Public Enum EnumOpenFileAccess openForInput openForOutput openForAppend End Enum ' enumerating counters Public Enum EnumCounter

Page 83: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

74

cntIterations = 0 cntAddSubs = 1 cntMultDivs = 2 cntLoops = 3 cntDecis = 4 cntUnknown = 9 End Enum ' return string representation for counter type Public Function EnumCounterAsStr(EnumCntCode As EnumCounter, _ Optional Short As Boolean = False) As String Select Case EnumCntCode Case EnumCounter.cntIterations: EnumCounterAsStr = IIf(Short, "Iter.", "iterations") Case EnumCounter.cntAddSubs: EnumCounterAsStr = IIf(Short, "+/-", "adds/subs") Case EnumCounter.cntMultDivs: EnumCounterAsStr = IIf(Short, "*/÷", "mults/divs") Case EnumCounter.cntLoops: EnumCounterAsStr = IIf(Short, "Loop", "loops") Case EnumCounter.cntDecis: EnumCounterAsStr = IIf(Short, "Dec.", "decisions") Case Else: EnumCounterAsStr = IIf(Short, "Unknown", "unknown counter") End Select End Function ' ' convert string to enum counter type ' Public Function StrAsEnumCounter(EnumString As String) As EnumCounter Select Case EnumString Case EnumCounterAsStr(cntIterations, True), EnumCounterAsStr(cntIterations) StrAsEnumCounter = cntIterations Case EnumCounterAsStr(cntAddSubs, True), EnumCounterAsStr(cntAddSubs) StrAsEnumCounter = cntAddSubs Case EnumCounterAsStr(cntMultDivs, True), EnumCounterAsStr(cntMultDivs) StrAsEnumCounter = cntMultDivs Case EnumCounterAsStr(cntLoops, True), EnumCounterAsStr(cntLoops) StrAsEnumCounter = cntLoops Case EnumCounterAsStr(cntDecis, True), EnumCounterAsStr(cntDecis) StrAsEnumCounter = cntDecis Case Else: StrAsEnumCounter = cntUnknown End Select End Function ' ' make an exact duplicate of an array ' Public Function CloneArray(sourceArray) Dim newCloneArray() ReDim newCloneArray(LBound(sourceArray, 1) To UBound(sourceArray, 1)) Dim i As Long For i = LBound(sourceArray, 1) To UBound(sourceArray, 1) newCloneArray(i) = sourceArray(i) Next i CloneArray = newCloneArray End Function ' copy contetns of one array to another '

Page 84: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

75

Public Sub CopyArray(sourceArray, _ targetArray, _ defaultValue, _ Optional preserveValues As Boolean = True) Dim i As Long For i = LBound(targetArray, 1) To UBound(targetArray, 1) If (i >= LBound(sourceArray, 1)) And _ (i <= UBound(sourceArray, 1)) And _ (preserveValues) Then ' CopyValue targetArray(i), sourceArray(i) GetFormatted targetArray(i), sourceArray(i) Else targetArray(i) = defaultValue End If Next i End Sub ' ' copy values from one matrix to another ' Public Sub CopyMatrix(sourceMatrix, _ targetMatrix, _ defaultValue, _ Optional preserveValues As Boolean = True) Dim i As Long, j As Long For i = LBound(targetMatrix, 1) To UBound(targetMatrix, 1) For j = LBound(targetMatrix, 2) To UBound(targetMatrix, 2) If ((i >= LBound(sourceMatrix, 1)) And (i <= UBound(sourceMatrix, 1))) And _ ((j >= LBound(sourceMatrix, 2)) And (j <= UBound(sourceMatrix, 2))) And _ (preserveValues) Then ' CopyValue targetMatrix(i, j), sourceMatrix(i, j) GetFormatted targetMatrix(i, j), sourceMatrix(i, j) Else targetMatrix(i, j) = defaultValue End If Next j Next i End Sub ' create exact copy of a matrix ' Public Function CloneMatrix(sourceMatrix) Dim newCloneMatrix() ReDim newCloneMatrix(LBound(sourceMatrix, 1) To UBound(sourceMatrix, 1), _ LBound(sourceMatrix, 2) To UBound(sourceMatrix, 2)) Dim i As Long, j As Long For i = LBound(sourceMatrix, 1) To UBound(sourceMatrix, 1) For j = LBound(sourceMatrix, 2) To UBound(sourceMatrix, 2) newCloneMatrix(i, j) = sourceMatrix(i, j) Next j Next i CloneMatrix = newCloneMatrix End Function

Page 85: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

76

' controled copying of values: mostly because of confusion with ' international use of character used with decimal numbers (usually char . or char ,) ' Public Sub CopyValue(var1, var2) On Error GoTo errorCopyValue Select Case TypeName(var1) Case "Double", "Single", "Decimal", "Currency" var1 = Val(var2) Case Else var1 = var2 End Select Exit Sub errorCopyValue: Err.Raise Err.Number, , Err.Description & _ NewLine("Value assignment error: " & _ var1 & "(" & TypeName(var1) & ") to " & _ var2 & "(" & TypeName(var2) & ")") End Sub ' create array based on martix row ' Public Function GetMatrixRowAsArray(rowIndex As Long, _ sourceMatrix) Dim newRowAsArray() ReDim newRowAsArray(LBound(sourceMatrix, 2) To UBound(sourceMatrix, 2)) Dim j As Long For j = LBound(sourceMatrix, 2) To UBound(sourceMatrix, 2) newRowAsArray(j) = sourceMatrix(rowIndex, j) Next j GetMatrixRowAsArray = newRowAsArray End Function ' create array based on martix column ' Public Function GetMatrixColumnAsArray(columnIndex As Long, _sourceMatrix) Dim newColumnAsArray() ReDim newColumnAsArray(LBound(sourceMatrix, 1) To UBound(sourceMatrix, 1)) Dim i As Long For i = LBound(sourceMatrix, 1) To UBound(sourceMatrix, 1) newColumnAsArray(i) = sourceMatrix(i, columnIndex) Next i GetMatrixColumnAsArray = newColumnAsArray End Function ' read next line from file, return parameter name and value ' Public Function GetParameter(fileID As Long, _ByRef parameterValue) As String GetParameter = "" Dim buffer As String: buffer = "unread line" Dim p As Long Line Input #fileID, buffer p = InStr(1, buffer, ":") If p > 0 Then GetParameter = Trim(LCase(Left(buffer, p - 1)))

Page 86: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

77

parameterValue = Trim(Mid(buffer, p + 1)) End If Exit Function errorGetParameter: Err.Raise Err.Number, , "Error reading parameter." & _ Err.Description & _ NewLine("Line: " & buffer) End Function ' ' simple test if file is problem definition file ' Public Function IsProblemDefinition(fullFileName As String) As Boolean On Error GoTo errorIsProblemDefinition Dim fileID As Long: fileID = OpenFile(fullFileName, openForInput) Dim buffer As String: Line Input #fileID, buffer IsProblemDefinition = (Left(Trim(buffer), 5) = "name:") Close #fileID Exit Function errorIsProblemDefinition: If fileID > 0 Then Close #fileID Err.Raise Err.Number, Err.Source, "Testing for Problem DefinitionFile", _ NewLine("File: " & fullFileName), _ NewLine(Err.Description) End Function ' ' return string with capital first characters ' Public Function PascalType(original As String) As String PascalType = "" Dim i As Long, SpaceDetected As Boolean: SpaceDetected = True For i = 1 To Len(original) If SpaceDetected Then PascalType = PascalType & UCase(Mid(original, i, 1)) SpaceDetected = False Else PascalType = PascalType & LCase(Mid(original, i, 1)) End If SpaceDetected = (Mid(original, i, 1) = " ") Next i End Function ' ' redimension array, keep old values add default if new is larger ' Public Sub ReDimArray(inputArray, _ newLowerBound As Long, _ newUpperBound As Long, _ defaultValue, _ Optional preserveValues As Boolean = True) If newUpperBound < newLowerBound Then Exit Sub Dim buffer() buffer = CloneArray(inputArray) ReDim inputArray(newLowerBound To newUpperBound) CopyArray buffer, inputArray, defaultValue, preserveValues

Page 87: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

78

End Sub ' ' redimension array, keep old values add default if new is larger ' Public Sub ReDimMatrix(inputMatrix, _ newRowLowerBound As Long, _ newRowUpperBound As Long, _ newColLowerBound As Long, _ newColUpperBound As Long, _ defaultValue, _Optional preserveValues As Boolean = True) If newRowUpperBound < newRowLowerBound Then Exit Sub If newColUpperBound < newColLowerBound Then Exit Sub Dim buffer() buffer = CloneMatrix(inputMatrix) ReDim inputMatrix(newRowLowerBound To newRowUpperBound, _ newColLowerBound To newColUpperBound) CopyMatrix buffer, inputMatrix, defaultValue, preserveValues End Sub ' ' test if item exists in collection ' Public Function ExistsInCollection(objectCollection As Collection, _ objectKey, _ Optional returnObject As Object) _ As Boolean On Error GoTo errorExistsInCollection ExistsInCollection = True Set returnObject = objectCollection(objectKey) Exit Function errorExistsInCollection: ExistsInCollection = False End Function ' ' merge a par of arrays ' Public Function MergeArrays(leftArray, _ rightArray) Dim buffer() ReDim buffer(LBound(leftArray) To UBound(leftArray) + (UBound(rightArray) - LBound(rightArray)) + 1) Dim i As Long, j As Long j = LBound(leftArray) For i = LBound(buffer) To UBound(buffer) If i = UBound(leftArray) + 1 Then j = LBound(rightArray) If i <= UBound(leftArray) Then buffer(i) = leftArray(j) Else buffer(i) = rightArray(j) End If j = j + 1 Next i

Page 88: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

79

MergeArrays = buffer End Function ' ' fill matrix row from given array Public Sub SetMatrixRowFromArray(rowIndex As Long, _sourceArray, _targetMatrix) Dim j As Long For j = LBound(targetMatrix, 2) To UBound(targetMatrix, 2) GetFormatted targetMatrix(rowIndex, j), sourceArray(j), True Next j Exit Sub End Sub ' ' return desired part of array as array ' Public Function PartOfArray(sourceArray, _ startIndex As Long, _ endIndex As Long) Dim resultArray(): ReDim resultArray(1 To (endIndex - startIndex + 1)) Dim j As Long For j = LBound(resultArray) To UBound(resultArray) resultArray(j) = sourceArray(startIndex + j - 1) Next j PartOfArray = resultArray End Function ' ' return string with CRLF at the beggining ' Public Function NewLine(newLineText As String) As String NewLine = Chr(13) & Chr(10) & newLineText End Function ' return string of characters "-" Public Function PrintLine(Optional lineLen = 50) As String PrintLine = String(lineLen, "-") End Function ' ' return string containing given parameter with spaces on left or right ' Public Function Spaces(inString, _ length As Long, _ Optional position = "> | <") As String Dim buffer As String: buffer = inString buffer = Trim(buffer) position = Left(position, 1) If Len(buffer) >= length Then Spaces = buffer Else Select Case Left(position, 1) ' first char because of default value, which is showing possible values as well ' as giving the default value: > Case ">": Spaces = Right(Space(length) & buffer, length) Case "<": Spaces = Left(buffer & Space(length), length)

Page 89: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

80

Case "|" Dim divide As Long: divide = Int((length - Len(buffer)) / 2) Spaces = String(divide, ".") & buffer & String(length - Len(buffer) - divide, ".") Case Else: Spaces = buffer End Select End If End Function ' ' fill array from string delimited with spaces ' Public Sub StringToArray(ByVal sourceString As String, _ targetArray, _ Optional delimiter As String = " ", _ Optional readFromFileFormat As Boolean = False) On Error GoTo errorStringToArray Dim i As Long Dim p As Long Dim newValue As Variant Dim buffer As String buffer = Trim(sourceString) & delimiter p = InStr(1, buffer, delimiter) i = LBound(targetArray) - 1 Do While p > 0 i = i + 1 If i > UBound(targetArray) Then Err.Raise vbObjectError + errorNumberStringToArray, "ProjectSixPap.ModuleUtilities", _ "Source string longer than target array." & _ NewLine("Array length: " & UBound(targetArray) - LBound(targetArray) + 1) End If newValue = Left(buffer, p - 1) buffer = Mid(buffer, p + Len(delimiter)) GetFormatted targetArray(i), newValue, True p = InStr(1, buffer, delimiter) Loop Exit Sub errorStringToArray: Err.Raise Err.Number, , "String to Array." & _ NewLine("String: '" & sourceString & "'") & _ NewLine(Err.Description) End Sub ' ' create space delimited string from array ' Public Function ArrayToString(sourceArray, _ Optional delimiter As String = " ", _ Optional formatForWriteToFile As Boolean = False) _ As String Dim i As Long: i = LBound(sourceArray) Dim buffer As String: buffer = GiveFormatted(sourceArray(i), formatForWriteToFile) For i = LBound(sourceArray) + 1 To UBound(sourceArray) buffer = buffer & delimiter & GiveFormatted(sourceArray(i), formatForWriteToFile) Next i

Page 90: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

81

ArrayToString = buffer End Function ' ' return string representation for enumerated method ' Public Function EnumMethodAsString(method As EnumMethod) As String Select Case method Case PushPull: EnumMethodAsString = "PUSH AND PULL" Case Simplex: EnumMethodAsString = "STD. SIMPLEX" Case Else: EnumMethodAsString = "UNKNOWN METHOD" End Select End Function ' ' return string representation for open access mode ' Public Function EnumOpenAccessModeAsString(openAccessMode As EnumOpenFileAccess) As String Select Case openAccessMode Case openForAppend: EnumOpenAccessModeAsString = "Open for Append" Case openForInput: EnumOpenAccessModeAsString = "Open for Input" Case openForOutput: EnumOpenAccessModeAsString = "Open for Output" Case Else: EnumOpenAccessModeAsString = "Unknown Access" End Select End Function ' ' return default extension for selected method ' Public Function DetailFileExtension(method As EnumMethod) As String Select Case method Case PushPull: DetailFileExtension = ".pap" Case Simplex: DetailFileExtension = ".six" Case Else: DetailFileExtension = ".???" End Select End Function ‘ ' return enumerated method representation for string ' Public Function StringAsEnumMethod(method As String) As EnumMethod Select Case method Case EnumMethodAsString(PushPull): StringAsEnumMethod = PushPull Case EnumMethodAsString(Simplex): StringAsEnumMethod = Simplex Case Else: StringAsEnumMethod = UnknownMethod End Select End Function ' ' returning different file name styles

Page 91: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

82

' Public Function ReturnFileAs(fullFileName As String, _ style As EnumReturnFileNameStyle) As String Dim p As Long ReturnFileAs = fullFileName Select Case style Case returnFileName p = InStrRev(fullFileName, "\") If p > 0 Then ReturnFileAs = Mid(fullFileName, p + 1) Case returnFilePath p = InStrRev(fullFileName, "\") If p > 0 Then ReturnFileAs = Left(fullFileName, p) Case returnFileExtension p = InStrRev(fullFileName, ".") If p > 0 Then ReturnFileAs = Mid(fullFileName, p + 1) Case returnNameInFile p = InStrRev(fullFileName, "\") If p > 0 Then ReturnFileAs = Mid(fullFileName, p + 1) p = InStrRev(ReturnFileAs, ".") If p > 0 Then ReturnFileAs = Left(ReturnFileAs, p - 1) End Select End Function ' return string representation for enumerated status ' Public Function EnumStatusAsString(Status As EnumStatus) As String Select Case Status Case EnumStatus.NotCalculated: EnumStatusAsString = "NOT CALCULATED YET" Case EnumStatus.Optimal: EnumStatusAsString = "OPTIMAL" Case EnumStatus.Infeasible: EnumStatusAsString = "INFEASIBLE" Case EnumStatus.Unbounded: EnumStatusAsString = "UNBOUNDED" Case EnumStatus.MaxIterationsExceeded: EnumStatusAsString = "MAX ITERATIONS EXCEEDED" Case EnumStatus.TestFailed: EnumStatusAsString = "TEST FAILED" Case EnumStatus.Trivial: EnumStatusAsString = "TRIVIAL" Case Else: EnumStatusAsString = "UNKNOWN STATUS" End Select End Function ' return enumerated status representation for string ' Public Function StringAsEnumStatus(ByVal Status As String) As EnumStatus Select Case Status Case EnumStatusAsString(NotCalculated): StringAsEnumStatus = NotCalculated Case EnumStatusAsString(Optimal): StringAsEnumStatus = Optimal Case EnumStatusAsString(Infeasible): StringAsEnumStatus = Infeasible Case EnumStatusAsString(Unbounded): StringAsEnumStatus = Unbounded Case EnumStatusAsString(MaxIterationsExceeded): StringAsEnumStatus = MaxIterationsExceeded Case EnumStatusAsString(TestFailed): StringAsEnumStatus = TestFailed Case EnumStatusAsString(Trivial): StringAsEnumStatus = Trivial Case Else: StringAsEnumStatus = UnknownStatus End Select End Function '

Page 92: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

83

' open file for i/o operation, handle errors ' Public Function OpenFile(fullFileName As String, _ openFileAccess As EnumOpenFileAccess) As Long On Error GoTo errorOpenFile ' override file attributes (when copied from CD, files become READ-ONLY!) If Dir(fullFileName) <> "" Then SetAttr fullFileName, vbNormal OpenFile = FreeFile Select Case openFileAccess Case openForInput: Open fullFileName For Input As #OpenFile Case openForOutput: Open fullFileName For Output As #OpenFile Case openForAppend: Open fullFileName For Append As #OpenFile End Select Exit Function errorOpenFile: If OpenFile > 0 Then Close #OpenFile Err.Raise vbObjectError + errorNumberOpenFile, Err.Source, _ "Open file error." & _ NewLine("Access mode: " & EnumOpenAccessModeAsString(openFileAccess)) & _ NewLine("File: " & fullFileName) OpenFile = -1 End Function ' ' handling text format for numbers ' Public Function GiveFormatted(givenValue, _ Optional formatForWriteToFile As Boolean = False) _ As String Dim defaultFormat As String: defaultFormat = " 0.00e+00;-0.00e+00" Dim buffer As String, p As Long If IsNull(givenValue) Then givenValue = "" If IsNumeric(givenValue) Then buffer = Str(givenValue) If formatForWriteToFile Then buffer = Trim(buffer) Else p = InStr(1, buffer, ".") If p > 0 Then buffer = Format(givenValue, "#,##0.####") '& String(Len(defaultFormat), "#")) Else buffer = Format(givenValue, "#,##0") End If buffer = Trim(buffer) If Len(buffer) > (Len(defaultFormat) - 1) / 2 Then buffer = Trim(Format(givenValue, defaultFormat)) End If End If Else buffer = Trim(givenValue) End If

Page 93: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

84

GiveFormatted = buffer End Function ' ' handling text format for numbers ' Public Sub GetFormatted(receivingVariable, _ valueGiven As Variant, _ Optional readFromFileFormat As Boolean = False) Select Case TypeName(receivingVariable) Case "Double", "Single", "Currency" If readFromFileFormat Then receivingVariable = Val(valueGiven) Else receivingVariable = valueGiven End If Case Else receivingVariable = valueGiven End Select End Sub ' ' stuff string with substring ' Public Function Stuff(originalString As String, _ stringToInsert As String) As String Dim i As Long Stuff = "" For i = 1 To Len(originalString) Stuff = Stuff & Mid(originalString, i, 1) & stringToInsert Next i End Function ' ' determine, 0, 1 or 2, don't want to handle more than that for now ' Public Function MatrixDimension(matrix) As Long On Error GoTo errorMatrixDimension Dim tempDimension As Long, tmp As Long For tempDimension = 1 To 3 tmp = UBound(matrix, tempDimension) Next errorMatrixDimension: MatrixDimension = tempDimension - 1 End Function ' block write combination of scalars, vectors and matrixes to a file ' Public Sub MatrixBlockWrite(fileID As Long, _ delimiter As String, _ ParamArray matrixes()) On Error GoTo errorMatrixBlockWrite

Page 94: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

85

Dim matrixCount As Long Dim matrixDim() As Long ReDim matrixDim(LBound(matrixes) To UBound(matrixes)) Dim firstRow As Long, lastRow As Long ' determine matrix dimensions For matrixCount = LBound(matrixes) To UBound(matrixes) matrixDim(matrixCount) = MatrixDimension(matrixes(matrixCount)) If matrixDim(matrixCount) > 0 Then firstRow = LBound(matrixes(matrixCount), 1) lastRow = UBound(matrixes(matrixCount), 1) End If Next matrixCount ' create string and write to a file Dim buffer As String Dim i As Long, j As Long For i = firstRow To lastRow buffer = "" For matrixCount = LBound(matrixes) To UBound(matrixes) Select Case matrixDim(matrixCount) Case 0: buffer = buffer & NumToStr(matrixes(matrixCount)) & delimiter Case 1: buffer = buffer & NumToStr(matrixes(matrixCount)(i)) & delimiter Case 2 For j = LBound(matrixes(matrixCount), 2) To UBound(matrixes(matrixCount), 2) buffer = buffer & NumToStr(matrixes(matrixCount)(i, j)) & delimiter Next j End Select Next matrixCount ' execute printing buffer = Left(buffer, Len(buffer) - Len(delimiter)) Print #fileID, buffer Next i Exit Sub errorMatrixBlockWrite: Err.Raise Err.Number, , "Trying to write several matrixes to a file." & _ NewLine(Err.Description) End Sub ' convert parameter to string, if numeric with Str() ' Public Function NumToStr(parameter) As String If IsNumeric(parameter) Then NumToStr = "0" & Trim(Str(Abs(parameter))) If parameter < 0 Then NumToStr = "-" & NumToStr Else NumToStr = Trim(parameter) End If End Function ' convert parameter to string, if numeric with Str() ' Public Function NumFromStr(parameter As String) If IsNumeric(parameter) Then

Page 95: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

86

NumFromStr = Val(parameter) Else NumFromStr = Trim(parameter) End If End Function ' MDI CHILD FORM: HANDLING A SINGLE LINEAR PROGRAMMING PROBLEM Public WithEvents CurrentProblem As ClassProblem Private controlCollection As New Collection Private dataFieldEdited As String Private IsNewProblem As Boolean Private fieldFormIsEmpty As Boolean ' ' printing single problem ' Public Sub DoPrint() If Me.TestCurrentForSave = False Then Exit Sub FormPrint.Show 1 End Sub ' ' clear form and lock saving ' Public Sub EmptyForm() CurrentProblem.CreateNew "TempProblem" CurrentProblem.ProblemSaved = True FormIsEmpty = True End Sub ' ' execute selected methods ' Public Sub ExecuteMethods() On Error GoTo errorExecuteMethods If TestCurrentForSave = False Then Exit Sub Dim tempMethod As EnumMethod For tempMethod = PushPull To Simplex If mclMethods.CheckLabel(EnumMethodAsString(tempMethod)) Then CurrentProblem.Result(tempMethod).ResetToDefault If tempMethod = PushPull Then ModulePushPull.ExecutePushPull CurrentProblem If tempMethod = Simplex Then ModuleSimplex.ExecuteSimplex CurrentProblem CurrentProblem.Result(tempMethod).ShowResult End If Next tempMethod CurrentProblem.CalcDifference CurrentProblem.SaveProblem SelectTab "SUMMARY" FormAnalysis.ChangeProblemData CurrentProblem.ProblemName Exit Sub errorExecuteMethods: MsgBox Err.Description, , "EXECUTE METHODS ERROR!" End Sub

Page 96: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

87

' resets results for selected methods ' Public Sub DoReset() On Error GoTo errorDoReset If TestCurrentForSave = False Then Exit Sub Dim tempMethod As EnumMethod For tempMethod = PushPull To Simplex If mclMethods.CheckLabel(EnumMethodAsString(tempMethod)) Then CurrentProblem.Result(tempMethod).ResetToDefault If Dir(CurrentProblem.Result(tempMethod).DetailFile) <> "" Then _ Kill CurrentProblem.Result(tempMethod).DetailFile End If Next tempMethod CurrentProblem.SaveProblem SelectTab "SUMMARY" FormAnalysis.ChangeProblemData CurrentProblem.ProblemName Exit Sub errorDoReset: MsgBox Err.Description, , "RESET RESULTS METHODS ERROR!" End Sub ' ' property get form is empty ' Public Property Get FormIsEmpty() As Boolean FormIsEmpty = fieldFormIsEmpty End Property ' ' declare empty form ' Public Property Let FormIsEmpty(newValue As Boolean) If (fieldFormIsEmpty = False) And (newValue = False) Then Exit Property fieldFormIsEmpty = newValue If fieldFormIsEmpty Then Dim tmpLabel As Label For Each tmpLabel In controlCollection tmpLabel.Caption = "" Next tmpLabel tbsContainer.Enabled = False tbsFrames(0).Visible = False tbsFrames(1).Visible = False tbsFrames(2).Visible = False Me.Caption = "Single Problem: No problem selected" malAction.EnableAll False mclMethods.EnableAll False Else tbsContainer.Enabled = True controlCollection("S").Caption = CurrentProblem.Definition.S controlCollection("M").Caption = CurrentProblem.Definition.M malAction.EnableAll True mclMethods.EnableAll True ' malAction.LabelEnabled("SAVE") = Not CurrentProblem.ProblemSaved SelectTab "DEFINITION" End If

Page 97: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

88

End Property ' ' create a new problem ' Public Function NewProblem(NewProblemName As String) As Boolean NewProblem = False If TestCurrentForSave = False Then Exit Function CurrentProblem.CreateNew NewProblemName CurrentProblem.SaveProblem Me.Caption = "Single Problem: " & CurrentProblem.ProblemName FormIsEmpty = False SelectTab "DEFINITION" NewProblem = True ' IsNewProblem = True End Function ' ' print definition and summary ' Public Function PrintDefinition() As Boolean rtbPrintDefinition.LoadFile CurrentProblem.Definition.DefinitionFile End Function ' ' save current problem ' Public Sub SaveProblem() On Error GoTo errorSaveProblem If CurrentProblem.ProblemSaved Then Exit Sub Screen.MousePointer = 11 With CurrentProblem .Result(PushPull).ResetToDefault .Result(Simplex).ResetToDefault .SaveProblem FormAnalysis.ChangeProblemData .ProblemName End With Screen.MousePointer = 0 IsNewProblem = False Exit Sub errorSaveProblem: MsgBox Err.Description, , "SAVE PROBLEM ERROR!" Screen.MousePointer = 0 Exit Sub End Sub ' ' open problem definition and results if they exist ' Public Sub OpenProblem(ProblemName As String) If Not TestCurrentForSave Then Exit Sub On Error GoTo errorOpenProblem Screen.MousePointer = 11

Page 98: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

89

CurrentProblem.OpenProblem RepositoryFolder & "\" & ProblemName & ".txt" Screen.MousePointer = 0 Me.Caption = "Single Problem: " & CurrentProblem.ProblemName FormIsEmpty = False Exit Sub errorOpenProblem: MsgBox Err.Description, , "OPEN PROBLEM ERROR!" Screen.MousePointer = 0 End Sub ' ' selecting proper tab strip ' Private Sub SelectTab(tabName As String) Set tbsContainer.SelectedItem = tbsContainer.Tabs(tabName) End Sub ' ' test and handle if problem is not saved ' Public Function TestCurrentForSave() As Boolean TestCurrentForSave = True If Not CurrentProblem.ProblemSaved Then Select Case MsgBox("Current problem hasn't been saved yet. Save now?", _ vbExclamation + vbYesNoCancel, Me.Caption) Case vbCancel FormRepository.mflvRepository.Locate CurrentProblem.ProblemName TestCurrentForSave = False Exit Function Case vbYes SaveProblem Exit Function Case vbNo ' If Not IsNewProblem Then CurrentProblem.OpenProblem CurrentProblem.Definition.DefinitionFile ' End If End Select End If ' If IsNewProblem Then ' ' If Dir(CurrentProblem.Definition.DefinitionFile) = "" Then ' ' definition file doesn't exist, destroy item in repository ' With FormRepository.mflvRepository ' Dim tempItem As ListItem ' Set tempItem = .ItemByName(CurrentProblem.ProblemName) ' If Not tempItem Is Nothing Then .RemoveItem tempItem ' End With ' End If ' IsNewProblem = False ' End If End Function

Page 99: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

90

' ' saved changed ' Private Sub CurrentProblem_SaveStateChanged(Saved As Boolean) ' malAction.LabelEnabled("SAVE") = Not Saved End Sub ' ' click on the form ' Private Sub Form_Click() If Not EditGlobalDataProcess Then Exit Sub TextData.Visible = False End Sub ' loading form into memory ' Private Sub Form_Load() ' create problem's global variables collection Dim tempLabel As Label For Each tempLabel In LabelData controlCollection.Add tempLabel, tempLabel.Tag Next tempLabel ' create and initiate the Current Problem object Set CurrentProblem = New ClassProblem CurrentProblem.InitialDeclarations controlCollection, mgDefinition, mgResultSummary, mrtbResultDetails CurrentProblem.ProblemSaved = True ' initiate action labels (menu) Set malAction.HostForm1 = FormAnalysis Set malAction.HostForm2 = FormRepository Set malAction.HostForm3 = FormSingleProblem malAction.Direction = alHorizontal malAction.AddNew "SAVE", "Save", "Save current problem definition." malAction.AddNew "PRINT", "Print", "Print problem definition and result files." malAction.AddNew "RESET", "Reset Results", "Resets the results for ticked methods." malAction.AddNew "EXECUTE", "Execute Algorithm:", "Execute ticked algorithms on current problem." ' check boxes Set mclMethods.HostForm1 = FormAnalysis Set mclMethods.HostForm2 = FormRepository Set mclMethods.HostForm3 = FormSingleProblem mclMethods.Move malAction.Left + malAction.Width, 0 '_ '(malAction.Top + malAction.Height - mclMethods.Height) / 2 mclMethods.AddNew EnumMethodAsString(PushPull), PascalType(EnumMethodAsString(PushPull)), _ "Select method to be executed.", , True mclMethods.AddNew EnumMethodAsString(Simplex), PascalType(EnumMethodAsString(Simplex)), _

Page 100: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

91

"Select method to be executed.", , True End Sub ' ' on form unload event ' Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Cancel = 1 Me.WindowState = 1 End Sub ' ' resizing form ' Private Sub Form_Resize() If (Me.WindowState <> 1) And (FormMain.WindowState <> 1) Then ' reposition tab-strip tbsContainer.Left = 100 If (Me.ScaleWidth - tbsContainer.Left - 100) > 0 Then _ tbsContainer.Width = Me.ScaleWidth - tbsContainer.Left - 100 If (Me.ScaleHeight - tbsContainer.Top - 100) > 0 Then _ tbsContainer.Height = Me.ScaleHeight - tbsContainer.Top - 100 ' repostioin frames Dim tempFrame As Frame For Each tempFrame In tbsFrames tempFrame.Visible = False tempFrame.Caption = "" tempFrame.BorderStyle = 0 tempFrame.Move tbsContainer.ClientLeft, _ tbsContainer.ClientTop, _ tbsContainer.ClientWidth, _ tbsContainer.ClientHeight Next tempFrame ' position show definition grid With mgDefinition If (.Container.Width > 500) And (.Container.Height > 500) Then _ .Move 250, 250, .Container.Width - 500, .Container.Height - 500 End With ' position show result summary grid With mgResultSummary If (.Container.Width > 500) And (.Container.Height > 500) Then _ .Move 250, 250, .Container.Width - 500, .Container.Height - 500 End With ' position show result detail components With mrtbResultDetails If (.Container.Width > 500) And (.Container.Height > 500) Then _ .Move 250, 250, .Container.Width - 500, .Container.Height - 500 End With ' show proper frame tbsFrames(tbsContainer.SelectedItem.Index - 1).Visible = True End If End Sub

Page 101: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

92

' clicking on non active labels ' Private Sub Label1_Click(Index As Integer) If Not EditGlobalDataProcess Then Exit Sub TextData.Visible = False End Sub ' ' execute action ' Private Sub malAction_Action(ActionName As String) Select Case ActionName Case "SAVE": SaveProblem Case "PRINT": DoPrint Case "RESET": DoReset Case "EXECUTE": ExecuteMethods Case Else: MsgBox (ActionName) End Select End Sub ' ' clicking on frames ' Private Sub tbsFrames_Click(Index As Integer) tbsContainer.SetFocus End Sub ' ' clicking on tab-strips ' Private Sub tbsContainer_Click() Dim i As Integer If Not tbsFrames(tbsContainer.SelectedItem.Index - 1).Visible Then For i = 0 To tbsFrames.Count - 1 tbsFrames(i).Visible = False Next i tbsFrames(tbsContainer.SelectedItem.Index - 1).Visible = True End If End Sub ' ' editing data ' Private Sub LabelData_Click(Index As Integer)

Page 102: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

93

If Not EditGlobalDataProcess Then Exit Sub Select Case LabelData(Index).Tag Case "Name" TextData.Visible = False MsgBox "Name is associated with problem definition file and " & _ NewLine("can only be changed in Repository window."), , _ "Changing problem name." Case "Objective" TextData.Visible = False CurrentProblem.Definition.Objective = IIf(LabelData(Index) = "MIN", "MAX", "MIN") CurrentProblem.ProblemSaved = False Case Else EditGlobalDataStart LabelData(Index).Tag End Select End Sub ' ' start editing problem's global variables ' Public Sub EditGlobalDataStart(fieldName As String) If FormIsEmpty Then Exit Sub With controlCollection(fieldName) dataFieldEdited = fieldName TextData.Move .Left, .Top, .Width, .Height TextData.FontName = .FontName TextData.FontSize = .FontSize TextData.FontBold = .FontBold TextData.FontItalic = .FontItalic TextData.Alignment = .Alignment TextData.Text = .Caption TextData.SelStart = 0 TextData.SelLength = Len(.Caption) TextData.Visible = True TextData.SetFocus End With

Page 103: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

94

End Sub ' ' process problem's global variables editing ' Private Function EditGlobalDataProcess() As Boolean On Error GoTo errorEditGlobalDataProcess EditGlobalDataProcess = True Select Case dataFieldEdited Case "S" If CurrentProblem.Definition.S <> CLng(TextData.Text) Then CurrentProblem.Definition.S = CLng(TextData.Text) CurrentProblem.ProblemSaved = False End If Case "M" If CurrentProblem.Definition.M <> CLng(TextData.Text) Then CurrentProblem.Definition.M = CLng(TextData.Text) CurrentProblem.ProblemSaved = False End If Case "Source" If CurrentProblem.Definition.Source <> Trim(TextData.Text) Then CurrentProblem.Definition.Source = Trim(TextData.Text) CurrentProblem.ProblemSaved = False End If Case "Comment" If CurrentProblem.Definition.Comment <> Trim(TextData.Text) Then CurrentProblem.Definition.Comment = Trim(TextData.Text)

Page 104: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

95

CurrentProblem.ProblemSaved = False End If Case Else: Exit Function End Select dataFieldEdited = "" Exit Function errorEditGlobalDataProcess: EditGlobalDataProcess = False MsgBox "Error editing data for " & dataFieldEdited & ": " & TextData.Text & _ NewLine(Err.Description), , "ERROR EDITING DATA." EditGlobalDataStart dataFieldEdited End Function ' ' key pressed on edit textbox ' Private Sub TextData_KeyPress(KeyAscii As Integer) ' ESC If KeyAscii = 27 Then TextData.Visible = False dataFieldEdited = "" KeyAscii = 0 End If ' ENTER If KeyAscii = 13 Then Dim oldDataFieldEdited As String: oldDataFieldEdited = dataFieldEdited If Not EditGlobalDataProcess Then EditGlobalDataStart dataFieldEdited Else Select Case oldDataFieldEdited Case "": EditGlobalDataStart "S" Case "S": EditGlobalDataStart "M" Case "M": EditGlobalDataStart "Source" Case "Source": EditGlobalDataStart "Comment" Case "Comment": SelectTab "DEFINITION" mgDefinition.StartEditing 1, 1 End Select

Page 105: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

96

End If KeyAscii = 0 End If End Sub ' ' edit textbox lost focus ' Private Sub TextData_LostFocus() EditGlobalDataProcess TextData.Visible = False End Sub ' MODULE PUSHPULL: PUSH AND PULL METHOD IMPLEMENTATION Private Problem As ClassProblem ' object holding problem Private Result As ClassProblemResult ' object holding results for Simplex Private Inc As ClassCounters ' object holding counters Private Definition As ClassProblemDefinition ' object holding problem definition Private noteDetail As ClassOutputDetailFile ' object handling output Private tableau() As Double ' tableau to work on '''Private iterationCount As Long ' iteration counter Private BVS() As Long ' basic variable set Private D As Long ' number of slack/surplus variables Private U As Long ' number of artificial variables Private M As Long ' number of constraints Private S As Long ' number of original variables Private minMax As Integer ' objective indicator: MIN= -1 , MAX= 1 Private k As Long Private r As Long Private stepName As String Private sortedCj As New ClassList Private degeneracyOccured As Boolean ' ' Push and Pull module entry point ' Public Sub ExecutePushPull(onProblem As ClassProblem) On Error GoTo errorExecutePushPull Set Problem = onProblem Set Result = onProblem.Result(PushPull) Set Inc = Result.Counters Set sortedCj.Inc = Inc Set Definition = onProblem.Definition

Page 106: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

97

Result.StartedWhen = Now Set noteDetail = Result.OutputDetailFile noteDetail.OpenOutputFile ' (A) Set dimensions and default values for matrix A, BVS, counters, ... InitiatePushPull ' (B) Convert problem into required form DoPreliminaries ' (1) Convert inequalities into equalities DoStep1 ' (2) Construct initial tableau containing all slack variables in BVS DoStep2 noteDetail.ResultDetailHeader noteDetail.SingleLine "Initial tableau", "=", 1, , "=" noteDetail.PrintTableau tableau, S, D, U, M, BVS noteDetail.SingleLine "BVS is " & IIf(CompleteBVS, "", "NOT ") & "complete." '---STEP 3: Generate a complete BVS Do While Not CompleteBVS ' rebuild sorted list based on last tableau row (zero values are excluded!) sortedCj.RebuildWith tableau ' look for new r and k within empty BVS-s DoStep3 ' something odd happened: notify and exit method Inc.Decis If Result.Status <> NotCalculated Then GoTo exitDueToStatusChange Inc.Decis If sortedCj.IsEmpty Then ' k and r were not found, all possibilities were exhausted: notify and exit loop noteDetail.SingleLine "All possible incoming Xj have been used." Exit Do End If noteDetail.SingleLine "Iteration No.: " & Inc.Counter(cntIterations), "=", 1, , "=" noteDetail.SingleLine "Step 3: completing BVS (k= " & k & ", r= " & r & ")" noteDetail.PrintTableau tableau, S, D, U, M, BVS Inc.Decis If degeneracyOccured Then noteDetail.SingleLine "DEGENERACY OCCURED." Result.Degeneracy = "YES" End If noteDetail.SingleLine "BVS is " & IIf(CompleteBVS, "", "NOT ") & "complete." Loop '---END STEP 3

Page 107: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

98

' loop to optimal solution noteDetail.SingleLine "Continue with Step 4." stepName = "4-PUSH" Do While True Inc.Loops Inc.Decis Select Case stepName Case "4-PUSH" '-----------STEP 4: Push to optimal solution ' use sorted list, based on last row of tableau, to determine the largest element sortedCj.RebuildWith tableau ' do while positive element exists Do While sortedCj.Positive Inc.Loops ' calculate next solution DoStep4 ' something odd happened: notify and exit method Inc.Decis If Result.Status <> NotCalculated Then GoTo exitDueToStatusChange noteDetail.SingleLine "Iteration No.: " & Inc.Counter(cntIterations), "=", 1, , "=" noteDetail.SingleLine "Step 4: Push to optimal solution (k= " & k & ", r= " & r & ")" noteDetail.PrintTableau tableau, S, D, U, M, BVS Inc.Decis If degeneracyOccured Then noteDetail.SingleLine "DEGENERACY OCCURED." Result.Degeneracy = "YES" End If ' rebuild list and test for positive element sortedCj.RebuildWith tableau noteDetail.SingleLine "Zj positive does " & _ IIf(sortedCj.Positive, "", "NOT ") & "exist." Loop ' continue with Step 5 noteDetail.SingleLine "Continue with Step 5." stepName = "5-TEST" '-----------END STEP 4 Case "5-TEST" '-----------STEP 5: Test the iteration results noteDetail.SingleLine "Step 5: Test the iteration results:", "=", 1 noteDetail.SingleLine DoStep5(), , , 1

Page 108: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

99

'-----------END STEP 5 Case "6-PULL" '-----------STEP 6: DoStep6 ' something odd happened: notify and exit method Inc.Decis If Result.Status <> NotCalculated Then GoTo exitDueToStatusChange noteDetail.SingleLine "Iteration No.: " & Inc.Counter(cntIterations), "=", 1, , "=" noteDetail.SingleLine "Step 6: Pull to feasible solution (k= " & k & ", r= " & r & ")" noteDetail.PrintTableau tableau, S, D, U, M, BVS Inc.Decis If degeneracyOccured Then noteDetail.SingleLine "DEGENERACY OCCURED." Result.Degeneracy = "YES" End If noteDetail.SingleLine "Continue with Step 5." stepName = "5-TEST" '-----------END STEP 6 Case "OPTIMAL" Result.Status = Optimal Exit Do End Select Loop '---evaluate results ModuleGauss.CalculateOptimalSolution Result, Definition, tableau, BVS noteDetail.PrintTestResult noteDetail.PrintSummary noteDetail.CloseOutputFile Exit Sub exitDueToStatusChange: ' something odd happened: notify and exit execution ''' Result.TotalIterations = iterationCount ''' noteDetail.SingleLine "Status has changed: " & Result.StatusName noteDetail.SingleLine "Execution stopped.", , 1, 1, "=" noteDetail.CloseOutputFile

Page 109: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

100

Exit Sub errorExecutePushPull: ' error occured during method execution noteDetail.CloseOutputFile Err.Raise Err.Number, , "Execute Push and Pull method error." & _ NewLine(Err.Description) Exit Sub End Sub ' ' (A) Initiate Push And Pull: Set dimensions and default values ' Private Sub InitiatePushPull() Dim i As Long, j As Long ' (a) initiate global method values stopExecuting = False ''' iterationCount = 0 Inc.Reset Result.Degeneracy = "NO" ' (b) read Objective, s and m Inc.Decis minMax = IIf(Definition.Objective = "MAX", -1, 1) M = Definition.M S = Definition.S ' (c) calculate D, U D = 0 U = 0 Inc.Loops M Inc.Decis M For i = 1 To M D = IIf(Definition.ConstraintType(i) <> "=", D + 1, D) Next i ' (d) dimension tableau, set initial values to Definition.A ReDim tableau(1 To M + 1, 1 To S + D + 1) Inc.Loops M * S For i = 1 To M For j = 1 To S tableau(i, j) = Definition.A(i, j) Next j

Page 110: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

101

Next i '(e) dimension BVS, set initial values to zero ReDim BVS(1 To M) End Sub ' ' (B) Preliminaries: Convert problem into required form ' Private Sub DoPreliminaries() Dim i As Long, j As Long ' (a) The problem must be a maximization problem; set A(m+1) row Inc.Loops S Inc.MulDiv 2 * S For j = 1 To S tableau(M + 1, j) = -1 * minMax * Definition.Cj(j) Next j ' (b) RHS must be non-negative; set A(s+D+1) column ' ??? "to avoid the occurence of a possible degeneracy, convert all inequality constr. ??? ' ??? with RHS=0 into 0 by multiplying each one of them by -1." (last article, page 5) ??? For i = 1 To M Inc.Loops tableau(i, S + D + 1) = Abs(Definition.RHS(i)) Inc.Decis If Definition.RHS(i) < 0 Then For j = 1 To S Inc.Loops tableau(i, j) = -1 * tableau(i, j) Inc.MulDiv Next j End If Next i ' (c) "All variables must be non-negative." (last article, page 5) CONSTRUCT IT LATER !!! ' ??? What does this mean? ??? ' ??? How do I implement it? ??? End Sub ' ' (1) Step 1: Convert inequalities into equalities ' Private Sub DoStep1() Dim i As Long, j As Long

Page 111: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

102

' (a) Set tableau(i,j) value 1 or -1, regarding the relation type of the constraint j = S Inc.Loops M For i = 1 To M Inc.Decis If Definition.ConstraintType(i) <> "=" Then ' is slack or surplus j = j + 1 Inc.AddSub ' slack or surplus, set tableau(i,j) Inc.Decis tableau(i, j) = IIf(Definition.ConstraintType(i) = "<", 1, -1) ' if RHS negative, multiply with -1 Inc.Decis If (Definition.RHS(i) < 0) Then tableau(i, j) = -1 * tableau(i, j): Inc.MulDiv End If Next i ' ??? "The coefficient matrix must have a full row rank, since otherwise either no ??? ' ??? solution exists or there are redundand equations." (last article, page 7) ??? End Sub ' ' (2) Step 2: Construct initial tableau containing all slack variables in BVS ' Private Sub DoStep2() Dim i As Long, j As Long ' (a) Set tableau(i,j) value 1 or -1, regarding the relation type of the constraint j = S Inc.Loops M For i = 1 To M Inc.Decis If Definition.ConstraintType(i) <> "=" Then ' is slack or surplus j = j + 1: Inc.AddSub Inc.Decis If (Definition.ConstraintType(i) = "<") And _ (Definition.RHS(i) >= 0) Then ' is slack and RHS was non-negative

Page 112: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

103

BVS(i) = j End If End If Next i ' ??? "The coefficient matrix must have a full row rank, since otherwise either no ??? ' ??? solution exists or there are redundand equations." (last article, page 7) ??? ' !!! If so, notify and STOP !!! ' execution has just begun => status should be NotCalculated Result.Status = NotCalculated End Sub ' ' (3) Step 3: Generate a complete BVS ' Private Sub DoStep3() Dim modTableau() Dim i As Long, j As Long ' loop while k and r are found or sorted list is empty Do While Not sortedCj.IsEmpty Inc.Loops ' (1) Incoming variable is the one with the largest Cj k = sortedCj.Largest.j ' (2) Choose the smallest !!positive!! C/R if possible ' ??? "If there are alternatives, break the ties arbitrarily." (last article, pg. 7) ??? ' ??? What does that mean? How do I implement it? => checking for degeneracy. ??? ' create modified tableau (clear rows with occupied bvs) modTableau = ModuleUtilities.CloneMatrix(tableau) For i = 1 To M If BVS(i) <> 0 Then For j = 1 To S modTableau(i, j) = 0 Next j End If Next i r = ModuleGauss.ColumnRatioTest(Inc, modTableau, k, degeneracyOccured, True) Inc.Decis If r = 0 Then ' column ratio test didn't give any results, try with next biggest element in sorted list sortedCj.RemoveLargest

Page 113: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

104

Else ' (3a) Calculated r-row in BVS is empty, let's pivot Inc.Decis If BVS(r) = 0 Then ' increase iteration count and check for boundaries (to prevent infinite loop) Inc.Decis If ModuleGauss.IterationCountExceedsMaxAllowed(Inc) Then ' too many iterations: change status and leave this loop (to prevent infinite loop) Result.Status = MaxIterationsExceeded Exit Sub End If ' success: k and r are found, execute tableau pivoting and leave this loop ModuleGauss.GaussPivot Inc, tableau, k, r, BVS Exit Do Else ' (3b) BVS(r) is already occupied, repeat (1) with next largest Cj sortedCj.RemoveLargest End If End If Loop End Sub ' ' (4) Step 4: Push to optimal solution ' Private Sub DoStep4() ' (1) Incoming variable is the one with the largest Cj k = sortedCj.Largest.j ' (2) Choose the smallest !!positive!! C/R if possible r = ModuleGauss.ColumnRatioTest(Inc, tableau, k, degeneracyOccured) Inc.Decis If r = 0 Then ' column ratio test didn't give any result => is it infesible or unbounded? Result.Status = Unbounded Exit Sub End If Inc.Decis

Page 114: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

105

If ModuleGauss.IterationCountExceedsMaxAllowed(Inc) Then ' too many iterations: change status and leave this loop (to prevent infinite loop) Result.Status = MaxIterationsExceeded Exit Sub End If ' success: calculate new tableau ModuleGauss.GaussPivot Inc, tableau, k, r, BVS End Sub ' ' (5) Step 5: Testing ' Private Function DoStep5() As String Dim decision As String ' use sorted list to determine existance of positive Cj sortedCj.RebuildWith tableau ' decide which step goes next decision = "" decision = decision & IIf(negativeRHS, "F", "T"): Inc.Decis decision = decision & IIf(sortedCj.Positive, "F", "T"): Inc.Decis Inc.Decis Select Case decision Case "TT" ' All RHS >= 0 and all Cj <= 0 : solution is optimal stepName = "OPTIMAL" DoStep5 = "All RHS >= 0 and all Zj <= 0 : solution is optimal" Case "TF", "FF" ' Not all Cj <= 0: continue with PUSH (Step 4) stepName = "4-PUSH" DoStep5 = "Not all Zj <= 0: continue with PUSH (Step 4)" Case "FT" ' Not all RHS >= 0: continue with PULL (Step 6) stepName = "6-PULL" DoStep5 = "Not all RHS >= 0: continue with PULL (Step 6)" End Select

Page 115: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

106

End Function ' ' (6) Step 6: Pull to feasible solution ' Private Sub DoStep6() ' (a) Use the dual simplex pivoting rules to determine k and r (R/R test) ModuleGauss.RowRatioTest Inc, tableau, k, r Inc.Decis If r = 0 Then ' row ratio test didn't give any result => is it infesible or unbounded? Result.Status = Infeasible Exit Sub End If Inc.Decis If ModuleGauss.IterationCountExceedsMaxAllowed(Inc) Then ' too many iterations: change status and leave this loop (to prevent infinite loop) Result.Status = MaxIterationsExceeded Exit Sub End If ' (b) generate the next tableau ModuleGauss.GaussPivot Inc, tableau, k, r, BVS End Sub ' check if BVS is complete ' Private Function CompleteBVS() As Boolean Dim i As Long CompleteBVS = True For i = 1 To M Inc.Loops Inc.Decis If BVS(i) = 0 Then CompleteBVS = False Exit Function End If

Page 116: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

107

Next i End Function ' ' check if RHS negative exists (pull phase) ' Private Function negativeRHS() As Boolean Dim i As Long negativeRHS = False For i = 1 To M Inc.Loops Inc.Decis If tableau(i, S + D + 1) < 0 Then negativeRHS = True Exit Function End If Next i End Function ' MODULE SIMPLEX: STD. SIMPLEX METHOD IMPLEMENTATION Option Explicit Private Problem As ClassProblem ' object holding problem Private Result As ClassProblemResult ' object holding results for Simplex Private Inc As ClassCounters ' object holding counters Private Definition As ClassProblemDefinition ' object holding problem definition Private noteDetail As ClassOutputDetailFile ' object handling output Private tableau() As Double ' tableau to work on '''Private iterationCount As Long ' iteration counter Private BVS() As Long ' basic variable set Private D As Long ' number of slack/surplus variables Private U As Long ' number of artificial variables Private M As Long ' number of constraints Private S As Long ' number of original variables Private minMax As Integer ' objective indicator: MIN= -1 , MAX= 1 Private bigM As Double ' the big M value Private k As Long Private r As Long Private stopExecuting As Boolean ' execution flag Private simplexCj() As Double ' last row in tableau - why do I need that ?? Private existsZjPositive As Boolean ' positive Zj - Cj existance flag Private biggestZjColumnIndex As Long ' biggest Zj - Cj column index (next possible k) Private degeneracyOccured As Boolean ' ' entry point for standardSimplex method execution ' Public Sub ExecuteSimplex(onProblem As ClassProblem) On Error GoTo errorExecuteSimplex Set Problem = onProblem

Page 117: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

108

Set Result = onProblem.Result(Simplex) Set Inc = Result.Counters Set Definition = onProblem.Definition Result.StartedWhen = Now Set noteDetail = Result.OutputDetailFile noteDetail.OpenOutputFile ' (A) set dimensions and default values for matrix A, BVS, counters, ... InitiateSimplex ' (B) construct initial tableau ConstructInitialTableau noteDetail.ResultDetailHeader noteDetail.SingleLine "Initial tableau", "=", 1, , "=" noteDetail.PrintTableau tableau, S, D, U, M, BVS noteDetail.SingleLine "Zj positive does " & IIf(existsZjPositive, "", "NOT ") & "exist." ' loop to optimal solution Do While stopExecuting = False Inc.Loops ' (1) Calculate new tableau CalculateNewTableau noteDetail.SingleLine "Iteration No.: " & Inc.Counter(cntIterations), "=", 1, , "=" noteDetail.SingleLine "k= " & k & ", r= " & r noteDetail.PrintTableau tableau, S, D, U, M, BVS Inc.Decis If degeneracyOccured Then noteDetail.SingleLine "DEGENERACY OCCURED." Result.Degeneracy = "YES" End If noteDetail.SingleLine "Zj positive does " & IIf(existsZjPositive, "", "NOT ") & "exist." Loop '---evaluate result: Select Case Result.Status Case EnumStatus.Optimal ModuleGauss.CalculateOptimalSolution Result, Definition, tableau, BVS noteDetail.PrintTestResult noteDetail.PrintSummary Case Else noteDetail.SingleLine "Status has changed: " & Result.StatusName noteDetail.SingleLine "Execution stopped.", , 1, 1, "=" End Select noteDetail.CloseOutputFile Exit Sub errorExecuteSimplex: noteDetail.CloseOutputFile Err.Raise Err.Number, , "Execute Std. Simplex method error." & _

Page 118: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

109

NewLine(Err.Description) End Sub ' ' (A) set dimensions and default values ' Private Sub InitiateSimplex() Dim i As Long, j As Long ' (a) initiate global method values stopExecuting = False ''' iterationCount = 0 Inc.Reset existsZjPositive = False biggestZjColumnIndex = 0 ' (b) read Objective, s and m minMax = IIf(Definition.Objective = "MAX", -1, 1): Inc.Decis M = Definition.M S = Definition.S ' (c) calculate D and U D = 0 U = 0 Inc.Loops M For i = 1 To M D = IIf(Definition.ConstraintType(i) <> "=", D + 1, D): Inc.Decis U = IIf(Definition.ConstraintType(i) <> "<", U + 1, U): Inc.Decis Next i ' (d) dimension tableau, set initial values to A or zero ReDim tableau(1 To M + 1, 1 To S + D + U + 1) Inc.Loops M * S For i = 1 To M For j = 1 To S tableau(i, j) = Definition.A(i, j) Next j Next i ' (e) dimension BVS, set initial values to zero ReDim BVS(1 To M) ' (f) calculate BIG M bigM = 0 Inc.Loops S Inc.Decis S For i = 1 To S bigM = IIf(Definition.Cj(i) > bigM, Definition.Cj(i), bigM) Next i bigM = 10 * bigM: Inc.MulDiv

Page 119: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

110

' (g) dimension simplexCj (expand original Cj with surplus/slack and artificial variables) ReDim simplexCj(S + D + U + 1) Inc.Loops S For j = 1 To S simplexCj(j) = Definition.Cj(j): Next j End Sub ' ' (B) Construct initial tableau for Simplex ' Private Sub ConstructInitialTableau() Dim i As Long Dim Dj As Long: Dj = 0 Dim Uj As Long: Uj = 0 ' (a) create slack, surplus and artificial Inc.Loops M Inc.Decis M For i = 1 To M Select Case Definition.ConstraintType(i) Case "=" Uj = Uj + 1 tableau(i, S + D + Uj) = 1 simplexCj(S + D + Uj) = minMax * bigM BVS(i) = S + D + Uj Inc.MulDiv Inc.AddSub 3 Case "<" Dj = Dj + 1 tableau(i, S + Dj) = 1 BVS(i) = S + Dj Inc.AddSub 2 Case ">" Uj = Uj + 1 Dj = Dj + 1 tableau(i, S + Dj) = -1 simplexCj(S + D + Uj) = minMax * bigM tableau(i, S + D + Uj) = 1 BVS(i) = S + D + Uj Inc.AddSub 4 Inc.MulDiv End Select Next i ' (b) read RHS

Page 120: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

111

Inc.Loops M For i = 1 To M tableau(i, S + D + U + 1) = Definition.RHS(i) Next i ' (c) calculate z(j)-c(j) CalculateZ ' if Zj positive doesn't exist stop executing stopExecuting = Not existsZjPositive End Sub ' calculate new incoming and outgoing vector, pivot tableau ' Private Sub CalculateNewTableau() ' find best k k = biggestZjColumnIndex Result.Status = NotCalculated stopExecuting = True ' calculate r with C/R test r = ModuleGauss.ColumnRatioTest(Inc, tableau, k, degeneracyOccured) ' what if column ratio test doesn't give a result Inc.Decis If r = 0 Then Result.Status = EnumStatus.Unbounded End If ' increase iteration count and check for boundaries Inc.Decis If ModuleGauss.IterationCountExceedsMaxAllowed(Inc) Then Result.Status = MaxIterationsExceeded End If ' something went wrong Inc.Decis If Result.Status <> NotCalculated Then Exit Sub ModuleGauss.GaussPivot Inc, tableau, k, r, BVS CalculateZ ' check for positive Zj stopExecuting = Not existsZjPositive End Sub ' calculating last row; alter for maximum ' Private Function CalculateZ() Dim i As Long Dim j As Long Dim tempZ As Double Dim tempBiggestZj As Double: tempBiggestZj = 0 existsZjPositive = False biggestZjColumnIndex = 0

Page 121: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

112

' (a) calculate last row For j = 1 To S + D + U + 1 tempZ = 0 Inc.Loops M For i = 1 To M ' calculate cumulative value tempZ = tempZ + simplexCj(BVS(i)) * tableau(i, j) Inc.AddSub Inc.MulDiv Next i Inc.Decis If j < S + D + U + 1 Then ' calculate last row in tableau tableau(M + 1, j) = minMax * (tempZ - simplexCj(j)) Inc.MulDiv ' check for positive value existsZjPositive = IIf(tableau(M + 1, j) > ModuleGauss.eta, True, existsZjPositive) Inc.Decis ' check for biggest value Inc.Decis If tableau(M + 1, j) > tempBiggestZj Then tempBiggestZj = tableau(M + 1, j) biggestZjColumnIndex = j End If Else ' current objective function value tableau(M + 1, j) = tempZ End If Next j Inc.Decis If Not existsZjPositive Then Result.Status = Optimal End Function ' FORM ANALYSIS: COMPARING METHODS EFFICIENCY WITH MULTIPLE PROBLEMS Public fieldSelectedProblem As ClassProblem Private firstActivation As Boolean Private problemCollection As New Collection ' handle adding to collection and grid ' Public Sub AddToProblemCollection(newDefinitionFile As String) On Error GoTo errorAddToProblemCollection Dim addProblemCount As Long: addProblemCount = problemCollection.Count + 1 Dim tempProblem As New ClassProblem: Set tempProblem = New ClassProblem tempProblem.InitialWithNoDisplay tempProblem.OpenProblem newDefinitionFile

Page 122: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

113

problemCollection.Add tempProblem, tempProblem.ProblemName mgAnalysis.SetHeaderRow Array(" "), addProblemCount tempProblem.DisplayInAnalysis mgAnalysis, addProblemCount mgAnalysis.ApplyCheck addProblemCount CheckProblemsCount Exit Sub errorAddToProblemCollection: If Err.Number = 457 Then ' collection.add error: item (key) already exists MsgBox "Problem is already included in analysis" & _ NewLine("Problem name: " & tempProblem.ProblemName), , _ "ADD PROBLEM ERROR!" On Error Resume Next Else Err.Raise Err.Number, , "Add problem to collection. Problem name:" & NewProblemName & _ NewLine("File: " & newDefinitionFile) & _ NewLine(Err.Description) End If End Sub ' ' clear analysis grid ' Public Sub ClearAnalysisEntries() Set problemCollection = Nothing Set problemCollection = New Collection mgAnalysis.SelectedRow = 0 mgAnalysis.ClearValueRows CheckProblemsCount End Sub ' ' execute methods ' Public Sub ExecuteWithCheckedProblems() On Error GoTo errorExecuteWithCheckedProblems ' check for problem being edited If ProblemAnalysisRow(FormSingleProblem.CurrentProblem.ProblemName) > 0 Then If Not FormSingleProblem.TestCurrentForSave Then Exit Sub

Page 123: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

114

End If Dim tmpProblem As ClassProblem Screen.MousePointer = 11 Dim tempMethod As EnumMethod Dim problemRow As Long For problemRow = 1 To mgAnalysis.ValueRowCount If mgAnalysis.IsChecked(problemRow) Then Set tmpProblem = problemCollection(mgAnalysis.GetCellValue(problemRow, 1)) For tempMethod = PushPull To Simplex If mclMethods.CheckLabel(EnumMethodAsString(tempMethod)) Then tmpProblem.Result(tempMethod).ResetToDefault If tempMethod = PushPull Then ModulePushPull.ExecutePushPull tmpProblem If tempMethod = Simplex Then ModuleSimplex.ExecuteSimplex tmpProblem tmpProblem.DisplayInAnalysis mgAnalysis, problemRow End If Next tempMethod tmpProblem.SaveProblem End If Next problemRow If Not SelectedProblem Is Nothing Then ShowSelected SelectedProblem.ProblemName Screen.MousePointer = 0 Exit Sub errorExecuteWithCheckedProblems: Screen.MousePointer = 0 MsgBox Err.Description, , "EXECUTE METHODS ERROR!" End Sub ' reset results for ticked methods and checked problems ' Public Sub ResetResultsForCheckedProblems() On Error GoTo errorResetResultsForCheckedProblems Dim tmpProblem As ClassProblem Screen.MousePointer = 11 Dim tempMethod As EnumMethod

Page 124: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

115

Dim problemRow As Long For problemRow = 1 To mgAnalysis.ValueRowCount If mgAnalysis.IsChecked(problemRow) Then Set tmpProblem = problemCollection(mgAnalysis.GetCellValue(problemRow, 1)) For tempMethod = PushPull To Simplex If mclMethods.CheckLabel(EnumMethodAsString(tempMethod)) Then tmpProblem.Result(tempMethod).ResetToDefault If Dir(tmpProblem.Result(tempMethod).DetailFile) <> "" Then _ Kill tmpProblem.Result(tempMethod).DetailFile tmpProblem.DisplayInAnalysis mgAnalysis, problemRow End If Next tempMethod tmpProblem.SaveProblem End If Next problemRow If Not SelectedProblem Is Nothing Then ShowSelected SelectedProblem.ProblemName Screen.MousePointer = 0 Exit Sub errorResetResultsForCheckedProblems: Screen.MousePointer = 0 MsgBox Err.Description, , "RESET RESULTS ERROR!" End Sub ' return problem from collection ' Public Function ProblemInCollection(ProblemName As String) As ClassProblem Set ProblemInCollection = problemCollection(ProblemName) End Function ' remove selected problem ' Public Sub RemoveSelectedProblem() If SelectedProblem Is Nothing Then Exit Sub Dim tempProblem As ClassProblem Set tempProblem = SelectedProblem

Page 125: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

116

mgAnalysis.SelectedRow = 0 problemCollection.Remove tempProblem.ProblemName mgAnalysis.RemoveRow ProblemAnalysisRow(tempProblem.ProblemName) ' mgAnalysis.RemoveRow mgAnalysis.SelectedRow Dim i As Long For i = 1 To mgAnalysis.ValueRowCount problemCollection(mgAnalysis.GetCellValue(i, 1)).AnalysisRowIndex = i Next i ' Set SelectedProblem = Nothing CheckProblemsCount End Sub ' ' check if there are any problems in analysis ' Private Sub CheckProblemsCount() Me.Caption = "Analysis: " & mgAnalysis.ValueRowCount & " problems included" ' Dim tempEnabled As Boolean ' tempEnabled = (mgAnalysis.ValueRowCount > 0) ' malAction.LabelEnabled("CLEAR") = tempEnabled ' malAction.LabelEnabled("REMOVE") = tempEnabled ' malAction.LabelEnabled("EXPORT") = tempEnabled ' malAction.LabelEnabled("EXECUTE") = tempEnabled ' ' mclMethods.EnableAll tempEnabled End Sub ' property set selected problem ' Public Property Set SelectedProblem(NewProblem As ClassProblem) Set fieldSelectedProblem = NewProblem End Property ' ' property get selected problem ' Public Property Get SelectedProblem() As ClassProblem Set SelectedProblem = fieldSelectedProblem End Property ' set analysis grid headers, etc... '

Page 126: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

117

Private Sub SetAnalysisGrid() With mgAnalysis .CheckBoxed("Check All") = True .CanHideColumn = True .showSelectedRow = True .ToggleSelectedEnabled = False Dim titleMatrix(1, 0) titleMatrix(0, 0) = "" titleMatrix(1, 0) = "" .SetHeaderTitle titleMatrix .SetHeaderColumn Array("Definition", "Name"), 1 .SetHeaderColumn Array("#-", "Objective") .SetHeaderColumn Array("#-", "m") .SetHeaderColumn Array("#-", "s") .SetHeaderColumn Array("#-", "Constraints") Dim method As EnumMethod For method = PushPull To Simplex .OtherData(EnumMethodAsString(method)) = .currentCol + 1 .SetHeaderColumn Array(EnumMethodAsString(method), "Status") .SetHeaderColumn Array("#-", "Deg.") .SetHeaderColumn Array("#-", "Value") .SetHeaderColumn Array("#-", "BVS") .SetHeaderColumn Array("#-", EnumCounterAsStr(cntIterations, True)) .SetHeaderColumn Array("#-", EnumCounterAsStr(cntAddSubs, True)) .SetHeaderColumn Array("#-", EnumCounterAsStr(cntMultDivs, True)) .SetHeaderColumn Array("#-", EnumCounterAsStr(cntLoops, True)) .SetHeaderColumn Array("#-", EnumCounterAsStr(cntDecis, True)) Next method .OtherData("last column") = .currentCol .fxgHandle.AllowUserResizing = flexResizeColumns .ClearValueRows End With End Sub ' examine if problem exists ' Public Function ProblemAnalysisRow(ProblemName) As Long ProblemAnalysisRow = 0 Dim i As Long For i = 1 To mgAnalysis.ValueRowCount If mgAnalysis.GetCellValue(i, 1) = ProblemName Then ' problem found ProblemAnalysisRow = i Exit For End If

Page 127: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

118

Next i End Function ' ' show as selected if exists ' Public Function ShowSelected(ProblemName As String) As Boolean Dim tempAnalysisRow As Long: tempAnalysisRow = ProblemAnalysisRow(ProblemName) ShowSelected = (tempAnalysisRow > 0) mgAnalysis.SelectedRow(True) = tempAnalysisRow End Function ' activating ' Private Sub Form_Activate() Unload Me If firstActivation Then firstActivation = False SetAnalysisGrid CheckProblemsCount End If End Sub ' loading of a form ' Private Sub Form_Load() firstActivation = True cdlgExport.InitDir = App.Path cdlgExport.CancelError = True ' initiate action labels (menu) Set malAction.HostForm1 = FormAnalysis Set malAction.HostForm2 = FormRepository Set malAction.HostForm3 = FormSingleProblem malAction.Direction = alHorizontal malAction.AddNew "CLEAR", "Clear", "Clear all problems form analysis list." malAction.AddNew "REMOVE", "Remove", "Remove selected problem from the list." malAction.AddNew "EXPORT", "Export Analysis", "Export analysis list (result) to TXT file." ' malAction.AddNew "OPEN", "Open Analysis", "Open MS Excel file with exported analysis." malAction.AddNew "RESET", "Reset Results", "Reset results for ticked methods and checked problems." malAction.AddNew "EXECUTE", "Execute Algorithm:", "Execute ticked algorithms on checked problems." ' check boxes Set mclMethods.HostForm1 = FormAnalysis Set mclMethods.HostForm2 = FormRepository Set mclMethods.HostForm3 = FormSingleProblem mclMethods.Move malAction.Left + malAction.Width, 0 '_

Page 128: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

119

'(malAction.Top + malAction.Height - mclMethods.Height) / 2 mclMethods.AddNew EnumMethodAsString(PushPull), PascalType(EnumMethodAsString(PushPull)), _ "Select method to be executed.", , True mclMethods.AddNew EnumMethodAsString(Simplex), PascalType(EnumMethodAsString(Simplex)), _ "Select method to be executed.", , True End Sub ' before unloading: don't allow, just minimize ' Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Cancel = 1 Me.WindowState = 1 End Sub ' Form Resize: stretch the grid over the whole form Private Sub Form_Resize() If (Me.WindowState <> 1) And (FormMain.WindowState <> 1) Then With mgAnalysis If Me.ScaleWidth - 2 * .Left > 0 Then _ .Width = Me.ScaleWidth - 2 * .Left If Me.ScaleHeight - .Left - .Top > 0 Then _ .Height = Me.ScaleHeight - .Left - .Top End With End If End Sub ' ' execute action ' Private Sub malAction_Action(ActionName As String) Select Case ActionName Case "CLEAR": ClearAnalysisEntries Case "EXPORT": DoExport Case "REMOVE": RemoveSelectedProblem Case "RESET": ResetResultsForCheckedProblems Case "EXECUTE": ExecuteWithCheckedProblems Case Else: MsgBox (ActionName) End Select End Sub ' ' export to selected file ' Public Sub DoExport() On Error GoTo errorDoExport

Page 129: DESIGN AND IMPLEMENTATION OF AUTOMATED SOFTWARE … · 1.1 background to the study 1 1.1.2 standard forms and expressions of linear programming problems 3 1.2 statement of research

120

cdlgExport.ShowSave mgAnalysis.ExportGrid cdlgExport.fileName Exit Sub errorDoExport: Exit Sub End Sub ' selection happened ' Public Sub mgAnalysis_ItemSelected(newSelectedRow As Long) If newSelectedRow = 0 Then Set SelectedProblem = Nothing Else Dim tempProblemName As String tempProblemName = mgAnalysis.GetCellValue(newSelectedRow, 1) Set SelectedProblem = problemCollection(tempProblemName) FormSingleProblem.OpenProblem tempProblemName FormRepository.mflvRepository.Locate tempProblemName End If End Sub ' Name has been changed Public Sub ChangeProblemData(ProblemName As String, _ Optional NewProblemName As String = "") If NewProblemName = "" Then NewProblemName = ProblemName Dim tempAnalysisRow As Long tempAnalysisRow = ProblemAnalysisRow(ProblemName) If tempAnalysisRow = 0 Then Exit Sub problemCollection.Remove ProblemName Dim tempProblem As New ClassProblem: Set tempProblem = New ClassProblem tempProblem.InitialWithNoDisplay tempProblem.OpenProblem RepositoryFolder & "\" & NewProblemName & ".txt" problemCollection.Add tempProblem, tempProblem.ProblemName tempProblem.DisplayInAnalysis mgAnalysis, tempAnalysisRow ShowSelected tempProblem.ProblemName Set tempProblem = Nothing End Sub