Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEFECT] LogicalModel/HybridModel cannot be used in an EnsembleModel #2321

Open
3 of 13 tasks
alfoa opened this issue May 16, 2024 · 0 comments · May be fixed by #2322
Open
3 of 13 tasks

[DEFECT] LogicalModel/HybridModel cannot be used in an EnsembleModel #2321

alfoa opened this issue May 16, 2024 · 0 comments · May be fixed by #2322

Comments

@alfoa
Copy link
Collaborator

alfoa commented May 16, 2024

Thank you for the defect report

Defect Description

LogicalModel/HybridModel cannot be used in an EnsembleModel. The code crashes since the LogicalModel/HybridModel model instances are not passed in.

Steps to Reproduce

<?xml version="1.0" ?>
<Simulation verbosity="quiet">
  <TestInfo>
    <name>abcd</name>
    <author>abcd</author>
    <created>2020-05-07</created>
    <classesTested>Models.LogicalModel</classesTested>
    <description>
 
    </description>
  </TestInfo>

  <RunInfo>
    <JobName>testLogicalCodeAndExtModelInEnsembleModel</JobName>
    <Sequence>logicalAndExtModel</Sequence>
    <WorkingDir>logicalModelCodeAndExtModelInEnsembleModel</WorkingDir>
    <batchSize>1</batchSize>
  </RunInfo>

  <Files>
    <Input name="gen.one" type="">../logicalCode/gen.one</Input>
    <Input name="gen.two" type="">../logicalCode/gen.two</Input>
  </Files>

  <Functions>
    <External file="../logicalCode/control" name="control">
      <variables>x, y</variables>
    </External>
  </Functions>

  <Models>
    <Code name="poly" subType="GenericCode">
      <executable>../logicalCode/poly_code.py</executable>
      <clargs arg="python" type="prepend"/>
      <clargs arg="-i" extension=".one" type="input"/>
      <fileargs arg="aux" extension=".two" type="input"/>
      <fileargs arg="output" type="output"/>
    </Code>
    <Code name="exp" subType="GenericCode">
      <executable>../logicalCode/exp_code.py</executable>
      <clargs arg="python" type="prepend"/>
      <clargs arg="-i" extension=".one" type="input"/>
      <fileargs arg="aux" extension=".two" type="input"/>
      <fileargs arg="output" type="output"/>
    </Code>
    <LogicalModel name="logical" subType="">
      <Model class="Models" type="Code">poly</Model>
      <Model class="Models" type="Code">exp</Model>
      <ControlFunction class="Functions" type="External">control</ControlFunction>
    </LogicalModel>
    
    <ExternalModel ModuleToLoad="steadyState" name="steadyState" subType="">
      <inputs>x</inputs>
      <outputs>y</outputs>
    </ExternalModel>
    
    <EnsembleModel name="ExternalModelAndLogical" subType="">
      <Model class="Models" type="LogicalModel">
          logical
        <Input class="Files" type="">gen.one</Input>
        <Input class="Files" type="">gen.two</Input>
        <TargetEvaluation class="DataObjects" type="PointSet">samplesLogical</TargetEvaluation>
      </Model>
      <Model class="Models" type="ExternalModel">
          steadyState
        <Input class="DataObjects" type="PointSet">inputHolder</Input>
        <TargetEvaluation class="DataObjects" type="PointSet">samplesSteadyState</TargetEvaluation>
      </Model>
    </EnsembleModel>
    
    
  </Models>

  <Distributions>
    <Uniform name="xd">
      <lowerBound>0.0</lowerBound>
      <upperBound>1.0</upperBound>
    </Uniform>
  </Distributions>

  <Samplers>
    <Stratified name="LHS">
      <variable name="x">
        <distribution>xd</distribution>
        <grid construction="equal" steps="15" type="CDF">0.3 0.9</grid>
      </variable>
    </Stratified>
  </Samplers>

  <Steps>
    <MultiRun name="logicalAndExtModel">
      <Input class="Files" type="">gen.one</Input>
      <Input class="Files" type="">gen.two</Input>
      <Input class="DataObjects" type="PointSet">inputHolder</Input>

      <Model class="Models" type="EnsembleModel">ExternalModelAndLogical</Model>
      <Sampler class="Samplers" type="Stratified">LHS</Sampler>
      
      <Output class="DataObjects" type="PointSet">finalResults</Output>
      <Output class="DataObjects" type="PointSet">samplesLogical</Output>
      <Output class="OutStreams" type="Print">samplesLogical</Output>
      <Output class="DataObjects" type="PointSet">samplesSteadyState</Output>
      <Output class="OutStreams" type="Print">samplesSteadyState</Output>
    </MultiRun>
  </Steps>

  <DataObjects>
    <PointSet name="inputHolder"/>
      
    <PointSet name="samplesSteadyState">
      <Input>x</Input>
      <Output>y</Output>
    </PointSet>
    <PointSet name="samplesLogical">
      <Input>x,y</Input>
      <Output>poly</Output>
    </PointSet>
    
    <PointSet name="finalResults">
      <Input>x,y</Input>
      <Output>poly</Output>
    </PointSet>
  </DataObjects>

  <OutStreams>
    <Print name="samplesLogical">
      <type>csv</type>
      <source>samplesLogical</source>
      <what>input, output</what>
    </Print>
    <Print name="samplesSteadyState">
      <type>csv</type>
      <source>samplesSteadyState</source>
      <what>input, output</what>
    </Print>
  </OutStreams>

</Simulation>

ExternalModel example (to use in the input):

import numpy as np
from scipy.integrate import odeint
import copy
import time

def run(raven, Input):
  raven.y = raven.x + 1.0

Expected Behavior

Either error out or ability to use it

Screenshots and Input Files

No response

OS

Linux

OS Version

No response

Dependency Manager

PIP

For Change Control Board: Issue Review

  • Is it tagged with a type: defect or task?
  • Is it tagged with a priority: critical, normal or minor?
  • If it will impact requirements or requirements tests, is it tagged with requirements?
  • If it is a defect, can it cause wrong results for users? If so an email needs to be sent to the users.
  • Is a rationale provided? (Such as explaining why the improvement is needed or why current code is wrong.)

For Change Control Board: Issue Closure

  • If the issue is a defect, is the defect fixed?
  • If the issue is a defect, is the defect tested for in the regression test system? (If not explain why not.)
  • If the issue can impact users, has an email to the users group been written (the email should specify if the defect impacts stable or master)?
  • If the issue is a defect, does it impact the latest release branch? If yes, is there any issue tagged with release (create if needed)?
  • If the issue is being closed without a pull request, has an explanation of why it is being closed been provided?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant