Show / Hide Table of Contents

Class OptionalObjective

An optional objective in an ExactCoverGraph. An optional objective is both an IObjective and an IPossibility.

This can be satisfied if one or more attached IPossibility objects are selected. Once satisfied, this drops any remaining unknown possibilities, and notifies parent objectives that to select this possibility.

Unlike Objectives, this class can be dropped. Dropping this objetive does not immediately impact attached possibilities. These possibilities may still be dropped or selected, as long as this objective does not become satisfied. If selecting a possibility would satisfy a dropped optional objective, then the call to SudokuSpice.ConstraintBased.IObjective.TrySelectPossibility(SudokuSpice.ConstraintBased.Link) will fail.

All OptionalObjective objects must eventually be descendents of at least one Objective.

Inheritance
object
OptionalObjective
Implements
IOptionalObjective
IObjective
IPossibility
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SudokuSpice.ConstraintBased
Assembly: SudokuSpice.dll
Syntax
public sealed class OptionalObjective : IOptionalObjective, IObjective, IPossibility

Properties

| Edit this page View Source

IsConcrete

True if this possibility is a concrete possibility, i.e. a leaf node in the graph, as opposed to a group of other possibilities.

Declaration
public bool IsConcrete { get; }
Property Value
Type Description
bool
| Edit this page View Source

State

The current state of this node in the ExactCoverGraph.

Declaration
public NodeState State { get; }
Property Value
Type Description
NodeState

Methods

| Edit this page View Source

CreateWithPossibilities(ReadOnlySpan<IPossibility>, int)

Creates an optional objective with the given possibilities attached. This objective will be satisfied when countToSatisfy of these possibilities are selected.

Note that this results in an OptionalObjective with no parent objectives. The returned objective must eventually be connected to at least one top-level required Objective object in order to behave correctly.

Declaration
public static OptionalObjective CreateWithPossibilities(ReadOnlySpan<IPossibility> possibilities, int countToSatisfy)
Parameters
Type Name Description
ReadOnlySpan<IPossibility> possibilities

The possibilities that could satisfy this objective.

int countToSatisfy

The number of possibilities that must be selected to satisfy this objective.

Returns
Type Description
OptionalObjective

The newly constructed optional objective.

Exceptions
Type Condition
ArgumentException

If the countToSatisfy is less than 1 or is impossible with the given number of possibilities.

| Edit this page View Source

GetUnknownDirectPossibilities()

Retrieves any possibilities that are direct descendents of this objective and whose states are unknown.

Declaration
public IEnumerable<IPossibility> GetUnknownDirectPossibilities()
Returns
Type Description
IEnumerable<IPossibility>

Implements

IOptionalObjective
IObjective
IPossibility
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX