Skip to content

Set Wave True causes algorithm always to fail. #14

Description

@RonYanDaik

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions