@Override
    public void train(List<Instance> instances){
        if(instances==null) return;
        setParameters(instances);
        DualPerceptron dualPerceptron = ((DualPerceptron)this._linkFunction);

        for(int iter=0;iter<this._online_training_iterations;iter++){
            //for every new instance, in this case, it is every instance we have.
            for(int new_instance_id=0;new_instance_id<instances.size();new_instance_id++){
                double y_pred=0;
                for(int i=0;i<instances.size();i++){
                    double y = dualPerceptron.transformLabel(instances.get(i).getLabel());
                    double ker = dualPerceptron.getKernel(i, new_instance_id);
                    y_pred += this._alpha.get(i)*y*ker;
                }
                int y = dualPerceptron.transformLabel(instances.get(new_instance_id).getLabel());
                if(y*y_pred<1){
                    this._alpha.add(new_instance_id,this._alpha.get(new_instance_id)+1);
                }
            }
        }

        dualPerceptron.releaseKernel();
    }