fitness {GADAG} | R Documentation |
Compute the fitness of a potential solution
Description
Internal function of the genetic algorithm that evaluates the fitness (penalized log-likelihood) of a potential solution, given as a pair of a permutation (P) and a triangular matrix (T).
Usage
fitness(P,X,T,lambda)
Arguments
P |
A permutation from [1,p] in a matrix form. |
X |
Design matrix, with samples (n) in rows and variables (p) in columns. |
T |
A pxp lower-triangular matrix. |
lambda |
Parameter of penalization (>0). |
Value
A numeric value corresponding to the fitness of the potential solution.
Author(s)
Magali Champion, Victor Picheny and Matthieu Vignes
See Also
Examples
#############################################################
# Loading toy data
#############################################################
data(toy_data)
# toy_data is a list of two matrices corresponding to a "star"
# DAG (node 1 activates all other nodes):
# - toy_data$X is a 100x10 design matrix
# - toy_data$G is the 10x10 adjacency matrix (ground trough)
############################################################
# Creating a candidate solution
############################################################
# define parameters
p <- ncol(toy_data$G)
# permutation matrix
Perm <- sample(p) # permutation in a vector form
P <- matrix(0,p,p)
P[p*0:(p-1) + Perm] <- 1 # Perm is tranformed into a matrix form
# lower-triangular matrix
T <- matrix(rnorm(p),p,p)
T[upper.tri(T,diag=TRUE)] <- 0
########################################################
# Computing the fitness of the potential solution
########################################################
Fitness <- fitness(P=P, X=toy_data$X, T=T, lambda=0.1)
print(Fitness) # here is the fitness of the candidate solution (P,T)
[Package GADAG version 0.99.0 Index]