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

Set Wave True causes algorithm always to fail. #14

Open
RonYanDaik opened this issue Nov 6, 2023 · 0 comments
Open

Set Wave True causes algorithm always to fail. #14

RonYanDaik opened this issue Nov 6, 2023 · 0 comments

Comments

@RonYanDaik
Copy link

RonYanDaik commented Nov 6, 2023

I've tried to alternate a bit algorithm with my poor understanding of it by changing function Wave::set to accept true values:

bool Wave::set(unsigned index, unsigned pattern, bool value) noexcept
{
	bool old_value = data.get(index, pattern);
	// If the value isn't changed, nothing needs to be done.
	if (old_value == value)
	{
		return false;
	}
	// Otherwise, the memoisation should be updated.
	data.get(index, pattern) = value;
	if(!value){
		memoisation.plogp_sum[index] -=  plogp_patterns_frequencies[pattern];
		memoisation.sum[index] -= patterns_frequencies[pattern];
		memoisation.log_sum[index] = log(memoisation.sum[index]);
		memoisation.nb_patterns[index]--;
		memoisation.entropy[index] = memoisation.log_sum[index] - memoisation.plogp_sum[index] / memoisation.sum[index];
	}else{
		memoisation.plogp_sum[index] +=  plogp_patterns_frequencies[pattern];
		memoisation.sum[index] += patterns_frequencies[pattern];
		memoisation.log_sum[index] = log(memoisation.sum[index]);
		memoisation.nb_patterns[index]++;
		memoisation.entropy[index] = memoisation.log_sum[index] - memoisation.plogp_sum[index] / memoisation.sum[index];
	}
	// If there is no patterns possible in the cell, then there is a
	// contradiction.
	if (memoisation.nb_patterns[index] == 0)
	{
		is_impossible = true;
		//todo: print imposible pattern
	}
	return is_impossible;
}

Idea is after removing some wave patterns manually, to be able to add some waves patterns, if needed.
But no matter what i do, even if I call this before propagate, algorithm always fails.
Can this work at all? Maybe someone can point or give a hint why this wont work?

@RonYanDaik RonYanDaik changed the title Set Wave True causes alwais algorithm to fail. Set Wave True causes algorithm always to fail. Nov 6, 2023
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