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.
Size:
Color:
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.
Size:
Color:
Thanks, that worked, with the following caveat. It needs to be in GetSettingsUI,
but below the if statementCODE:
Please log in to see this code.
Having the statement inside the "if" was the problem
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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?
Size:
Color:
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.
Size:
Color:
Thanks. I knew there was a better way.
I'm sure I'm not done yet, but I should be very close now.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color: