[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting CandidateProperties.cs,1.1,
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-10-21 18:25:09
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24066/b7_Scripts/TickerSelectionTesting Modified Files: CandidateProperties.cs Log Message: Implemented IComparable interface through the new Fitness property. Members are now protected (and not private anymore), in order to be visible by inherited classes. Index: CandidateProperties.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/CandidateProperties.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CandidateProperties.cs 25 Jul 2005 22:24:09 -0000 1.1 --- CandidateProperties.cs 21 Oct 2005 18:25:01 -0000 1.2 *************** *** 29,42 **** /// <summary> /// This is the class containing basic information ! /// for each candidate to be evaluated in order ! /// to discover the efficient frontier /// </summary> [Serializable] ! public class CandidateProperties { ! private string ticker; ! private float[] arrayOfRatesOfReturn; ! private float[] oppositeArrayOfRatesOfReturn; ! private bool longRatesOfReturn; public CandidateProperties(string ticker, float[] arrayOfRatesOfReturn) --- 29,42 ---- /// <summary> /// This is the class containing basic information ! /// for each candidate to be evaluated /// </summary> [Serializable] ! public class CandidateProperties : IComparable { ! protected string ticker; ! protected float[] arrayOfRatesOfReturn; ! protected float[] oppositeArrayOfRatesOfReturn; ! protected bool longRatesOfReturn; ! protected double fitness; public CandidateProperties(string ticker, float[] arrayOfRatesOfReturn) *************** *** 45,48 **** --- 45,49 ---- this.longRatesOfReturn = true; this.arrayOfRatesOfReturn = arrayOfRatesOfReturn; + this.fitness = 0.0; } *************** *** 58,62 **** --- 59,76 ---- return this.oppositeArrayOfRatesOfReturn; } + //implementation of IComparable interface + public int CompareTo(object obj) + { + if(obj is CandidateProperties) + { + CandidateProperties candidate = (CandidateProperties)obj; + return this.Fitness.CompareTo(candidate.Fitness); + } + + throw new ArgumentException("Object is not of CandidateProperties type!"); + } + //end of implementation of IComparable interface + public float[] ArrayOfRatesOfReturn { *************** *** 80,84 **** get{return this.ticker;} } ! } --- 94,107 ---- get{return this.ticker;} } ! ! public virtual double Fitness ! { ! get{return this.fitness;} ! } ! ! public virtual void setFitness() ! { ! this.fitness = 0.0; ! } } |