DSL_discDef

<< Click to Display Table of Contents >>

Navigation:  Reference Manual > Node definitions >

DSL_discDef

Header file: discdef.h

class DSL_discDef : public DSL_nodeDef

The abstract class DSL_discDef is derived from DSL_nodeDef and provides outcome implementation for discrete nodes. The outcomes of discrete nodes can be defined in the following ways:

1.Identifiers only, with no numeric information associated with outcomes.

2.Intervals only, with no text identifiers associated with outcomes.

3.Identifiers and intervals.

4.Identifiers and numeric point values. The point values always require text identifiers.


virtual int AddOutcome(const char *outcomeId);

Overridden method from DSL_nodeDef. Adds node outcome with the specified identifier. Returns DSL_OKAY on success, or a negative error code on failure.


virtual int InsertOutcome(int outcomeIndex, const char *outcomeId);

Overridden method from DSL_nodeDef. Inserts node outcome with the specified identifier at the specified index. Returns DSL_OKAY on success, or a negative error code on failure.


virtual int RemoveOutcome(int outcomeIndex);

Overridden method from DSL_nodeDef. Removes node outcome at the specified index. Returns DSL_OKAY on success, or a negative error code on failure.


virtual int GetNumberOfOutcomes();

Overridden method from DSL_nodeDef. Returns the number of node outcomes. The minimum number of outcomes for discrete nodes is two.


virtual int RenameOutcome(int outcomeIndex, const char *newId);

Overridden method from DSL_nodeDef. Changes node outcome identifier at the specified index. Returns DSL_OKAY on success, or a negative error code on failure.


virtual int RenameOutcomes(const DSL_idArray& newOutcomeIds);
virtual int RenameOutcomes(const std::vector<std::string>& newOutcomeIds);

Overridden method from DSL_nodeDef. Changes all outcome identifiers. Returns DSL_OKAY on success, or a negative error code on failure.


virtual const DSL_idArray* GetOutcomeIds() const;

Overridden method from DSL_nodeDef. Returns the const pointer to an identifier array with all outcome identifiers. When node outcomes are defined with intervals and no identifiers, the array contains empty strings.


virtual int SetNumberOfOutcomes(int outcomeCount);

Overridden method from DSL_nodeDef. Sets the number of node outcomes. If the outcome count increases, new outcomes will have automatically generated identifiers. Returns DSL_OKAY on success, or a negative error code on failure.


virtual int SetNumberOfOutcomes(const DSL_idArray& outcomeIds);

Overridden method from DSL_nodeDef. Sets the number of node outcomes and renames them by using specified identifiers.Returns DSL_OKAY on success, or a negative error code on failure.


virtual int ChangeOrderOfOutcomes(const DSL_intArray& newOrder);

Overridden method from DSL_nodeDef. Reorders node outcomes. Returns DSL_OKAY on success, or a negative error code on failure.


virtual int ChangeOrderOfOutcomesWithAddAndRemove(

 const DSL_idArray& ids, const DSL_intArray& newOrder);

Overridden method from DSL_nodeDef. Reorders node outcomes and optionally adds/removes existing outcomes. The outcomes to add should be represented by -1 in newOrder. If the original outcome index is not present in newOrder, the outcome is removed. Returns DSL_OKAY on success, or a negative error code on failure.


bool HasFixedOutcomes() const;

Returns true when the node has a fixed set of outcomes. Currently only qualitative nodes have fixed outcomes.


bool HasIdentifiers() const;

Returns true if the node has outcome identifiers. The identifiers can be omitted only if outcomes are defined by numeric intervals.


bool HasIntervals() const;

Returns true if the node has outcome intervals.


int RemoveIntervals();

Removes outcome intervals and creates default outcome identifiers, if there were no outcome identifiers. Returns DSL_OKAY on success, or a negative error code on failure.


int GetInterval(int outcomeIndex, double& lo, double& hi) const;

Gets the bounds of the interval for the outcome specified by outcomeIndex. Returns DSL_OKAY on success, or a negative error code on failure.


int GetIntervals(DSL_doubleArray& intervals) const;

int GetIntervals(std::vector<double>& intervals) const;

Get all interval boundaries. For a node definition with N outcomes, the output array/vector will have N+1 elements. Returns DSL_OKAY on success, or a negative error code on failure.


int SetIntervals(const DSL_doubleArray& intervals, bool removeIds=false);

int SetIntervals(const std::vector<double>& intervals, bool removeIds=false);

int SetIntervals(std::initializer_list<double> intervals, bool removeIds=false);

Sets all interval boundaries. For an array/vector/initializer list with N elements, the number of outcomes is set to N-1 (therefore, at least three elements are needed). The outcome identifiers are removed if removeIds is set to true. If fewer than three interval edges are specified or the edges are not specified in increasing order, the function fails. Point intervals are allowed. Returns DSL_OKAY on success, or a negative error code on failure.


int Discretize(double value) const;

Converts the continuous value to a non-negative integer outcome index, based on the specified outcome intervals. If the node has no outcome intervals, returns DSL_NO_ITEM. Returns DSL_OUT_OF_RANGE if value is smaller than leftmost interval bound, or is larger than rightmost interval bound.


bool HasPointValues() const;

Returns true if the node has outcome point values.


int RemovePointValues();

Removes outcome point values. Returns DSL_OKAY on success or a negative error code if node definition has no point values.


int PointValueToOutcomeIndex(double pointValue) const;

Gets the outcome index for the point value specified by pointValue. Returns DSL_OKAY on success or a negative error code if node definition has no point values, or if pointValue is not found.


int GetPointValue(int outcomeIndex, double& pointValue) const;

Gets the point value for the outcome specified by outcomeIndex. Returns DSL_OKAY on success or a negative error code if node definition has no point values, or if outcomeIndex is invalid.


int GetPointValues(DSL_doubleArray& pointValues) const;

int GetPointValues(std::vector<double>& pointValues) const;

Gets all point values. For a node definition with N outcomes, the output array/vector will have N elements. Returns DSL_OKAY on success or a negative error code if node definition has no point values.


int SetPointValues(const DSL_doubleArray& pointValues);

int SetPointValues(const std::vector<double>& pointValues);

int SetPointValues(std::initializer_list<double> pointValues);

Sets all point values. The size of an array/vector/initializer list must be equal to the current number of node outcomes. Returns DSL_OKAY on success or a negative error code if the number of point values specified is not equal to the outcome count.


int GetDefaultOutcome() const;

Returns the index of the default outcome, or a negative number if there is no default outcome.


int SetDefaultOutcome(int newDefOutcome);

Sets the index of the default outcome. To remove the default outcome flag, specify -1 as newDefOutcome. Returns DSL_OKAY on success or a negative error code if newDefOutcome is equal to or larger than the number of outcomes.


bool IsFaultOutcome(int outcomeIndex) const;

Returns true if the outcome specified by outcomeIndex is a diagnostic fault.


int SetFaultOutcome(int outcomeIndex, bool fault);

Sets the diagnostic fault flag associated with the outcome specified by outcomeIndex. Returns DSL_OKAY on success, or a negative error code on failure.


const DSL_documentation* GetOutcomeDocumentation(int outcomeIndex) const;

const char* GetOutcomeLabel(int outcomeIndex) const;

const char* GetOutcomeComment(int outcomeIndex) const;

const char* GetOutcomeFix(int outcomeIndex) const;

Get various display-only diagnostic attributes associated with the outcome specified by outcomeIndex. If outcomeIndex is invalid or if there is no attribute associated with the outcome, returns NULL.


int SetOutcomeDocumentation(int outcomeIndex, const DSL_documentation* doc);

int SetOutcomeLabel(int outcomeIndex, const char* label);

int SetOutcomeComment(int outcomeIndex, const char* comment);

int SetOutcomeFix(int outcomeIndex, const char* fix);

Set various display-only diagnostic attributes associated with the outcome specified by outcomeIndex. Returns DSL_OKAY on success, or a negative error code on failure.