Print

Print


It sounds like what you really need to do is store the MyClass object somewhere that it's easily accessed.  I suggest that you just subclass SimpleEvolutionState (or whatever) like this:

MyEvolutionState extends SimpleEvolutionState
	{
	public MyClass myobj;
	}

Now you just create a MyEvolutionState instead of a SimpleEvolutionState, stick your myobj in it, and then evolve it.  In your Problem you're handed the EvolutionState.  Cast it to a MyEvolutionState and extract myobj.

If you don't want to extend the EvolutionState, you could extend, say, Finisher, which isn't used by anyone.

Sean


On Oct 20, 2016, at 12:36 PM, Márcio Basgalupp <[log in to unmask]> wrote:

> Dear all,
> 
> In my application, I have extended Evolve class (here called
> MyEvolve.java). In this class, I need to instantiate an object from
> another class created by my (let's say MyClass obj = new MyClass()).
> However, I need to use this object in the evaluate method (implemented
> in my problem).
> 
> How could I pass this object from MyEvolve (extending Evolve.java) to
> MyProblem (public class myProblem extends Problem implements
> SimpleProblemForm)? This object can not be static, that's why I need
> to pass as a parameter. However, ECJ will call the evaluate
> implemented according to SimpleProblemForm (exactly the same
> parameters). Then, I need to know where ECJ calls evaluate(),  then I
> can change it to call a different evaluate (with an additional param),
> and add a new evaluate method in SimpleProblemForm (one more
> parameter: MyClass obj) or implement a new interface (that also
> implements SimpleProblemForm).
> 
> Could someone give me directions to solve this, please?
> 
> Best,
> Márcio
> 
> --------
> Prof. Dr. Márcio Porto Basgalupp
> Instituto de Ciência e Tecnologia (ICT)
> Universidade Federal de São Paulo (UNIFESP)
> Tel: +55 12 3924-9500 (r: 9762)