1. 21 Dec, 2018 1 commit
  2. 14 Dec, 2018 5 commits
    • Anne Hommelberg's avatar
      Add unit tests for new io classes · eb5e4b7f
      Anne Hommelberg authored
      Adds unit tests for the two IOMixin and DataStore classes.
      Also fixes some minor bugs in the set_timeseries method.
      Also adds the get_parameter_ensemble_size method to make parameter
      access in the DataStore consistent with access to the stored time
      series.
      eb5e4b7f
    • Anne Hommelberg's avatar
      Fix duplicate checks in DataStore · bc0b8320
      Anne Hommelberg authored
      To keep backwards compatibility with the old duplicate parameters
      check in PIMixin, the DataStore should overwrite the old values with
      new values when duplicates occur. If check_duplicates is True, a
      warning will be given each time this happens.
      bc0b8320
    • Anne Hommelberg's avatar
      Add io accessor for all DataStore access · 8f743998
      Anne Hommelberg authored
      To avoid method naming conflicts, all access methods for
      the internal data store have been put into an self.io accessor.
      For example, call self.io.get_times to get the times stored in the
      internal data store.
      8f743998
    • Anne Hommelberg's avatar
      Fix unit tests · f2aae576
      Anne Hommelberg authored
      The DataStore should allow the input and output folder to not be
      specified, in case the user chooses to not use any of the provided
      IOMixins.
      f2aae576
    • Anne Hommelberg's avatar
      Add general DataStore and IOMixin classes · 00c7de3f
      Anne Hommelberg authored
      Large refactoring of all IO mixins (PIMixin and CSVMixin).
      Adds a general DataStore class extended by OptimizationProblem
      and SimulationProblem, which is used to store all data read by
      the IO mixins.
      Adds an optimization IOMixin class which contains methods that
      were previously duplicated in the optimization PIMixin and
      CSVMixin.
      Adds a simulation IOMixin class which does the same for the
      simulation PIMixin and IOMixin.
      00c7de3f
  3. 13 Dec, 2018 1 commit
  4. 12 Dec, 2018 1 commit
  5. 07 Dec, 2018 1 commit
    • Tjerk Vreeken's avatar
      Optimize evaluation of delay duration · 0ab02ffa
      Tjerk Vreeken authored
      Creating a ca.Function for every single delay is costly. We can save a lot
      of time by combining the evaluation of all delay durations in one
      function.
      
      Note that large parts of this commit's diff are just re-indented or
      moved code.
      0ab02ffa
  6. 06 Dec, 2018 1 commit
    • Jorn Baayen's avatar
      Allow extra variables to appear in path expressions. · 1c0f5f9d
      Jorn Baayen authored
      This is useful for the following type of situation.  Imagine wanting
      to put a uniform upper bound for a state over all time steps.  Then,
      this bound would be an extra variable, and the bound constraint would
      be imposed as a path constraint.
      1c0f5f9d
  7. 26 Nov, 2018 1 commit
  8. 22 Nov, 2018 1 commit
  9. 21 Nov, 2018 2 commits
    • Jesse VanderWees's avatar
      Improve CSVLookupTableMixin and LookupTable tests · e752e0b2
      Jesse VanderWees authored
      Testing of lookuptables was sloppy and not very thorough. Furthermore,
      the tests treated CSVLookupTableMixin as though it is an extension of
      CSVMixin, while the reality is that it is completely independant. This
      commit splits the testing of CSVLookupTableMixin and the LookupTable
      class into its own file, and tests both the symbolic and numerical
      evaluation of LookupTable functions.
      e752e0b2
    • Jesse VanderWees's avatar
      Properly handle LookupTable __call__() parameters · ec12c16c
      Jesse VanderWees authored
      The handling of LookupTable __call__() parameters was somewhat sloppy,
      without clear error codes if parameters were not supported. Furthermore,
      calling with np.nan would expose undefined behaviour. This commit
      improves error messages and does explicit handling of np.nan parameters.
      ec12c16c
  10. 20 Nov, 2018 2 commits
  11. 19 Nov, 2018 2 commits
    • Jorn Baayen's avatar
      b8a6d27e
    • Jesse VanderWees's avatar
      CSVMixin: expose the import/export ts base names · cf15148b
      Jesse VanderWees authored
      This addition brings the CSVMixin API more into line with the PIMIxin.
      By exposing the timeseries_import_basename and
      timeseries_export_basename class variables, a model can select which
      filename to use for imports or exports. This feature is important when
      building more complex RTC-Tools models.
      
      We also add these variables to the class docstrings in both PIMixin and
      CSVMixin, so that these variables are documented by Sphinx.
      
      Closes #1075
      cf15148b
  12. 13 Nov, 2018 1 commit
    • Jesse VanderWees's avatar
      Sim: Update eliminable variable expression · fe6b845d
      Jesse VanderWees authored
      Since Pymoca 0.4.1, expanding vectors is performed first if expand_mx is
      set as well. This means that the variable elimination should also handle
      trailing array indices, e.g. "a.b._c[1,2]" instead of just "a.b._c".
      
      This commit mirrors commit 854d9605, where optimization was fixed.
      fe6b845d
  13. 06 Nov, 2018 2 commits
    • Teresa Piovesan's avatar
      Add alternative goal programming hard constraints · f6eb00d9
      Teresa Piovesan authored
      A new way of turning the soft constraints of goals into hard constraints
      is added in this commit. The user can choose to use this alternative by
      setting setting 'keep_soft_constraints' to True.
      
      The new implementation keeps the soft constraints and the violation
      (a.k.a. epsilon) variables around, and just constrains the objective
      value that a certain priority evaluated to. Note that the results are
      expected to be the same if all violations will be 0.0. Only when
      violations become nonzero can the new implementation provide more room in
      further priorities.
      
      The new implementation is expected to help with infeasibilities in lower
      priorities, even if a trivial goal is added. It turned out that the
      current/old way of goal programming could lead to these infeasibilities,
      likely because it generated entirely differently looking hard constraints.
      
      Note that keeping the violation variables around may or may not lead to a
      performance hit. Because the constraints of the problem remain entirely
      the same except for one additional constraint (and the constraints of the new
      priority), the solver may more readily pick up the seed solution and
      actually be faster in solving the new priority.
      
      A word of caution when using this option with (MI)QCP solvers. A
      quadratic objective will turn into a quadratic constraint. In other words,
      a MIQP problem can turn into a MIQCPQP problem (if the next priority also
      has a quadratic objective). This is something that solvers like Gurobi and
      CPLEX typically cannot handle.
      
      Closes #1048
      f6eb00d9
    • Tjerk Vreeken's avatar
      Fix indexing error in goal function value storage · 41488125
      Tjerk Vreeken authored
      For normal goals, if we would have more than one goal_function stored,
      the indexing would fail because the indices were reversed. The results
      would be a column vector, meaning we would have to index with `[j, :]`
      instead of `[:, j]`. We transpose it into a row vector, such that we can
      use the same indexing for path goals as for normal goals.
      
      The missing broadcasting of goal function values for normal (i.e. not
      path) goals is a regression introduced in 3690cfa4. Instead of relying
      on np.full_like() to do broadcasting, We now explicitly make a
      Timeseries object, which will do the broadcasting for us if needed.
      41488125
  14. 05 Nov, 2018 1 commit
  15. 03 Nov, 2018 2 commits
  16. 02 Nov, 2018 1 commit
    • Teresa Piovesan's avatar
      Fix seed derivatives · 80f225f9
      Teresa Piovesan authored
      The value of the derivatives of the initial time step and of the extra
      variables is included the seed.
      
      Closes issue #1066
      80f225f9
  17. 01 Nov, 2018 3 commits
  18. 31 Oct, 2018 1 commit
    • Tjerk Vreeken's avatar
      Fix formatting of default parameters with types · 56151c84
      Tjerk Vreeken authored
      According to Python's formatting rules, default parameters without types
      should have no spaces around the equals operator. However, if the type of
      a parameter _is_ specified, spaces around the operator are required. See
      also PEP-3107 for examples of such code.
      
      Flake8 only started reporting this formatting error starting with version
      3.6 (error code E252), causing our test pipeline to fail even though there
      were no changes to the codebase. This commit makes sure that the
      formatting checks pass again.
      56151c84
  19. 14 Oct, 2018 3 commits
    • Jesse VanderWees's avatar
      fix initialization error in GP mixin · 0b5e668d
      Jesse VanderWees authored
      A previous commit accidentally referenced the self.ensemple_size
      property in the __init__ method. self.ensemble_size is not known until
      after self.pre(), when [PI, CSV]Mixin read the input data. This commit
      removes that reference, and makes the assumption that there are no
      ensembles. This means that models using ensembles cannot call the
      constraints method with with an ensemble_member parameter greater than 0
      until after GP optmize has first run.
      
      While it is unlikely that any user would encounter this issue, we should
      find a real solution to this problem.
      0b5e668d
    • Jesse VanderWees's avatar
      fix set_timeseries() for goal funtion_values error · 11ec493c
      Jesse VanderWees authored
      As of right now, set_timeseries() requires the timeseries parameter to
      be the same shape as times(). With the GP refactor, we were passing a
      timeseries of len 1 for normal goals. We now use np.full_like() to
      coerce the single-valued function_values into the correct shape.
      11ec493c
    • Jesse VanderWees's avatar
      fix indexing mistake in gp function evaluation · 299fb572
      Jesse VanderWees authored
      While refactoring to merge goal and path_goal logic, an array indexing
      error was introduced, rendering normal goals unusable. We now transpose
      the path_goal expr so that the output from the goal and path_goal expr
      evaluation have the same shape.
      299fb572
  20. 11 Oct, 2018 1 commit
  21. 27 Sep, 2018 1 commit
    • Tjerk Vreeken's avatar
      Update eliminable variable expression · 854d9605
      Tjerk Vreeken authored
      Since Pymoca 0.4.1, expanding vectors is performed first if expand_mx is
      set as well. This means that the variable elimination should also handle
      trailing array indices, e.g. "a.b._c[1,2]" instead of just "a.b._c".
      854d9605
  22. 26 Sep, 2018 1 commit
    • Tjerk Vreeken's avatar
      Use AliasRelation generated by Pymoca · f3545cc2
      Tjerk Vreeken authored
      Since Pymoca 0.4.0, the AliasRelation is part of the Model (and
      CachedModel) classes. We can therefore save a bit of time by not
      rebuilding it ourselves.
      f3545cc2
  23. 25 Sep, 2018 5 commits
    • Tjerk Vreeken's avatar
      Fix DeprecationWarnings in tests · e82b3069
      Tjerk Vreeken authored
      The assertRaisesRegexp name was deprecated in Python 3.2 in favor of
      assertRaisesRegex. Our minimum version requirement is Python 3.5, so
      this change is fully backwards compatible for our purposes.
      
      The np.all() check would raise a DeprecationWarning if the lengths of
      the two arrays were not equal. The required additional length check
      means the early termination moves inside the if-else for __iter__ (i.e.
      is "t" an np.ndarray or a float). Note that we can skip the length check
      when "t" is a float, making the early termination a little more
      generic (also working when len(ts) > 1).
      e82b3069
    • Tjerk Vreeken's avatar
      GoalProgramming: Add constraint relaxation option · cb59b9ed
      Tjerk Vreeken authored
      This option was removed in deae0c3f, as its previous implementation was
      somewhat of a misnomer. The "constraint_relaxation" option is now
      re-added, but in a way that is consistent with its naming and intent.
      
      The "constraint_relaxation" option should be used to add  _constant_
      slack to any hard constraint generated for a goal. If a relative slack
      is needed, one can use either a goal's relaxation, or the
      "violation_relaxation" option.
      cb59b9ed
    • Tjerk Vreeken's avatar
      Validate goal target min/max variable type · 3069228c
      Tjerk Vreeken authored
      3069228c
    • Tjerk Vreeken's avatar
      Refactor goal programming mixin · 3690cfa4
      Tjerk Vreeken authored
      External API stays the same, but internally things are restructured to:
      
      1) Share as much code between goals and path goals as possible
      2) Increase readibility of flow in code by moving things into
         methods/functions
      3) Prepare for an alternative implementation of the hard constraints
      4) Prepare for vector goals
      
      As far as the changes are concerned, they can be summarized as:
      
      1) Merge code paths of goals and path goals as much as possible
      2) Keep track of soft and hard constraints separately. Note that we do not
         need to associate a soft constraint with a function_key, because they
         are guaranteed to be linearly independent. This change is mainly made
         to prepare for a yet-to-be-implemented alternative way of formulating
         hard constraints.
      3690cfa4
    • Tjerk Vreeken's avatar
      Small optimization in processing of DAE outputs · 1d442187
      Tjerk Vreeken authored
      Although this is typically only ~200-500 ms, the vertsplit is about 3
      times faster because it reduces the SWIG call overhead.
      1d442187