From 7486ed83a310cc82a1c3149f9258d853f43cc11b Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 16 Jan 2017 18:07:09 -0800 Subject: remove redundant helpers from modelthing --- src/modelica_model.rs | 45 --------------------------------------------- 1 file changed, 45 deletions(-) diff --git a/src/modelica_model.rs b/src/modelica_model.rs index 40b83d6..54363c8 100644 --- a/src/modelica_model.rs +++ b/src/modelica_model.rs @@ -2,7 +2,6 @@ extern crate modelica_parser; use std::clone::Clone; -use std::collections::HashMap; use std::collections::HashSet; use std::iter::FromIterator; @@ -13,8 +12,6 @@ use errors::Result; /// Helpers pub trait ModelicaModelExt { - fn get_constant_vars(&self) -> HashMap>; - fn get_free_vars(&self) -> HashSet; fn solve_for(&self, indep_vars: Vec, dep_vars: Vec) @@ -22,48 +19,6 @@ pub trait ModelicaModelExt { } impl ModelicaModelExt for ModelicaModel { - fn get_constant_vars(&self) -> HashMap> { - let mut binds = HashMap::new(); - // XXX: actually implement this... - for c in &self.components { - match c.prefix { - Some(ComponentPrefix::Constant) => { - binds.insert(c.name.clone(), Some(Expr::Integer(123))); - } - Some(ComponentPrefix::Parameter) => { - binds.insert(c.name.clone(), Some(Expr::Float(4.56))); - } - _ => (), - } - } - binds - } - - // This crude function finds "unbound" variables: those which are not constants, parameters, or - // the sole element on the LHS of an equation. - // Bugs: - // if a var is on LHS and RHS of same equation - fn get_free_vars(&self) -> HashSet { - // Start with components, and remove constants and parameters - let vars = self.components.iter().filter(|v| match v.prefix { - Some(ComponentPrefix::Constant) | - Some(ComponentPrefix::Parameter) => false, - _ => true, - }); - - // Remove LHS (bound) vars - let mut outputs = vec![]; - for eq in self.equations.iter() { - // TODO: - if let Expr::Ident(ref symb) = eq.lhs { - outputs.push(symb.to_string()); - } - } - let vars = vars.filter(|v| !outputs.contains(&v.name)); - - vars.map(|c| c.name.clone()).collect() - } - // V variables // Q constants (become kwargs) // P bound vars (independent, inputs/passed, become like constants) -- cgit v1.2.3