Skip to content

Conversation

Copy link

Copilot AI commented May 19, 2025

Problem

When PictGenerate is called multiple times on the same task, the function does not clean previous results before generating new ones. This causes duplication where calling the function n times while expecting i rows of results will generate n * i rows of results.

Root Cause

The issue is in the Model::Generate() method, where results are accumulated in the m_results collection without clearing previous results first. This means that even after fetching the results and cleaning the result buffers, if the model is modified and generation is triggered again, the initial results will still be present.

Solution

Added a simple one-line fix to clear the results collection at the beginning of the Model::Generate() method:

void Model::Generate()
{
    DOUT( L"Num of params " << (int) m_parameters.size() <<
          L", order: "      << m_order <<
          L", seed: "       << m_randomSeed << endl );
    for( ParamCollection::iterator ip = m_parameters.begin(); ip != m_parameters.end(); ++ip )
        DOUT( ( *ip )->GetName() << L", order: " << ( *ip )->GetOrder() << endl );

    // Clear previous results before generating new ones
    m_results.clear();

    switch( m_generationType )
    // ...
}

Testing

I verified the fix by creating a test program that calls PictGenerate twice and confirms that both calls produce the same number of rows rather than the second call producing twice as many.

All existing tests continue to pass with this change.

Fixes #123.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits May 19, 2025 18:04
Co-authored-by: jaccz <9115223+jaccz@users.noreply.github.com>
Co-authored-by: jaccz <9115223+jaccz@users.noreply.github.com>
Copilot AI changed the title [WIP] PictGenerate does not clean previous results before generating the new ones Fix PictGenerate to clear previous results before generating new ones May 19, 2025
Copilot AI requested a review from jaccz May 19, 2025 18:08
Copilot finished work on behalf of jaccz May 19, 2025 18:08
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.

PictGenerate does not clean previous results before generating the new ones

2 participants