Skip to content

Port PSO algorithm from legacy Funz plugin to new fz S3 class format#1

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/port-old-pso-plugin-to-fz
Draft

Port PSO algorithm from legacy Funz plugin to new fz S3 class format#1
Copilot wants to merge 6 commits intomainfrom
copilot/port-old-pso-plugin-to-fz

Conversation

Copy link

Copilot AI commented Oct 27, 2025

Migrates the Particle Swarm Optimization algorithm from the old Funz plugin architecture to the new fz framework's S3 class pattern.

Implementation

  • S3 class structure: Constructor returns classed object with options list and mutable state environment
  • Method dispatch: getInitialDesign/getNextDesign/displayResultsget_initial_design.PSO/get_next_design.PSO/get_analysis.PSO/get_analysis_tmp.PSO
  • Data format: Matrix-based I/O → list of named lists (e.g., list(list(x1=0.5, x2=0.3), ...))
  • Analysis return: HTML string → structured dict with text, data, html fields
  • Termination signal: NULL → empty list list()
  • Variable scoping: Explicit capture for future block execution (id, d, seed, maxit)

Example

# Old format
pso <- PSO(list(maxit='30', seed='123'))
X <- getInitialDesign(pso, input, output)  # Returns matrix

# New format  
pso <- PSO(maxit=30, seed=123)
X <- get_initial_design(pso, input_vars, output_vars)  # Returns list of named lists
results <- get_analysis(pso, X, Y)  # Returns list(text=..., data=..., html=...)

Additional files

  • tests/test_basic.R: S3 structure validation
  • examples/branin_example.R: Complete optimization workflow
  • PORTING_GUIDE.md: Migration reference for other algorithms
  • .github/workflows/test.yml: CI with explicit permissions
Original prompt

Create a repository porting old PSO plugin (https://github.com/Funz/algorithm-PSO) to new fz. See https://github.com/Funz/fz/blob/implement-algorithms/examples/algorithms/montecarlo_uniform.R to get details of new fz "algorithm" in R (mostly files in .fz/algorithms/...)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits October 27, 2025 09:00
Co-authored-by: yannrichet-asnr <148193180+yannrichet-asnr@users.noreply.github.com>
Co-authored-by: yannrichet-asnr <148193180+yannrichet-asnr@users.noreply.github.com>
Co-authored-by: yannrichet-asnr <148193180+yannrichet-asnr@users.noreply.github.com>
Co-authored-by: yannrichet-asnr <148193180+yannrichet-asnr@users.noreply.github.com>
Co-authored-by: yannrichet-asnr <148193180+yannrichet-asnr@users.noreply.github.com>
Copilot AI changed the title [WIP] Port old PSO plugin to new fz structure Port PSO algorithm from legacy Funz plugin to new fz S3 class format Oct 27, 2025
Copilot AI requested a review from yannrichet-asnr October 27, 2025 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments