actions { SetValue 0.X {{ a 1 b 2 c 3 }} }
depends_on { CONTENTS_OF 0.X }
}
+solution
SetValue 0.X {{ a 1 b 2 c 3 }}
? eq ?Y {{ d 1 e 2 f 3 }}
consider eq ?Y {{ d 1 e 2 f 3 }}
actions { SetValue 0.Y {{ d 1 e 2 f 3 }} }
depends_on { CONTENTS_OF 0.Y }
}
+solution
SetValue 0.Y {{ d 1 e 2 f 3 }}
? member_at X ?XKey ?XValue
consider member_at X ?XKey ?XValue
actions { SetValue 0.XKey 'a'; BindValue 0.XValue 0.X.a }
depends_on { CONTENTS_OF 0.X.a; CONTENTS_OF 0.XKey; CONTENTS_OF 0.XValue }
}
+solution
SetValue 0.XKey 'a'
BindValue 0.XValue 0.X.a
? member_at Y ?YKey ?YValue
actions { SetValue 0.YKey 'd'; BindValue 0.YValue 0.Y.d }
depends_on { CONTENTS_OF 0.Y.d; CONTENTS_OF 0.YKey; CONTENTS_OF 0.YValue }
}
+solution
SetValue 0.YKey 'd'
BindValue 0.YValue 0.Y.d
? eq XValue 2
members { resolution { veracity_depends_on { CONTENTS_OF 0.XValue } } }
}
resolve { proposition eq XValue 2; depends_on { CONTENTS_OF 0.XValue } }
+solution
? eq YValue 2
consider eq YValue 2
resolution_space {
members { resolution { veracity_depends_on { CONTENTS_OF 0.YValue } } }
}
resolve { proposition eq YValue 2; depends_on { CONTENTS_OF 0.YValue } }
+solution
? ...
-backtrack
-remaining resolution_space {
- proposition eq YValue 2
- geometry_depends_on { CONTENTS_OF 0.YValue }
- aperture { VALUE_SET 0.YValue; VALUE_SET 0.Y.e }
- members { }
-}
-backtrack
-remaining resolution_space {
- proposition eq XValue 2
- geometry_depends_on { CONTENTS_OF 0.XValue }
- aperture { VALUE_SET 0.XValue; VALUE_SET 0.X.b }
- members { }
-}
-backtrack
+resume
remaining resolution_space {
proposition member_at Y ?YKey ?YValue
geometry_depends_on { INDICES_OF 0.Y; TYPE_OF 0.YKey; TYPE_OF 0.YValue }
use DX::Hypothesis;
use DX::SearchProcess;
use DX::ResolvedPropositionSet;
-use DX::Value::Unset;
-use DX::ActionBuilder::UnsetValue;
use DX::ActionPolicy::Allow;
+use DX::Step::MarkAsExhaustion;
use DX::Utils qw(:builders);
use DX::Class;
sub find_next_solution {
my ($self) = @_;
- return undef unless my $bt = $self->force_backtrack;
- return $bt->find_solution;
+ my $state = $self->current_search_state->with_one_step;
+ return $self->but(current_search_state => $state)->find_solution;
}
1;
has is_solution_state => (is => 'ro', isa => Bool, required => 1);
+has is_exhaustion_state => (is => 'ro', isa => Bool, required => 1);
+
has on_exhaustion_step => (is => 'ro', isa => Maybe[Step], required => 1);
has on_solution_step => (is => 'ro', isa => Maybe[Step], required => 1);
),
is_solution_state => 0,
)
- : ( next_step => undef, is_solution_state => 1 )
+ : ( next_step => DX::Step::MarkAsExhaustion->new, is_solution_state => 1 )
),
- on_exhaustion_step => undef,
+ is_exhaustion_state => 0,
+ on_exhaustion_step => DX::Step::MarkAsExhaustion->new,
on_solution_step => DX::Step::MarkAsSolution->new,
);
}
package DX::Step::ConsiderProposition;
+use DX::Value::Unset;
+use DX::ActionBuilder::UnsetValue;
use DX::Class;
with 'DX::Role::Step';
proposition => $prop,
),
is_solution_state => 0,
+ is_exhaustion_state => 0,
on_solution_step => DX::Step::CompleteRecheck->new(
resume_search_state => $old_ss->but(next_step => $next_step),
was_recheck_for => $prop,
--- /dev/null
+package DX::Step::MarkAsExhaustion;
+
+use DX::Class;
+
+with 'DX::Role::Step';
+
+sub apply_to {
+ my ($self, $ss) = @_;
+ $ss->but(
+ is_solution_state => 0,
+ is_exhaustion_state => 1,
+ next_step => undef,
+ );
+}
+
+1;
package DX::Step::MarkAsSolution;
+use DX::Step::ResumeSearch;
use DX::Class;
with 'DX::Role::Step';
sub apply_to {
my ($self, $ss) = @_;
+ trace solution => [ statement => [ [ symbol => 'solution' ] ] ];
$ss->but(
is_solution_state => 1,
- next_step => DX::Step::Backtrack->new
+ next_step => DX::Step::ResumeSearch->new
);
}
--- /dev/null
+package DX::Step::ResumeSearch;
+
+use DX::Class;
+
+with 'DX::Role::Step';
+
+sub apply_to {
+ my ($self, $ss) = @_;
+ trace resume => [ statement => [ [ symbol => 'resume' ] ] ];
+ foreach my $adj (@{$ss->decisions_taken}) {
+ my ($rspace_was, $ss_was) = @$adj;
+ next unless @{$rspace_was->remaining_resolution_space->members};
+ trace rspace => [ statement => [
+ [ symbol => 'remaining' ],
+ @{$rspace_was->remaining_resolution_space->for_deparse->[1]}
+ ] ];
+ return $ss_was->but(
+ is_solution_state => 0,
+ next_step => $rspace_was->remaining_resolution_space->next_step
+ );
+ }
+ return $ss->but(
+ is_solution_state => 0,
+ next_step => $ss->on_exhaustion_step
+ );
+}
+
+1;