Skip to content

Commit

Permalink
Merge pull request #1 from antoanne/restart
Browse files Browse the repository at this point in the history
Resetting the package structure
  • Loading branch information
antoanne authored Jun 22, 2021
2 parents d257b65 + 5ba6a3c commit 27e8d94
Show file tree
Hide file tree
Showing 113 changed files with 1,126 additions and 1,434 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ifm.Rcheck/*

*.Rproj

lixo/*
demo/output
19 changes: 10 additions & 9 deletions ifm/DESCRIPTION → DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
Package: ifm
Type: Package
Title: Set of functions for financial evaluation of Software Projects
Version: 1.0
Date: 2018-07-31
Author: Antoanne Pontes and Eber Schmitz
Title: Financial evaluation of Projects
Version: 0.1.0
Author: Antoanne Christopher Pontes Wanderley
Authors@R: c(
person("Antoanne", "Pontes", email = "antoanne@gmail.com", role = c("aut", "ctb", "cre")),
person("Eber", "Schmitz", email = "[email protected]", role = c("aut", "cph", "cre")),
person("Antoanne", "Pontes", email = "antoanne@ufrj.br", role = c("aut", "ctb", "cre")),
person("Eber", "Schmitz", email = "[email protected]", role = c("ctb")),
person("Alexandre", "Costa", email = "[email protected]", role = "ctb"),
person("Anderson", "Nepomuceno", email = "[email protected]", role = "ctb"),
person("Andre", "Gheventer", email = "[email protected]", role = "ctb"),
Expand All @@ -15,12 +14,14 @@ Authors@R: c(
person("Marcelo", "Tueiv", email = "[email protected]", role = "ctb"),
person("Washington", "Correia", email = "[email protected]", role = "ctb")
)
Maintainer: Antoanne Pontes <antoanne@gmail.com>
Maintainer: Antoanne Pontes <antoanne@ufrj.br>
Description: R packeage with a set of functions for financial evaluation of
Software Project.
License: LGPL (>= 2.1)
Encoding: UTF-8
URL: https://github.com/antoanne/ifmFramework
BugReports: https://github.com/antoanne/ifmFramework/issues
NeedsCompilation: no
RoxygenNote: 5.0.1
Imports: igraph, XLConnect
RoxygenNote: 7.1.1
Imports: igraph, XLConnect, openxlsx, RUnit
Date: 2018-07-31
Binary file removed Glossary.zip
Binary file not shown.
18 changes: 17 additions & 1 deletion ifm/NAMESPACE → NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,35 @@ export(cpm.all.schedule)
export(discount.rate.vector)
export(discounted.csf)
export(draw.cfs)
export(draw.discounted.cash)
export(draw.graph)
export(excel.list.to.xls)
export(excel.xls.to.list)
export(ifir)
export(inflation.free.interest.rate)
export(mmf.all.sequences)
export(mmf.df.1r)
export(mmf.df.infr)
export(mmf.get.breakeven)
export(mmf.get.selffunding)
export(mmf.max.npv)
export(mmf.npv)
export(net.future.value)
export(net.present.value)
export(npvg)
export(predecessors.to.edges)
export(schedules.1r)
export(utils.pred2graph)
export(utils.pred2suc)
export(utils.suc2pred)
import(XLConnect)
import(igraph)
importFrom(grDevices,dev.off)
importFrom(grDevices,png)
importFrom(graphics,abline)
importFrom(graphics,arrows)
importFrom(graphics,axis)
importFrom(graphics,barplot)
importFrom(graphics,legend)
importFrom(graphics,title)
importFrom(stats,spline)
importFrom(utils,tail)
67 changes: 35 additions & 32 deletions ifm/R/cpm.R → R/cpm.R
Original file line number Diff line number Diff line change
@@ -1,79 +1,82 @@
#' The critical path method (CPM) is a step-by-step project management technique for process
#' The critical path method (CPM) is a step-by-step project management technique for process
#' planning that defines critical and non-critical tasks with the goal of preventing time-frame
#' problems and process bottlenecks#' activities are "critical," meaning that they have to be done on time or else
#' problems and process bottlenecks#' activities are "critical," meaning that they have to be done on time or else
#' the whole project will take longer.
#'
#'
#' @name cpm
#'
#'
#' @aliases critical.path.method critical_path_method
#'
#'
#' @param activities.duration Vector with activities duration.
#' @param activities.successors Vector with dependencies between activities.
#'
#' @description The Critical Path Method or Critical Path Analysis, is a
#' mathematically based algorithm for scheduling a set of project activities.
#'
#' CPM will get how long your complex project will take to complete and which
#' activities are "critical," meaning that they have to be done on time or else
#'
#' @description The Critical Path Method or Critical Path Analysis, is a
#' mathematically based algorithm for scheduling a set of project activities.
#'
#' CPM will get how long your complex project will take to complete and which
#' activities are "critical," meaning that they have to be done on time or else
#' the whole project will take longer.
#'
#' @export
#' @return Returns list of EST (Early Start Time), EFT(Early Finish Time),LST(Lately Start Time), LFT (Lately Finish Time) using Forward Pass and Backward Pass
#'
#'
#' @return Returns list of EST (Early Start Time), EFT(Early Finish Time),
#' LST(Lately Start Time), LFT (Lately Finish Time) using Forward Pass and Backward Pass
#'
#' @keywords critical path, scheduling, project activities
#'
#'
#' @family scheduling
#'
#'
#' @examples
#' ex.cpm.activities.duration <- c(1,4,5,7,2,3,1)
#' ex.cpm.activities.successors <- list(c(2,3), 4, c(4,5), 6, 7, 7, c(0))
#' ex.cpm <- cpm(ex.cpm.activities.duration,
#' ex.cpm <- cpm(ex.cpm.activities.duration,
#' ex.cpm.activities.successors)
#'
cpm <- critical.path.method <- critical_path_method <-
function(activities.duration = c(1,4,5,7,2,3,1),
#'
cpm <- critical.path.method <- critical_path_method <-
function(activities.duration = c(1,4,5,7,2,3,1),
activities.successors = list(c(2,3), 4, c(4,5), 6, 7, 7, c(0)))
{

activities.predecessors <- utils.suc2pred(activities.successors)

activities.quantity <- length(activities.duration)
#generates early and late start times of for a cpm network
est<-vector (mode="numeric", length=activities.quantity)
eft<-vector (mode="numeric", length=activities.quantity)
lst<-vector (mode="numeric", length=activities.quantity)
lft<-vector (mode="numeric", length=activities.quantity)

#Functions
cpm.forward <- function(s=1){
#find early start and finish times
eft[s] <<- est[s] + activities.duration[s]
eft[s] <<- est[s] + activities.duration[s]
if (activities.successors[[s]][1]!=0){
for (i in activities.successors[[s]]){
if (est[i] < eft[s]){
est[i]<<-eft[s]
}
}
cpm.forward(i)
}
}
}
}

cpm.backward<-function(s){
#find late start and finish times
lst[s]<<-lft[s] - activities.duration[s]
lst[s]<<-lft[s] - activities.duration[s]
if (activities.predecessors[[s]][1]!=0){
for (i in activities.predecessors[[s]]){
if (lft[i]>lst[s]){
lft[i]<<-lst[s]
}
lft[i]<<-lst[s]
}
cpm.backward(i)
}
}
}

#Main
cpm.forward()
lft<-rep(eft[activities.quantity], times=activities.quantity)
cpm.backward(activities.quantity)
return(list('est' = est, 'eft' = eft,
return(list('est' = est, 'eft' = eft,
'lst' = lst, 'lft' = lft))
}
}
60 changes: 30 additions & 30 deletions ifm/R/cpm.all.schedule.R → R/cpm.all.schedule.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#' Generates all possible schedules for a cpm network
#'
#'
#' @name cpm.all.schedule
#'
#' @aliases cpm_all_schedule genAllCpmSched
#'
#' @param est early start time vector
#' @param slack activities slack
#'
#'
#' @aliases cpm_all_schedule genAllCpmSched
#'
#' @param cpm CPM vector with Early Start Time, Early Finish Time,
#' Late Start Time and Late Finish Time.
#'
#' @description Generates all possible schedules for a cpm network
#'
#'
#' @export
#'
#'
#' @return Matrix with all mininum makespan (the time to complete all jobs) cpm start time schedules
#'
#'
#' @keywords critical path, scheduling, project activities
#'
#'
#' @family scheduling
#'
#'
#' @examples
#' #Use critical.path.method function to calculate a set of project
#' #Use critical.path.method function to calculate a set of project
#' #activities:
#'
#'
#' ex.cpm.activities.duration <- c(1,4,5,7,2,3,1)
#' ex.cpm.activities.successors <- list(c(2,3), 4, c(4,5), 6, 7, 7, c(0))
#' ex.cpm <- cpm(ex.cpm.activities.duration,
#' ex.cpm <- cpm(ex.cpm.activities.duration,
#' ex.cpm.activities.successors)
#'
#' # Now, we have the CPM vector with:
Expand All @@ -32,43 +32,43 @@
#' # - lst (Late Start Time) - ex.cpm["lst"]
#' # - lft (Late Finish Time) - ex.cpm["lft"]
#'
#' ex.cpm.activities.schedule <-
#' ex.cpm.activities.schedule <-
#' cpm.all.schedule(ex.cpm)
#'
cpm.all.schedule <- cpm_all_schedule <- genAllCpmSched <-
#'
cpm.all.schedule <- cpm_all_schedule <- genAllCpmSched <-
function(cpm){
est <- cpm$est
slack <- (cpm$lst - cpm$est)

# Constants
slack <- slack + 1
m <- prod(slack)
n <- length(slack)

# Variables
current.schedule <- vector(mode = "numeric", length = n)
schedule.matrix <- matrix(ncol = n, nrow = m)

#Algorithm
schedule.matrix[1,] <- current.schedule + est
k <- 2 #row index for current.schedule

for (j in 1:m){
carry <- 1
for (i in n:1){
v <- current.schedule[i] + carry
v <- current.schedule[i] + carry
if (v >= slack[i]){
current.schedule[i] <- 0
carry <- 1
} else {
current.schedule[i] <- v
carry <- 0
sched <- current.schedule + est
carry <- 1
} else {
current.schedule[i] <- v
carry <- 0
sched <- current.schedule + est
schedule.matrix[k,] <- sched
k <- k+1
k <- k+1
break
}
}
}
return(schedule.matrix)
}
}
24 changes: 12 additions & 12 deletions ifm/R/cpm.npv.R → R/cpm.npv.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ cpm.npv <- function(cfs,
schedules,
interest.rate,
begin.of.period = FALSE) {

all.cfs.stream <- list()
all.cfs.nominal <- list()
all.cfs.discounted <- list()
all.npv <- list()

for (count in 1:nrow(schedules)) {
current.schedule.cfs <- list()
current.schedule.npv <- 0
current.activity.id <- 1
for (current.activity.start in schedules[count,]) {
current.unlist.cfs <- unlist(cfs[current.activity.id,], use.names=FALSE)
current.activity.cfs <- (c(rep.int(0, current.activity.start),

current.activity.cfs <- (c(rep.int(0, current.activity.start),
current.unlist.cfs[1:(length(current.unlist.cfs) - (current.activity.start))]))

current.schedule.cfs[[current.activity.id]] <- current.activity.cfs

current.activity.npv <- net.present.value(current.activity.cfs, interest.rate, begin.of.period)
current.schedule.npv <- current.schedule.npv + current.activity.npv

current.activity.id <- current.activity.id + 1
}
all.cfs.stream[[count]] <- current.schedule.cfs
Expand All @@ -34,13 +34,13 @@ cpm.npv <- function(cfs,
begin.of.period)
all.npv[[count]] <- current.schedule.npv
}

return(list(cfs.stream=all.cfs.stream,
cfs.nominal=all.cfs.nominal,
cfs.discounted=all.cfs.discounted,
cfs.nominal=all.cfs.nominal,
cfs.discounted=all.cfs.discounted,
npv=all.npv))
}

# ex.cpm.npv <- cpm.npv(ex.sheet.data.cfs,
# ex.cpm.schedules,
# ex.sheet.data.interest.rate)
# ex.cpm.schedules,
# ex.sheet.data.interest.rate)
Loading

0 comments on commit 27e8d94

Please sign in to comment.