diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 7baeefd..155b2ae 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-08-02T18:35:42","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-08-21T16:49:50","documenter_version":"1.6.0"}} \ No newline at end of file diff --git a/dev/algorithms/index.html b/dev/algorithms/index.html index 1f7da23..228ffb1 100644 --- a/dev/algorithms/index.html +++ b/dev/algorithms/index.html @@ -1,5 +1,5 @@ -Algorithms · OperationsResearchModels.jl

Algorithms

Assignment Problem

OperationsResearchModels.solveMethod
solve(a)

Arguments

a::AssignmentProblem: The problem in type of AssignmentProblem

Output

AssignmentResult: The custom data type that holds problem, solution, and optimum cost.

Description

Solves an assignment problem given by an object of in type AssignmentProblem.

Example

julia> mat = [
+Algorithms · OperationsResearchModels.jl

Algorithms

Assignment Problem

OperationsResearchModels.solveMethod
solve(a)

Arguments

a::AssignmentProblem: The problem in type of AssignmentProblem

Output

AssignmentResult: The custom data type that holds problem, solution, and optimum cost.

Description

Solves an assignment problem given by an object of in type AssignmentProblem.

Example

julia> mat = [
                    4 8 1;
                    3 1 9;
                    1 6 7;
@@ -18,7 +18,7 @@
 
 julia> result.cost
 
-3.0
source

Transportation Problem

OperationsResearchModels.solveMethod
solve(t)

Arguments

a::TransportationProblem: The problem in type of TransportationProblem

Output

TransportationResult: The custom data type that holds problem, solution, and optimum cost.

Description

Solves a transportation problem given by an object of in type TransportationProblem.

Example

julia> t = TransportationProblem(
+3.0
source

Transportation Problem

OperationsResearchModels.solveMethod
solve(t)

Arguments

a::TransportationProblem: The problem in type of TransportationProblem

Output

TransportationResult: The custom data type that holds problem, solution, and optimum cost.

Description

Solves a transportation problem given by an object of in type TransportationProblem.

Example

julia> t = TransportationProblem(
                    [   1 1 1 1; 
                        2 2 2 2; 
                        3 3 3 3], 
@@ -49,7 +49,7 @@
 Cost:
 600.0
 Solution:
-[-0.0 -0.0 -0.0 100.0; 100.0 -0.0 -0.0 -0.0; -0.0 -0.0 100.0 -0.0; -0.0 100.0 -0.0 -0.0]
source

Shortest Path

OperationsResearchModels.solveMethod
solve(problem)

Description

Solves a shortest path problem given by an object of in type ShortestPathProblem.

Arguments

problem::ShortestPathProblem: The problem in type of ShortestPathProblem

Output

ShortestPathResult: The custom data type that holds path and cost.

Example

julia> conns = [
+[-0.0 -0.0 -0.0 100.0; 100.0 -0.0 -0.0 -0.0; -0.0 -0.0 100.0 -0.0; -0.0 100.0 -0.0 -0.0]
source

Shortest Path

OperationsResearchModels.solveMethod
solve(problem)

Description

Solves a shortest path problem given by an object of in type ShortestPathProblem.

Arguments

problem::ShortestPathProblem: The problem in type of ShortestPathProblem

Output

ShortestPathResult: The custom data type that holds path and cost.

Example

julia> conns = [
                    Connection(1, 2, 3),
                    Connection(1, 3, 2),
                    Connection(1, 4, 4),
@@ -70,7 +70,7 @@
  Connection(6, 7, 5, "x67")
 
 julia> result.cost
-8.0
source

Maximum Flow

OperationsResearchModels.solveMethod
solve(problem)

Arguments

problem::MaximumFlowProblem: The problem in type of MaximumFlowProblem

Output

MaximumFlowResult: The custom data type that holds path and flow.

Example

julia> conns = [
+8.0
source

Maximum Flow

OperationsResearchModels.solveMethod
solve(problem)

Arguments

problem::MaximumFlowProblem: The problem in type of MaximumFlowProblem

Output

MaximumFlowResult: The custom data type that holds path and flow.

Example

julia> conns = [
                    Connection(1, 2, 3),
                    Connection(1, 3, 2),
                    Connection(1, 4, 4),
@@ -97,7 +97,7 @@
  Connection(6, 7, 3.0, "x67")
 
 julia> result.flow
-7.0
source

Minimum Spanning Tree

OperationsResearchModels.solveMethod
solve(problem::MstProblem)

Arguments

  • problem::MstProblem: The problem in type of MstProblem

Description

Obtains the minimum spanning tree.

Output

  • ::MstResult: A MstResult object that holds the results.

Examples

julia> conns = Connection[
+7.0
source

Minimum Spanning Tree

OperationsResearchModels.solveMethod
solve(problem::MstProblem)

Arguments

  • problem::MstProblem: The problem in type of MstProblem

Description

Obtains the minimum spanning tree.

Output

  • ::MstResult: A MstResult object that holds the results.

Examples

julia> conns = Connection[
                        Connection(1, 2, 10),
                        Connection(2, 3, 10),
                        Connection(3, 4, 10),
@@ -120,7 +120,7 @@
  3-element Vector{Connection}:
   Connection(3, 4, 10, "x34")
   Connection(1, 4, 10, "x14")
-  Connection(2, 3, 10, "x23")
source

pmedian

OperationsResearchModels.PMedian.pmedianFunction
pmedian(data, ncenters)

Arguments

  • data::Matrix: Coordinates of locations
  • ncenters::Int: Number of centers

Description

The function calculates Euclidean distances between all possible rows of the matrix data. ncenters locations are then selected that minimizes the total distances to the nearest rows.

Output

  • PMedianResult: PMedianResult object.

Example

julia> data1 = rand(10, 2);
+  Connection(2, 3, 10, "x23")
source

pmedian

OperationsResearchModels.PMedian.pmedianFunction
pmedian(data, ncenters)

Arguments

  • data::Matrix: Coordinates of locations
  • ncenters::Int: Number of centers

Description

The function calculates Euclidean distances between all possible rows of the matrix data. ncenters locations are then selected that minimizes the total distances to the nearest rows.

Output

  • PMedianResult: PMedianResult object.

Example

julia> data1 = rand(10, 2);
 
 julia> data2 = rand(10, 2) .+ 50;
 
@@ -137,7 +137,7 @@
  21
 
  julia> result.objective
- 11.531012240599605
source

pmedian with distances

OperationsResearchModels.PMedian.pmedian_with_distancesFunction
pmedian_with_distances(distancematrix, ncenters)

Arguments

  • distancematrix::Matrix: n x n matrix of distances
  • ncenters::Int: Number of centers

Description

  • ncenters locations are selected that minimizes the total distances to the nearest rows.

Output

  • PMedianResult: PMedianResult object.
source

CPM (Critical Path Method)

OperationsResearchModels.solveMethod
solve(problem)

Arguments

  • problem::CpmProblem: The problem in type of CpmProblem.

Output

  • ::CpmResult: The object holds the results

Description

Calculates CPM (Critical Path Method) and reports the critical path for a given set of activities.

Example

julia> A = CpmActivity("A", 2);
+ 11.531012240599605
source

pmedian with distances

OperationsResearchModels.PMedian.pmedian_with_distancesFunction
pmedian_with_distances(distancematrix, ncenters)

Arguments

  • distancematrix::Matrix: n x n matrix of distances
  • ncenters::Int: Number of centers

Description

  • ncenters locations are selected that minimizes the total distances to the nearest rows.

Output

  • PMedianResult: PMedianResult object.
source

CPM (Critical Path Method)

OperationsResearchModels.solveMethod
solve(problem)

Arguments

  • problem::CpmProblem: The problem in type of CpmProblem.

Output

  • ::CpmResult: The object holds the results

Description

Calculates CPM (Critical Path Method) and reports the critical path for a given set of activities.

Example

julia> A = CpmActivity("A", 2);
 julia> B = CpmActivity("B", 3);
 julia> C = CpmActivity("C", 2, [A]);
 julia> D = CpmActivity("D", 3, [B]);
@@ -162,12 +162,12 @@
  "I"
 
  julia> result.path == [B, E, G, I]
-true
source

CPM Activity

OperationsResearchModels.CPM.CpmActivityType
CpmActivity(name::String, time::Float64, dependencies)

Description

The object that represents an activity in CPM (Critical Path Method).

Arguments

  • name::String: The name of the activity.
  • time::Float64: The time of the activity.
  • dependencies: The dependencies of the activity in type of Vector{CpmActivity}.

Example

julia> A = CpmActivity("A", 2, []);
+true
source

CPM Activity

OperationsResearchModels.CPM.CpmActivityType
CpmActivity(name::String, time::Float64, dependencies)

Description

The object that represents an activity in CPM (Critical Path Method).

Arguments

  • name::String: The name of the activity.
  • time::Float64: The time of the activity.
  • dependencies: The dependencies of the activity in type of Vector{CpmActivity}.

Example

julia> A = CpmActivity("A", 2, []);
 
 julia> B = CpmActivity("B", 3, []);
 
 julia> C = CpmActivity("C", 2, [A, B]);
-
source

PERT (Project Evalutation and Review Technique)

OperationsResearchModels.solveMethod
solve(problem::PertProblem)::PertResult

Arguments

  • problem::PertProblem: The problem in type of PertProblem.

Example

julia> A = PertActivity("A", 1, 2, 3)
+
source

PERT (Project Evalutation and Review Technique)

OperationsResearchModels.solveMethod
solve(problem::PertProblem)::PertResult

Arguments

  • problem::PertProblem: The problem in type of PertProblem.

Example

julia> A = PertActivity("A", 1, 2, 3)
 PertActivity("A", 1.0, 2.0, 3.0, PertActivity[])
 
 julia> B = PertActivity("B", 3, 3, 3)
@@ -191,12 +191,12 @@
 8.0
 
 julia> result.stddev
-0.0
source

PERT Activity

OperationsResearchModels.CPM.PertActivityType
PertActivity(name::String, o::Float64, m::Float64, p::Float64)::PertActivity

Description

The object that represents an activity in PERT (Program Evaluation and Review Technique).

Arguments

  • name::String: The name of the activity.
  • o::Float64: The optimistic time of the activity.
  • m::Float64: The most likely time of the activity.
  • p::Float64: The pessimistic time of the activity.
  • dependencies: The dependencies of the activity in type of Vector{PertActivity}.

Example

julia> A = PertActivity("A", 1, 2, 3);
+0.0
source

PERT Activity

OperationsResearchModels.CPM.PertActivityType
PertActivity(name::String, o::Float64, m::Float64, p::Float64)::PertActivity

Description

The object that represents an activity in PERT (Program Evaluation and Review Technique).

Arguments

  • name::String: The name of the activity.
  • o::Float64: The optimistic time of the activity.
  • m::Float64: The most likely time of the activity.
  • p::Float64: The pessimistic time of the activity.
  • dependencies: The dependencies of the activity in type of Vector{PertActivity}.

Example

julia> A = PertActivity("A", 1, 2, 3);
 julia> B = PertActivity("B", 3, 3, 4);
-julia> C = PertActivity("C", 5, 6, 7, [A, B]);
source

Knapsack

OperationsResearchModels.solveMethod
solve(problem::KnapsackProblem)::KnapsackResult

Description

Solves the knapsack problem.

Arguments

  • problem::KnapsackProblem: The problem in type of KnapsackProblem.

Output

  • KnapsackResult: The custom data type that holds selected items, model, and objective value.

Example

julia> values = [10, 20, 30, 40, 50];
+julia> C = PertActivity("C", 5, 6, 7, [A, B]);
source

Knapsack

OperationsResearchModels.solveMethod
solve(problem::KnapsackProblem)::KnapsackResult

Description

Solves the knapsack problem.

Arguments

  • problem::KnapsackProblem: The problem in type of KnapsackProblem.

Output

  • KnapsackResult: The custom data type that holds selected items, model, and objective value.

Example

julia> values = [10, 20, 30, 40, 50];
 julia> weights = [1, 2, 3, 4, 5];
 julia> capacity = 10;
-julia> solve(KnapsackProblem(values, weights, capacity));
source

Johnson's Rule

OperationsResearchModels.Johnsons.johnsonsFunction
johnsons(times::Matrix)

Given a matrix of times, returns a JohnsonResult with the permutation of the jobs. If number of machines is 2, it uses the Johnson's algorithm for 2 machines. If number of machines is greater than 2, it uses the Johnson's algorithm by transforming the problem into a 2-machine problem. In order to reduce the original problem to a 2-machine problem, the algorithm checks if the minimum time of the first machine is greater or equal than the maximum time of the other machines and/or if the minimum time of the last machine is greater or equal than the maximum time of the other machines.

For example if we have 4 machines, namely, A, B, C, and D at least one of the following conditions must be satisfied:

  • min(A) >= max(B, C)
  • min(D) >= max(B, C)

The function throws a JohnsonException if the problem cannot be reduced to a 2-machine problem.

Arguments

  • times::Matrix: a matrix of times

Returns

  • JohnsonResult: a custom data type that holds the permutation of the jobs

Example

times = Float64[
+julia> solve(KnapsackProblem(values, weights, capacity));
source

Johnson's Rule

OperationsResearchModels.Johnsons.johnsonsFunction
johnsons(times::Matrix)

Given a matrix of times, returns a JohnsonResult with the permutation of the jobs. If number of machines is 2, it uses the Johnson's algorithm for 2 machines. If number of machines is greater than 2, it uses the Johnson's algorithm by transforming the problem into a 2-machine problem. In order to reduce the original problem to a 2-machine problem, the algorithm checks if the minimum time of the first machine is greater or equal than the maximum time of the other machines and/or if the minimum time of the last machine is greater or equal than the maximum time of the other machines.

For example if we have 4 machines, namely, A, B, C, and D at least one of the following conditions must be satisfied:

  • min(A) >= max(B, C)
  • min(D) >= max(B, C)

The function throws a JohnsonException if the problem cannot be reduced to a 2-machine problem.

Arguments

  • times::Matrix: a matrix of times

Returns

  • JohnsonResult: a custom data type that holds the permutation of the jobs

Example

times = Float64[
     3.1 2.8;
     4.0 7.0;
     8.0 3.0;
@@ -208,7 +208,7 @@
 
 result = johnsons(times)
 
-println(result.permutation)
source

Genetic Algorithm for the problems that cannot be solved with using Johnson's Rule

OperationsResearchModels.Johnsons.johnsons_gaFunction
johnsons_ga(times::Matrix; popsize = 100, ngen = 1000, pcross = 0.8, pmutate = 0.01, nelites = 1)::JohnsonResult

Given a matrix of times, returns a JohnsonResult with the permutation of the jobs. The function uses a genetic algorithm to find the best permutation of the jobs. The genetic algorithm is implemented in the RandomKeyGA module.

Arguments

  • times::Matrix: a matrix of times
  • popsize::Int: the population size. Default is 100
  • ngen::Int: the number of generations. Default is 1000
  • pcross::Float64: the crossover probability. Default is 0.8
  • pmutate::Float64: the mutation probability. Default is 0.01
  • nelites::Int: the number of elites. Default is 1

Returns

  • JohnsonResult: a custom data type that holds the permutation of the jobs

Example

times = Float64[
+println(result.permutation)
source

Genetic Algorithm for the problems that cannot be solved with using Johnson's Rule

OperationsResearchModels.Johnsons.johnsons_gaFunction
johnsons_ga(times::Matrix; popsize = 100, ngen = 1000, pcross = 0.8, pmutate = 0.01, nelites = 1)::JohnsonResult

Given a matrix of times, returns a JohnsonResult with the permutation of the jobs. The function uses a genetic algorithm to find the best permutation of the jobs. The genetic algorithm is implemented in the RandomKeyGA module.

Arguments

  • times::Matrix: a matrix of times
  • popsize::Int: the population size. Default is 100
  • ngen::Int: the number of generations. Default is 1000
  • pcross::Float64: the crossover probability. Default is 0.8
  • pmutate::Float64: the mutation probability. Default is 0.01
  • nelites::Int: the number of elites. Default is 1

Returns

  • JohnsonResult: a custom data type that holds the permutation of the jobs

Example

times = Float64[
     3.1 2.8;
     4.0 7.0;
     8.0 3.0;
@@ -220,7 +220,7 @@
 
 result = johnsons(times)
 
-println(result.permutation)
source

Makespan

Makespan

OperationsResearchModels.Johnsons.makespanFunction
makespan(times::Matrix, permutation::Vector{Int})
 
 Given a matrix of times and a permutation of the jobs, returns the makespan of the jobs.

Arguments

  • times::Matrix: a matrix of times
  • permutation::Vector{Int}: a permutation of the jobs

Returns

  • Float64: the makespan of the jobs

Example


 julia> times = Float64[
@@ -231,7 +231,7 @@
     2 5 6    
 ]
 
-julia> result = makespan(times, [1, 4, 5, 3, 2])
source

Traveling Salesman

OperationsResearchModels.TravelingSalesman.travelingsalesmanFunction
travelingsalesman(distancematrix::Matrix; popsize = 100, ngen = 1000, pcross = 0.8, pmutate = 0.01, nelites = 1)::TravelinSalesmenResult

Given a matrix of distances, returns a TravelinSalesmenResult with the best route and its cost.

Arguments

  • distancematrix::Matrix: a matrix of distances
  • popsize::Int: the population size. Default is 100
  • ngen::Int: the number of generations. Default is 1000
  • pcross::Float64: the crossover probability. Default is 0.8
  • pmutate::Float64: the mutation probability. Default is 0.01
  • nelites::Int: the number of elites. Default is 1

Returns

  • TravelinSalesmenResult: a custom data type that holds the best route and its cost

Example

pts = Float64[
+julia> result = makespan(times, [1, 4, 5, 3, 2])
source

Traveling Salesman

OperationsResearchModels.TravelingSalesman.travelingsalesmanFunction
travelingsalesman(distancematrix::Matrix; popsize = 100, ngen = 1000, pcross = 0.8, pmutate = 0.01, nelites = 1)::TravelinSalesmenResult

Given a matrix of distances, returns a TravelinSalesmenResult with the best route and its cost.

Arguments

  • distancematrix::Matrix: a matrix of distances
  • popsize::Int: the population size. Default is 100
  • ngen::Int: the number of generations. Default is 1000
  • pcross::Float64: the crossover probability. Default is 0.8
  • pmutate::Float64: the mutation probability. Default is 0.01
  • nelites::Int: the number of elites. Default is 1

Returns

  • TravelinSalesmenResult: a custom data type that holds the best route and its cost

Example

pts = Float64[
     0 0;
     0 1;
     0 2;
@@ -257,4 +257,4 @@
     end 
 end
 
-result = travelingsalesman(distmat, ngen = 1000, popsize = 100, pcross = 1.0, pmutate = 0.10)
source
+result = travelingsalesman(distmat, ngen = 1000, popsize = 100, pcross = 1.0, pmutate = 0.10)
source
diff --git a/dev/assets/documenter.js b/dev/assets/documenter.js index b2bdd43..82252a1 100644 --- a/dev/assets/documenter.js +++ b/dev/assets/documenter.js @@ -77,30 +77,35 @@ require(['jquery'], function($) { let timer = 0; var isExpanded = true; -$(document).on("click", ".docstring header", function () { - let articleToggleTitle = "Expand docstring"; - - debounce(() => { - if ($(this).siblings("section").is(":visible")) { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-down") - .addClass("fa-chevron-right"); - } else { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-right") - .addClass("fa-chevron-down"); +$(document).on( + "click", + ".docstring .docstring-article-toggle-button", + function () { + let articleToggleTitle = "Expand docstring"; + const parent = $(this).parent(); + + debounce(() => { + if (parent.siblings("section").is(":visible")) { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-down") + .addClass("fa-chevron-right"); + } else { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-right") + .addClass("fa-chevron-down"); - articleToggleTitle = "Collapse docstring"; - } + articleToggleTitle = "Collapse docstring"; + } - $(this) - .find(".docstring-article-toggle-button") - .prop("title", articleToggleTitle); - $(this).siblings("section").slideToggle(); - }); -}); + parent + .children(".docstring-article-toggle-button") + .prop("title", articleToggleTitle); + parent.siblings("section").slideToggle(); + }); + } +); $(document).on("click", ".docs-article-toggle-button", function (event) { let articleToggleTitle = "Expand docstring"; @@ -110,7 +115,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { debounce(() => { if (isExpanded) { $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-down") .addClass("fa-chevron-right"); @@ -119,7 +124,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { $(".docstring section").slideUp(animationSpeed); } else { $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-right") .addClass("fa-chevron-down"); diff --git a/dev/index.html b/dev/index.html index 66a40f8..c4cc066 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -- · OperationsResearchModels.jl

Operations Research Models

The OperationsResearchModels package includes basic Operations Research subjects such as Transportation Problem, Assignment Problem, Minimum Spanning Tree, Shortest Path, Maximum Flow, and p-medians method for selecting location of facilities.

Package content is incrementaly updated.

Please refer the Algorithms section for the detailed documentation.

+- · OperationsResearchModels.jl

Operations Research Models

The OperationsResearchModels package includes basic Operations Research subjects such as Transportation Problem, Assignment Problem, Minimum Spanning Tree, Shortest Path, Maximum Flow, and p-medians method for selecting location of facilities.

Package content is incrementaly updated.

Please refer the Algorithms section for the detailed documentation.