Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using non default random seed for a model will produce invalid set of results #126

Open
MilanAssuied opened this issue Jul 18, 2024 · 1 comment

Comments

@MilanAssuied
Copy link

Consider the following test case that use 3 parameters of two values each:

 This test uses three parameters with two values each:
 
 AValues: A0, B1
 BValues: B0, B1
 CValues: C0, C1
 
 To be pair-wise covered, the following values pairs need to be generated:
 
 (A0, B0), (A0, B1),
 (A1, B0), (A1, B1),
 (A0, C0), (A0, C1),
 (A1, C0), (A1, C1),
 (B0, C0), (B0, C1)
 (B1, C0), (B1, C1)
 
 Aka: A total of 12 combinations is expected.
 
 This pairs can be covered with the following 3-parameters combinations:
 
 (A0, B0, C1): covers (A0, B0), (A0, C1), (B0, C1)
 (A0, B1, C0): covers (A0, B1), (A0, C0), (B1, C0)
 (A1, B0, C0): covers (A1, B0), (A1, C0), (B0, C0)
 (A1, B1, C1):  covers (A1, B1), (A1, C1), (B1, C1)
 
 Which means that 4 results lines are expected, covering all those combinations.

While this may not be the only set of valid combination, this case establishes that the necessary number of sets to cover all pair-wise combination is 4.

Consider now the following implementation of this test:

void test_that_random_seed_will_produce_invalid_results() {
    std::vector<std::vector<unsigned int>> actual_results;

    const auto random_seed = 6;
    const auto task = PictCreateTask();
    const auto model = PictCreateModel(random_seed);

    PictSetRootModel(task, model);

    PictAddParameter(model, 2);
    PictAddParameter(model, 2);
    PictAddParameter(model, 2);

    const PICT_RESULT_ROW row = PictAllocateResultBuffer(task);
    const size_t paramCount = PictGetTotalParameterCount(task);

    PictGenerate(task);
    PictResetResultFetching(task);

    while (PictGetNextResultRow(task, row)) {
        std::vector<unsigned int> temp_row;

        for (size_t index = 0; index < paramCount; ++index) {
            temp_row.push_back(static_cast<unsigned int>(row[index]));
        }

        actual_results.push_back(temp_row);
    }

    PictFreeResultBuffer(row);

    assert(actual_results.size() == 4);

    PictDeleteModel(model);
    PictDeleteTask(task);
}

This code will produce not 4 but 5 set of results as follow:

{(0, 1, 1), (1, 0, 0), (0, 0, 0), (1, 1, 0), (1, 0, 1)}

As we can see the pair (A1, B0), (B0, C0) and (A1, C0) are present several times.

I found out that between values of 0 and 600, 497 random seeds will produce invalid results.
Using default random seed (0) will produce actual results for this test, but I cannot be sure the results will be valid for any possible models.

@MilanAssuied
Copy link
Author

Interestingly, this bug affects differently windows machines and mac machines.

With MSCVER compiler, I only have 99 seed values over the 600 tried that produce a non optimal result.
With Clang, I have 497 of them.

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

No branches or pull requests

1 participant