Code: Select all
// NoisyMaxDemo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "smile.h"
int main()
{
	DSL_network net;
	int ret = net.ReadFile("noisymax.xdsl");
	if (DSL_OKAY != ret)
	{
		printf("Can't load input file %sn", "noisyadder.xdsl");
		return ret;
	}
	int h = net.FindNode("A");
	if (h < 0)
	{
		printf("Node %s not founnd", "A");
		return h;
	}
	DSL_nodeDefinition *def = net.GetNode(h)->Definition();
	if (def->GetType() != DSL_NOISY_MAX)
	{
		printf("Node %s is not a noisy addern", "A");
		return DSL_WRONG_NODE_TYPE;
	}
	DSL_noisyMAX *adder = static_cast <DSL_noisyMAX *> (def);
	printf("Displaying noisyAdder weights for %s\n", "A");
	DSL_Dmatrix &weights = adder->GetCiWeights();
	for (int i = 0; i < weights.GetSize(); i++)
	{
		printf("%d: %f\n", i, weights[i]);
	}
	int parentCount = adder->GetNumberOfParents();
	int outcomeCount = adder->GetNumberOfOutcomes();
	for (int i = 0; i < parentCount; i++)
	{
		int base = i * outcomeCount * 2;
		double p = (i + 1) * 0.1;
		weights[base] = p;
		for (int j = 1; j < outcomeCount; j++)
		{
			weights[base + j] = (1 - p) / (outcomeCount - 1);
		}
	}
	return net.WriteFile("noisymax-modified.xdsl");
}Code: Select all
			DSL_nodeDefinition *def = theNet.GetNode(nodeHandle)->Definition();
				const DSL_Dmatrix &cpt = *def->GetMatrix();
			const DSL_idArray &outcomes = *def->GetOutcomesNames();
			const int numberOfOutcomes = def->GetNumberOfOutcomes();What's the best way to determine Parent states?
Also, what's the best way to determine Parent names?
Are those in the Noisy Max node or do I need to traverse the parents?