simulated_annealing_SL: Simulated Annealing Optimization with Categorical Variable...

View source: R/simulated_annealing_SL.R

simulated_annealing_SLR Documentation

Simulated Annealing Optimization with Categorical Variable and R^2 Differences

Description

This function implements the Simulated Annealing algorithm to optimize a solution based on the total variation distance, changes in regression coefficients, R-squared differences, and inter-cluster distance, with respect to a set of categorical and continuous variables.

Usage

simulated_annealing_SL(
  X,
  Y,
  Z,
  X_st,
  Y_st,
  p,
  sd_x = 0.05,
  sd_y = 0.05,
  lambda1 = 1,
  lambda2 = 1,
  lambda3 = 1,
  lambda4 = 1,
  max_iter = 1000,
  initial_temp = 1,
  cooling_rate = 0.99
)

Arguments

X

A numeric vector or matrix of input data (independent variable).

Y

A numeric vector of the dependent variable (target).

Z

A categorical variable (vector), used for grouping data in the analysis.

X_st

A numeric vector of starting values for the composition method of X.

Y_st

A numeric vector of starting values for the composition method of Y.

p

A numeric vector representing the target R^2 values for each category in Z.

sd_x

Standard deviation for the noise added to X during the perturbation (default is 0.05).

sd_y

Standard deviation for the noise added to Y during the perturbation (default is 0.05).

lambda1

Regularization parameter for the total variation distance term (default is 1).

lambda2

Regularization parameter for the coefficient difference term (default is 1).

lambda3

Regularization parameter for the R^2 difference term (default is 1).

lambda4

Regularization parameter for the inter-cluster distance term (default is 1).

max_iter

Maximum number of iterations for the annealing process (default is 1000).

initial_temp

Initial temperature for the annealing process (default is 1.0).

cooling_rate

The rate at which the temperature cools down during annealing (default is 0.99).

Value

A list with the optimized values of X_prime and Y_prime.


covalchemy documentation built on April 12, 2025, 2:15 a.m.