Package com.mockturtlesolutions.snifflib.datatypes

Examples of com.mockturtlesolutions.snifflib.datatypes.DblMatrix


             
          }
        });
   
    DblParamSet temp = new DblParamSet();
    temp.setParam("Hey",new DblMatrix(1.0));
    temp.setParam("There",new DblMatrix(2.0));
   
    this.priorEditor.setParamSet(temp);
       
    //this.parameterEditor 
   
View Full Code Here


   
    if (descriptor.equals("parameter"))
    {
      //System.out.println("Adding parameter "+parametername);
      pars = parameterEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(0.0));
      parameterEditor.setParamSet(pars);
     
      pars = currentEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(0.0));
      currentEditor.setParamSet(pars);
    }
    else if (descriptor.equals("prior"))
    {
      //System.out.println("Adding prior "+parametername);
      pars = priorEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(0.0));
      priorEditor.setParamSet(pars);
    }
    else if (descriptor.equals("mixing"))
    {
      //System.out.println("Adding mixing "+parametername);
      pars = proposalEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(0.0));
      proposalEditor.setParamSet(pars);
    }
    else if (descriptor.equals("configuration"))
    {
      //System.out.println("Adding configuration "+parametername);
View Full Code Here

    {
   
      System.out.println("Setting parameter "+parametername+" to "+val);
     
      pars = currentEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(new Double(val)));
      currentEditor.setParamSet(pars);
     
      pars = parameterEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(new Double(val)));
      parameterEditor.setParamSet(pars);
      //pars.show("Current parameter estimates 1");
     
     
      //pars.show("Current parameter estimates 2");
     
     
      currentEditor.repaint();
      parameterEditor.repaint();
     
      //parameterEditor.getParamSet().show("After setting "+parametername+" parameter Set is:");
     
    }
   
    if (descriptor.equals("prior"))
    {
      pars = priorEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(new Double(val)));
      priorEditor.setParamSet(pars);
     
      priorEditor.repaint();
    }
   
    if (descriptor.equals("mixing"))
    {
      pars = proposalEditor.getParamSet();
      pars.setParam(parametername,new DblMatrix(new Double(val)));
      proposalEditor.setParamSet(pars);
     
      proposalEditor.repaint();
     
    }
View Full Code Here

      exp = (String)experiments.get(k);
      subsamples = this.parent.getTitrationSubsampleIDs(exp);

      //Make an overlay plot of the cummulative sum of Conc_i*Volume_Added_i versus pH_i
     
      DblMatrix cv_total = new DblMatrix(0.0);
      DblMatrix v_total = new DblMatrix(0.0);
      //Plot plot = new Plot(data);
      //plot.setOverlay(true);
      boolean NANSENCOUNTERED = false;
      int NANLINE = 0;
      String NANSUB = "";
      String NANEXP = "";
     
      for (int ss=0;ss<subsamples.size();ss++)
      {

        String ssid = (String)subsamples.get(ss);
        cv_total = new DblMatrix(0.0);
        v_total = new DblMatrix(new Double(this.parent.getInitialVolume(exp,ssid)));


        //data.addColumn("pH"+ssid,Double.class);
        //data.addColumn("CV"+ssid,Double.class);
        //plot.addResponseVariable("CV"+ssid);
        //plot.addPredictorVariable("pH"+ssid);

        Vector observations = this.parent.getTitrationObservationNumbers(exp,ssid);
        for (int obs=0;obs<observations.size();obs++)
        {

          String obsnum = (String)observations.get(obs);
          String val;
          Double nval;
         
          val = this.parent.getTitrantConcentration(exp,ssid,obsnum);
          try
          {
            nval = new Double(val);
          }
          catch(Exception err)
          {
            NANSENCOUNTERED = true;
            NANLINE = obs;
            NANSUB = ssid;
            NANEXP = exp;
           
            nval = new Double(Double.NaN);
          }
          Double conc = nval;
          //Double conc = new Double(this.parent.getTitrantConcentration(exp,ssid,obsnum));
          val = this.parent.getVolumeAdded(exp,ssid,obsnum);
          try
          {
            nval = new Double(val);
          }
          catch(Exception err)
          {
            NANSENCOUNTERED = true;
            NANLINE = obs;
            NANSUB = ssid;
            NANEXP = exp;
            nval = new Double(Double.NaN);
          }
          Double volAdded = nval;
          //Double volAdded = new Double(this.parent.getVolumeAdded(exp,ssid,obsnum));
         
          cv_total = cv_total.plus(conc.doubleValue()*volAdded.doubleValue());
          v_total = v_total.plus(volAdded.doubleValue());
         
         
         
          //System.out.println("conc"+conc);
          //System.out.println("volAdded"+volAdded);
View Full Code Here

    catch (Exception err)
    {
         throw new RuntimeException("Failed Cb evaluation.",err);  
    }
   
    DblMatrix out = (DblMatrix)Cbresult.get("total");
    out = DblMatrix.abs(out);
          return(out);
  }
View Full Code Here

 
  public DblMatrix getValueToMinimize()
        {
   
          HashMap Cbresult = null;
    DblMatrix pHval = this.getParam("pH");

    try
    {
      Cbresult = bufferSolution.Cb(pHval,false);
    }
    catch (Exception err)
    {
         throw new RuntimeException("Failed evaluation of Cb.",err);  
    }
   
    DblMatrix out = (DblMatrix)Cbresult.get("total");
    out = DblMatrix.abs(out);
          return(out);  
                 
        }
View Full Code Here

        }
 
  public DblMatrix getValueAt(DblMatrix factors)
        {
    BufferSolution sol;
    DblMatrix fact;
    this.Params.show("Parameters");
   
   
    // for (int j=0;j<this.bufferSolutions.size();j++)
//     {
//       sol = (BufferSolution)this.bufferSolutions.get(j);
//      
//       if (j==0)
//       {
//         fact = new DblMatrix(0.0);
//       }
//       else
//       {
//         fact = this.getParam(new String("Factor"+j));
//       }
//      
//       //We're optimizing the log of the mixture coefficients.
//       factors.setDblAt(DblMatrix.pow(10,fact),j); 
//     }
    
    BufferSolution mixture = null;
    //mixture = BufferSolution.createMixture(this.repos,this.bufferSolutions,factors);
          mixture = BufferSolution.createMixture(this.bufferSolutions,factors);
   
    mixture.show("Mixture");
   
    DblMatrix concMatrix = new DblMatrix(this.BVector.getN());
    HashMap spec_conc = null;
    spec_conc = (HashMap)mixture.species(this.pH);
   
   
    //Get the predicted ionic strength too!
    HashMap ionicStr = null;
    ionicStr = mixture.ionicStr(this.pH);
   
    DblMatrix iStrength = (DblMatrix)ionicStr.get("total");
   
   
    Set buffers = spec_conc.keySet();
    Set ions;
    Iterator iter = buffers.iterator();
    Iterator iterIon;
    String ionComp=null;
    int row=0;
    HashMap abuff=null;
    String buffer;
    int k=0;
    while (iter.hasNext())
    {
      buffer = (String)iter.next();
      abuff = (HashMap)spec_conc.get(buffer);
      ions = abuff.keySet();
      iterIon = ions.iterator();
      while (iterIon.hasNext())
      {
        ionComp=(String)iterIon.next();
        concMatrix.setDblAt((DblMatrix)abuff.get(ionComp),k);
        k++;
      }
    }
   
    //Need to remove constraints for which BVector is NaN
   
    this.AMatrix.show("AMatrix");
    concMatrix.show("concMatrix");
    this.BVector.show("BVector");
   
   
    DblMatrix ionicStrPenalty = iStrength.minus(this.desiredIonicStr);
    ionicStrPenalty = ionicStrPenalty.pow(2);
   
    DblMatrix resids = (this.AMatrix.dot(concMatrix)).minus(this.BVector);
    DblMatrix ONE = new DblMatrix(1.0);
   
    resids = resids.getMap(ONE.minus(DblMatrix.isNaN(resids)));
    resids = DblMatrix.sum(resids.pow(2),1);
    resids = resids.plus(ionicStrPenalty);
   
    resids = DblMatrix.sqrt(resids);
    //resids.show("resids2");
View Full Code Here

    return(resids);
  }
 
        public DblMatrix getValueToMinimize()
        {
    DblMatrix factors = new DblMatrix(this.bufferSolutions.size());
   
    return(this.getValueAt(factors));
   
   
                 
View Full Code Here

   
    this.setSize(400,150);
    this.contentPane = this.getContentPane();
   
    this.contentPane.setLayout(new BoxLayout(this.contentPane,BoxLayout.Y_AXIS));
    this.pH = new DblMatrix(new Double(7.0));
   
    this.matrixBuilder = new MatrixBuilder();
    this.matrixBuilder.setMinVal(new DblMatrix(2.0));
    this.matrixBuilder.setMaxVal(new DblMatrix(12.0));
    this.matrixBuilder.setStepVal(new DblMatrix(25.0));
   
    this.okButton = new JButton("Ok");
    this.cancelButton = new JButton("Cancel");
   
   
View Full Code Here

   
    persistentParams = backingBuffer.getGeneratorParametersForDescriptor(descriptor);
    for (int j=0;j<persistentParams.size();j++)
    {
      PersistentParameter pp = (PersistentParameter)persistentParams.get(j);
      pars.setParam(pp.getName(),new DblMatrix(new Double(pp.getValue())));
      pars2.setParam(pp.getName(),new DblMatrix(new Double(pp.getValue())))
    }
   
   
    descriptor = "prior";
    //pars = this.priorParameters;
    pars = this.priorParameters;
    persistentParams = backingBuffer.getGeneratorParametersForDescriptor(descriptor);
    for (int j=0;j<persistentParams.size();j++)
    {
      PersistentParameter pp = (PersistentParameter)persistentParams.get(j);
      pars.setParam(pp.getName(),new DblMatrix(new Double(pp.getValue())))
    }
   
    this.configureMixingParameters();
   
    descriptor = "mixing";
    //pars = this.mixingParameters;
    pars = this.mixingParameters;
    persistentParams = backingBuffer.getGeneratorParametersForDescriptor(descriptor);
    for (int j=0;j<persistentParams.size();j++)
    {
      PersistentParameter pp = (PersistentParameter)persistentParams.get(j);
      pars.setParam(pp.getName(),new DblMatrix(new Double(pp.getValue())))
    }
   
   
   
   
View Full Code Here

TOP

Related Classes of com.mockturtlesolutions.snifflib.datatypes.DblMatrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.