Custom Optimizer ScoreCard Metric Names
Author: LenMoz
Creation Date: 6/1/2014 8:14 PM
profile picture

LenMoz

#1
I've written a custom optimizer, including a settings dropdown that picks up the available metric names, from the initial ScoreCard, that can be optimized. It works, but it doesn't follow along when the user changes the choice of scorecard. I don't know how, or rather in which routine, to repopulate my dropdown. The genetic optimizer has this "ScoreCard following" functionality. I am an admitted newbie to Windows Forms.
profile picture

Eugene

#2
The GA optimizer accomplishes this by querying the following property, as documented in the API manual:
CODE:
Please log in to see this code.

And the placement of the call should be inside:
CODE:
Please log in to see this code.
profile picture

LenMoz

#3
Thanks, that worked, with the following caveat. It needs to be in GetSettingsUI, but below the if statement
CODE:
Please log in to see this code.

Having the statement inside the "if" was the problem
profile picture

Panache

#4
QUOTE:
I've written a custom optimizer, including a settings dropdown that picks up the available metric names, from the initial ScoreCard, that can be optimized.]


Any chance you'd be willing to share how you accomplished this in Particle Swarm? I need to do the same thing.

I know you invested a lot of time in Particle Swarm, so I completely understand if you don't want to.
profile picture

LenMoz

#5
Panache,
The short answer is that I might not be much help to you. Let me start by saying that the user interface, settings and two custom forms, was, by far, the most difficult code for me to write. It was my first foray into Windows Forms and I had a lot of difficulty figuring out what to put where. Because the optimizer instantiates the form but then passes it to higher level code, there are cross thread issues to contend with. I also have had no C# training, rather counting on 50 years of experience in other languages. The result of all that? Code that is too tightly coupled to my main module. I got it to work. I know how to extend it for PSO purposes, but giving you just the Settings pieces is more work than I'm willing to do, and I'm also unwilling to share the full source of PSO. But it didn't hurt for you to ask.

After the above caveats, here's what I can tell you about the PSO implementation...
1. ICustomSettings is implemented in my main module.
CODE:
Please log in to see this code.

2. ... accomplished through calls to a SwarmSettings module. The following code is in my main module
CODE:
Please log in to see this code.

3. The SwarmSettings object in turn calls a uxSwarmSettings object which handles the custom settings form.

Not much, I know. Sorry.

profile picture

Panache

#6
Sorry. I should have made my question more specific.

First, how do you activate the Settings button? In the Exhaustive and Monte Carlo optimizers, it is greyed out, but it is active in Particle Swarm. I would also like to be able to click on it to open a UI with optimization options.

Second, how do you convert MetricNames to SystemPerformance identifiers? I could have a series of if statements to do the conversion, but that doesn't help if there non-standard names in the Performance Visualizer.
profile picture

LenMoz

#7
QUOTE:
First, how do you activate the Settings button?
Per the Optimizer Development Guide...
QUOTE:
PosSizer's provide this capability by implementing the ICustomSettings interface
.
My main module implements ICustomSettings like this...
CODE:
Please log in to see this code.

QUOTE:
Second, how do you convert MetricNames to SystemPerformance identifiers?
I'm not sure I do that. Here's how to get the current metric names...
Code I showed in post #5. Note reference to Host.MetricNames; I iterate this and build a List to populate my dropdown.
CODE:
Please log in to see this code.

Ask again if I've misunderstood.

profile picture

Panache

#8
Thank you.

QUOTE:
Note reference to Host.MetricNames; I iterate this and build a List to populate my dropdown.

Populating the dropdown is relatively straightforward. What I inartfully was trying to ask is how you translate the dropdown to the comparison.

Maybe I'm not understanding, or maybe I'm making bad assumptions about how to program this.

The default item in your dropdown is "Net Profit". When using that metric, I assume your optimizer does something like:

CODE:
Please log in to see this code.


In order to do that, your code has to determine that if the dropdown DisplayMember is "Net Profit" then it uses sp.Results.NetProfit for the comparison and if the dropdown DisplayMember is APR % then it uses sp.Results.APR, etc. Is that a series of:

CODE:
Please log in to see this code.

or is there some more elegant way to determine which value to use?
profile picture

LenMoz

#9
We're getting closer. The "trick" is that the index in the List, which I've remembered as "metricPosition", is also the index to OptimizationResult. I don't need the metric name. The following code is called by my NextRun.
CODE:
Please log in to see this code.

Note that I also validate the metric.
profile picture

Panache

#10
Thanks. I knew there was a better way.

I'm sure I'm not done yet, but I should be very close now.
profile picture

Panache

#11
LenMoz - Thanks again for all of your help. Coding the optimization part of my Optimizer was nothing compared to the time I've spent trying to solve issues like these.
profile picture

LenMoz

#12
QUOTE:
Coding the optimization part of my Optimizer was nothing compared to the time I've spent trying to solve issues like these.

I totally agree. I had the same experience. Glad I was able to move some rocks out of your path.

I use SharpDevelop so can't help with Visual Studio issues.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).