Return to Appendix B.

ESMAIN.H
// Matt Streeter
// 2/27/00
// ESMAIN.H
// Header for class TESMainWindow; window class for main program window.
// Copyright Matt Streeter, 2000.  All rights reserved

#ifndef __ESMAIN_H__
#define __ESMAIN_H__

#include <owl/owlpch.h>
#include <owl/applicat.h>
#include <owl/inputdia.h>

#include "ESData.hpp"
#include "Pop.hpp"
#include "graph.h"
#include "heredity.h"
#include "types.h"
#include "eswindow.h"
#include "nvis.h"
#include "esstatic.h"

// These #defines determine the maximum length, respectively, of text entered
// in reponse to the "Layers: ", "Nodes Per Layer: ", and "Total Nodes: "
// prompts.
#define MAX_LAYER_LEN 12
#define MAX_NODES_PER_LAYER_LEN 32
#define MAX_TOTAL_NODES_LEN 12

struct TNetworkConfigStruct
{
	BOOL bFeedforward;
	BOOL bHopfield;
	char pLayers[MAX_LAYER_LEN];
	char pNodesPerLayer[MAX_NODES_PER_LAYER_LEN];
	char pTotalNodes[MAX_TOTAL_NODES_LEN];
   BOOL bUseBackpropagation;
};

class TNetworkConfigDialog: public TDialog {
  public:
	TNetworkConfigDialog(TWindow *pParent,TNetworkConfigStruct *pTransfer);
};

// These two #defines determine the maximum length of text entered in
// response to the "Number of parents: " and "Number of children: " prompts,
// respectively.
#define MAX_MU_LEN 12
#define MAX_LAMBDA_LEN 12

struct TESConfigStruct
{
	char pMu[MAX_MU_LEN];
	char pLambda[MAX_LAMBDA_LEN];
	BOOL bPlus;
	BOOL bComma;
};

class TESConfigDialog: public TDialog {
  public:
	TESConfigDialog(TWindow *pParent,TESConfigStruct *pTransfer);
};

enum GenerationState
{
	NO_STATE=0,
	START,
	GENERATE_CHILD,
	MERGE,
	INDEX,
	SAVE,
	DONE
};

class TESMainWindow : public TESWindow {
  public:
	TESMainWindow(char *pTitle);
	byte Running() {return mbRunning;}

  protected:
	GenerationState mGenerationState;
   int miChildrenGenerated;

	TESButton *mpESButton, *mpProblemButton,*mpRunButton,*mpPauseButton,
		*mpPlotButton, *mpResetButton, *mpNetworkButton, *mpBestButton,
		*mpGenerationButton;
	THSlider *mpMutationSlider;
	TESStatic *mpESStatic, *mpGenerationNumStatic, *mpBestScoreStatic,
		*mpProblemStatic, *mpNetworkStatic;
	TESGraphWindow *mpPlotWindow;

	ESWorkspace mES;
	ESParams mParams;
	ParamInfo mPInfo;
	Population mParent,mChild;
	byte mbPlus;
	byte mbUseBackpropagation;
	byte mbRunning;
	GenerationScore *mpScoreList;
   TGeneration *mpGenerationList;
	double *mpLBSigma,*mpUBSigma;

   void CreateChildren();
	void SetupWindow();
	bool IdleAction(long idleCount);

	void HandleESButtonMsg();
	void HandleProblemButtonMsg();
	void HandleRunButtonMsg();
	void HandlePauseButtonMsg();
	void HandlePlotButtonMsg();
	void HandleResetButtonMsg();
	void HandleNetworkButtonMsg();
	void HandleBestButtonMsg();
   void HandleGenerationButtonMsg();
	void HandleMutationSlider(UINT code);

	void StartRunning();
	void PauseRunning();
	void StopRunning();

   void SetChromosomeLength(int iLen);
	void Reset();
   void RedrawPlotWindow();

	void InitGenerationStats();
	void AddGenerationStats();
	int InitES();
	int InitGenerationCycle();
   int GenerationCycle();
	int Generation();

	int LoadConfigFile();
   void UpdateMutationSlider();
	void UpdateESStatic();
	void UpdateGenerationNumStatic();
	void UpdateBestScoreStatic();
	void UpdateProblemStatic();
	void UpdateNetworkStatic();
   double GetAverageSigma();
	void GetESStaticStr(char *pDest);
   void GetProblemStaticStr(char *pDest);
	void GetNetworkStaticStr(char *pDest);
	void SaveCurrentGeneration();
   void DeleteGenerationList();

   DECLARE_RESPONSE_TABLE(TESMainWindow);
};

class TESWinApp : public TApplication {
  public:
	 TESWinApp() : TApplication() {}

  protected:
	 void InitMainWindow();
};

#endif // __ESMAIN_H__

Return to Appendix B.