Package com.mockturtlesolutions.snifflib.datatypes

Examples of com.mockturtlesolutions.snifflib.datatypes.DblParamSet


  public Vector getPersistentParameters()
  {
    System.out.println("Running getPersistentParameters of DefaultPredictorPanel");
    Vector outSet = new Vector();
   
    DblParamSet pars = null;
   
    String descriptor = "parameter";
   
    pars = parameterEditor.getParamSet();
    pars.show("pars");
   
    String[] params = pars.parameterSet();
    if (params.length == 0)
    {
      System.out.println("There are no parameters.");
    }
   
    for (int j=0;j<params.length;j++)
    {
      DblMatrix val = pars.getParam(params[j]);
      outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
    }
   
    descriptor = "prior";
    pars = priorEditor.getParamSet();
    params = pars.parameterSet();
   
    for (int j=0;j<params.length;j++)
    {
      DblMatrix val = pars.getParam(params[j]);
      outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
    }
   
    descriptor = "mixing";
    pars = proposalEditor.getParamSet();
    params = pars.parameterSet();
   
    for (int j=0;j<params.length;j++)
    {
      DblMatrix val = pars.getParam(params[j]);
      outSet.add(new PersistentParameter(params[j],descriptor,val.getDoubleAt(0).toString()));
    }
   
    descriptor = "configuration";
    HashMap configmap = this.configurationMap;
View Full Code Here


        // if (this.like instanceof BufferListener)
//         {
//           ((BufferListener)this.like).bufferActionPerformed(ev);
//         }
       
        DblParamSet newParams = null;
        DblParamSet oldParams = null;
        String oldNickname = ev.getOldName();
        String newNickname = ev.getNewName();
       
         oldParams = this.parameterEditor.getParamSet();
        newParams = new DblParamSet();
        String[] params = oldParams.parameterSet();
        for (int j=0;j<params.length;j++)
        {
          String p = params[j];
          String newParamName= p.replaceFirst("#"+oldNickname,"#"+newNickname);
          newParams.put(newParamName,oldParams.get(p));
        }
        this.parameterEditor.setParamSet(newParams);
       
       
        oldParams = this.currentEditor.getParamSet();
        newParams = new DblParamSet();
        params = oldParams.parameterSet();
        for (int j=0;j<params.length;j++)
        {
          String p = params[j];
          String newParamName= p.replaceFirst("#"+oldNickname,"#"+newNickname);
          newParams.put(newParamName,oldParams.get(p));
        }
        this.currentEditor.setParamSet(newParams);
       
       
        oldParams = this.priorEditor.getParamSet();
        newParams = new DblParamSet();
        params = oldParams.parameterSet();
        for (int j=0;j<params.length;j++)
        {
          String p = params[j];
          String newParamName= p.replaceFirst("#"+oldNickname,"#"+newNickname);
          newParams.put(newParamName,oldParams.get(p));
        }
        this.priorEditor.setParamSet(newParams);
       
        oldParams = this.proposalEditor.getParamSet();
        newParams = new DblParamSet();
        params = oldParams.parameterSet();
        for (int j=0;j<params.length;j++)
        {
          String p = params[j];
          String newParamName= p.replaceFirst("#"+oldNickname,"#"+newNickname);
          newParams.put(newParamName,oldParams.get(p));
        }
        this.proposalEditor.setParamSet(newParams);
       
       
        this.proposalEditor.getParamSet().show("The new proposal...");
View Full Code Here

    return(best.Dblget("pH"));
  }
 
  public DblMatrix initpH(DblMatrix iv)
  {
    DblParamSet Param = new DblParamSet();
    DblMatrix initval = iv;
    DblMatrix lrbnd = new DblMatrix(2.0);
    DblMatrix upbnd = new DblMatrix(12.0);
                Param.Dblput("pH",initval);

                NMSimplex Simplex = new NMSimplex(new CbObjective(this),Param);
    
   
    NMSimplexConfiguration Opts = Simplex.getOptions();
    DblParamSet bnd = (DblParamSet)Opts.getConfigValue("LowerBnd");
                bnd.Dblput("pH",lrbnd);
    Opts.setConfigValue("LowerBnd",bnd);
   
    bnd = (DblParamSet)Opts.getConfigValue("UpperBnd");
                bnd.Dblput("pH",upbnd);
    Opts.setConfigValue("UpperBnd",bnd);
               

    try
    {
                  Simplex.solve();
    }
    catch (Exception err)
    {
      throw new RuntimeException("Failed minimization in initpH",err);
    }
                DblParamSet best = Simplex.getBestEstimate();
   
    return(best.Dblget("pH"));
  }
View Full Code Here

    return(best.Dblget("pH"));
  }
 
  public DblMatrix initpH(DblMatrix iv,DblMatrix lr,DblMatrix up)
  {
    DblParamSet Param = new DblParamSet();
    DblMatrix initval = iv;
    DblMatrix lrbnd = lr;
    DblMatrix upbnd = up;
                Param.Dblput("pH",initval);

                NMSimplex Simplex = new NMSimplex(new CbObjective(this),Param);


    NMSimplexConfiguration Opts = Simplex.getOptions();
    DblParamSet bnd = (DblParamSet)Opts.getConfigValue("LowerBnd");
                bnd.Dblput("pH",lrbnd);
    Opts.setConfigValue("LowerBnd",bnd);
   
    bnd = (DblParamSet)Opts.getConfigValue("UpperBnd");
                bnd.Dblput("pH",upbnd);
    Opts.setConfigValue("UpperBnd",bnd);
               
              
    try
    {
                  Simplex.solve();
    }
    catch (Exception err)
    {
      throw new RuntimeException("Failed minimization in initpH",err);
    }
   
                DblParamSet best = Simplex.getBestEstimate();
   
    return(best.Dblget("pH"));
  }
View Full Code Here

  }
 
 
  public DblMatrix initpH()
  {
    DblParamSet Param = new DblParamSet();
    DblMatrix initval = new DblMatrix(4.5);
    DblMatrix lrbnd = new DblMatrix(2.0);
    DblMatrix upbnd = new DblMatrix(12.0);
   
                Param.Dblput("pH",initval);

                NMSimplex Simplex = new NMSimplex(new CbObjective(this),Param);

                NMSimplexConfiguration Opts = Simplex.getOptions();
    DblParamSet bnd = (DblParamSet)Opts.getConfigValue("LowerBnd");
                bnd.Dblput("pH",lrbnd);
    Opts.setConfigValue("LowerBnd",bnd);
   
    bnd = (DblParamSet)Opts.getConfigValue("UpperBnd");
                bnd.Dblput("pH",upbnd);
    Opts.setConfigValue("UpperBnd",bnd);
               
    try
    {
                  Simplex.solve();
    }
    catch (Exception err)
    {
      throw new RuntimeException("Failed minimization in initpH",err);
    }
   
   
                DblParamSet best = Simplex.getBestEstimate();
   
    return(best.Dblget("pH"));
  }
View Full Code Here

 
 
 
  public void setAdjustFor(String flag,boolean f)
  {
    DblParamSet previousParams = this.getParams().copy();
   
    Vector names = this.referenceStorage.getExperimentNames();
    for (int j=0;j<names.size();j++)
    {
      this.unconfigureParametersFor((String)names.get(j));
    }
   
   
   
    if (!this.adjustForMap.containsKey(flag))
    {
      throw new RuntimeException("Flag "+flag+" is not in adjustForMap.");
    }
   
    this.adjustForMap.put(flag,f);
   
   
    // Set keys = this.adjustForMap.keySet();
//     Iterator iter = keys.iterator();
//     while (iter.hasNext())
//     {
//       String key = (String)iter.next();
//       System.out.println("Map has"+key+"="+this.adjustForMap.get(key));
//     }
   
   
    for (int j=0;j<names.size();j++)
    {
      this.configureParametersFor((String)names.get(j));
    }
   
    String[] newParams = this.parameterSet();
    String param = null;
    for (int k=0;k<newParams.length;k++)
    {  
      param = newParams[k];
      if (previousParams.hasParameter(param))
      {
        //Overwrite with the old value.
        this.setParam(param,previousParams.getParam(param));
      }
    }
  }
View Full Code Here

    }
  }
 
  public void setAdjustFor(String flag,int f)
  {
    DblParamSet previousParams = this.getParams().copy();
   
    Vector names = this.referenceStorage.getExperimentNames();
    for (int j=0;j<names.size();j++)
    {
      this.unconfigureParametersFor((String)names.get(j));
    }
   
    if (!this.adjustForMap.containsKey(flag))
    {
      throw new RuntimeException("Flag "+flag+" is not in adjustForMap.");
    }
   
    this.adjustForMap.put(flag,f);
   
    for (int j=0;j<names.size();j++)
    {
      this.configureParametersFor((String)names.get(j));
    }
   
    String[] newParams = this.parameterSet();
    String param = null;
    for (int k=0;k<newParams.length;k++)
    {  
      param = newParams[k];
      if (previousParams.hasParameter(param))
      {
        //Overwrite with the old value.
        this.setParam(param,previousParams.getParam(param));
      }
    }
  }
View Full Code Here

 
 
  public DblParamSet negLogPrior()
        {
 
    DblParamSet OUT = super.negLogPrior();
   
    HashSet estpriors = this.establishedPriors;
    Iterator iter = estpriors.iterator();
 
    while (iter.hasNext())
    {
      String paramname = (String)iter.next();
     
      String priorname = this.mkParameterName(new String[]{"prior","mean",paramname});
      DblMatrix MU = this.getPriorParam(priorname);
      priorname = this.mkParameterName(new String[]{"prior","sigma",paramname});
      DblMatrix SIGMA = this.getPriorParam(priorname);
      this.normal.setMean(MU);
      this.normal.setStd(SIGMA);
      DblMatrix priorprob = this.normal.pdf(this.getParam(paramname));
      //priorprob.show(("Prior for "+paramname),"0.000000000E00");
      OUT.setParam(paramname,DblMatrix.log(priorprob).times(-1.0));
   
    }
   
    return(OUT);
   
View Full Code Here

                DblMatrix target_ionicStr = new DblMatrix(finalIonicStrText.getText());
               
                LinearConstraintObjective obj = new LinearConstraintObjective(repos,A,B,bufferSolutions,target_ionicStr,pH);
               
               
                DblParamSet Param = new DblParamSet();
                BufferSolution sol;
                //We have n-1 parameters since we define the first solutions
                //coefficient to be 1.
                for (int j=1;j<bufferSolutions.size();j++)
                {
                  sol = (BufferSolution)bufferSolutions.get(j);
                  Param.Dblput(new String("Factor"+j),1.0);
                }        
               
                int[] reps = new int[2];
                reps[1] = 1;
                reps[0] = bufferSolutions.size()-1;
                //DblMatrix lrbnd = DblMatrix.replicate(0.0,reps);
                //DblMatrix upbnd = DblMatrix.replicate(1.0,buffsols.size(),1);

                           

                            NMSimplex Simplex = new NMSimplex(obj,Param);

                            //NMSimplexSet Opts = Simplex.getOptions();

                            //Opts.LowerBnd.Dblput("pH",lrbnd);
                            //Opts.UpperBnd.Dblput("pH",upbnd);

                Simplex.solve();
               
                            DblParamSet best = Simplex.getBestEstimate();

                best.show("Best Termination");
               
                factors = new Vector();
                DblMatrix f = null;
                for (int j=0;j<bufferSolutions.size();j++)
                {
                  //sol = (BufferSolution)bufferSolutions.get(j);
                  if (j == 0)
                  {
                    f = new DblMatrix(0.0);
                  }
                  else
                  {
                    f = best.Dblget(new String("Factor"+j));
                  }
                 
                  factors.add(DblMatrix.pow(10,f).getDoubleAt(0));
                }
              }
View Full Code Here

  }
 
 
  public void setAdjustFor(String flag,boolean f)
  {
    DblParamSet previousParams = this.getParams().copy();
   
    Vector names = this.referenceStorage.getExperimentNames();
    for (int j=0;j<names.size();j++)
    {
      this.unconfigureParametersFor((String)names.get(j));
    }
   
    if (!this.adjustForMap.containsKey(flag))
    {
      throw new RuntimeException("Flag "+flag+" is not in adjustForMap.");
    }
   
    this.adjustForMap.put(flag,f);
   
    for (int j=0;j<names.size();j++)
    {
      this.configureParametersFor((String)names.get(j));
    }
   
    String[] newParams = this.parameterSet();
    String param = null;
    for (int k=0;k<newParams.length;k++)
    {  
      param = newParams[k];
      if (previousParams.hasParameter(param))
      {
        //Overwrite with the old value.
        this.setParam(param,previousParams.getParam(param));
      }
    }
  }
View Full Code Here

TOP

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

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.