R/phase2.R In mfpp: 'Matrix-Based Flexible Project Planning'

Documented in phase2

```#-----------------------------------------------------------------------------#
#                                                                             #
#  MATRIX-BASED FLEXIBLE PROJECT PLANNING                                     #
#                                                                             #
#  Written by: Zsolt T. Kosztyan, Aamir Saghir                                #
#              Department of Quantitative Methods                             #
#              University of Pannonia, Hungary                                #
#              kosztyan.zsolt@gtk.uni-pannon.hu                               #
#                                                                             #
#-----------------------------------------------------------------------------#
#' @export
phase2<- function(x,p=0.1,s=5.0){
if (!requireNamespace("pracma", quietly = TRUE)) {
stop(
"Package \"pracma\" must be installed to use this function.",
call. = FALSE
)
}
if (methods::is(x,"PDM_list")){
PDM<-x\$PDM
}else{
if ((methods::is(x,"PDM_matrix"))||(methods::is(x,"matrix"))||(methods::is(x,"array"))||(methods::is(x,"data.frame"))){
PDM<-x
}else{
stop(
"truncpdm works only on matix, PDM_matrix, and PDM_list.",
call. = FALSE
)
}
}
class(PDM)<-"PDM_matrix"
n=pracma::size(PDM,1)
m=pracma::size(PDM,2)
PDMout=PDM
if (m>n){
PDMout[,(n+1):m]=PDMout[,(n+1):m]+(pracma::rand(n,m-n)<p)*(PDM[,(n+1):m]*s)
for (i in 1:n){                   #demands will be similar to the other demands
for (j in ((n+1):m)){
if ((PDM[i,j]>0) && (PDM[i,j]<=1) && (PDMout[i,j]>1))
PDMout[i,j]=1                  # %Quality should not be greater than 1
}
}

}
class(PDMout)<-"PDM_matrix"
if (methods::is(x,"PDM_list")){
x\$PDM<-PDMout
output<-x
class(output)<-"PDM_list"
return(output)
}else{
return(PDMout)
}
}
```

Try the mfpp package in your browser

Any scripts or data that you put into this service are public.

mfpp documentation built on June 22, 2024, 9:35 a.m.