Skip to content

[FEATURE] ways to save logs of search path [PSO] #596

@yezhengli-Mr9

Description

@yezhengli-Mr9

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
#595
to save parameters in the search path, for example, in PSO.
Describe the solution you'd like
Making attempt of putting

mutable std::mutex file_mutex;

int tscall::write_to_file(std::string content) const {
    std::lock_guard<std::mutex> lock(file_mutex);  // Locking to prevent race condition
    std::ofstream file(filename, std::ios::app);   // Open in append mode
    if (file.is_open()) {
        file << content << std::endl;
    } else {
        std::cerr << "Error opening file!" << std::endl;
    }
}    

in

/// Fitness computation
/**
* Computes the fitness for this UDP.
*
* @param x the decision vector.
*
* @return the fitness of \p x.
*/
vector_double rosenbrock::fitness(const vector_double &x) const

A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions