package affectors; import java.io.PrintWriter; import java.util.Enumeration; import main.Node; import main.Cell; import main.Globals; /** This is a special "meta-affector". Rather than calculating something on its own, the SumAff is a container for other affectors. It simply adds together the values of each affector contained within it, with a scaling factor giving the relative weights of each subaffector. Note that for adding transcriptional activators you should use MultiEnhancer.

Formula
dnodex/dt = alpha1 * SubAffector1 + alpha2 * SubAffector2 + ... + alphaN * SubAffectorN

Parameters
There needs to be one alpha parameter per subaffector. The alphas give the relative weights of each subaffectors contribution to the total value.

Usage
&NODEX

&SumAff alpha_aff1 alpha_aff2
&[an affector]
&[another affector]
&endSumAff
&endNODEX */ public class SumAff extends EnhancerRegionAff implements Cloneable { int [] alphas = new int[3]; static final String desc = "Sum of several other affectors"; static final int [] whichSides = { -1 }; public SumAff() { } protected void setLabelsAndTypes() { setDescriptions(this.desc, null, null); setSided(true, whichSides); this.Type[GUI_CAPABLE] = 0; this.Type[CERTIFICATION] = Affector.RETURNS_DERIV; this.Type[MATHTYPE] = Affector.FF; // ???? None really fit this.Type[TERMTYPE] = Affector.PRODUCTION; } public void setParameterNumbers(int [] param_nums) { if(param_nums.length != numAffectors) { System.out.println("Error: Number of alpha parameters does not match number of affectors in Sum meta-affector"); return; } alphas = new int[param_nums.length]; for(int i = 0; i < param_nums.length; i++) alphas[i] = param_nums[i]; } /** Overrides Affector.getValue() to multiply together the values from all the subsidiary affectors. */ public float getValue(Node which_node) { float value = 0; for(int i = 0; i < numAffectors; i++) { value += params[alphas[i]] * affectors[i].getValue(which_node); } // if(Node.stepNum == 0 && Globals.time > 10 && Globals.time < 80 && Globals.flag > 0 && numAffectors > 3) // // System.out.println(params[alphas[3]] + "\t" + value); return value; } /** Overrides Affector.getNCValue() to multiply together the values from all the subsidiary affectors. */ public float getNCValue(Node which_node) { if(containsTarget) { float value = 0; for(int i = 0; i < numAffectors; i++) value += params[alphas[i]] * affectors[i].getNCValue(which_node); return value; } else return super.getNCValue(which_node); } /* The rest of these functions are overrides of Affector functions so that they work right for this class. */ public Affector copy() { SumAff element = null; try { element = (SumAff)this.clone(); } catch(CloneNotSupportedException e) { System.out.println("Error cloning SumAff: " + e.toString()); } element.affectors = new Affector[3]; element.alphas = new int[numAffectors]; element.numAffectors = 0; for(int i = 0; i < numAffectors; i++) { element.addAffector(affectors[i].copy()); element.alphas[i] = alphas[i]; } element.this_debug_num = debug_num++; return element; } }