Xopt icon indicating copy to clipboard operation
Xopt copied to clipboard

Constants not being passed into evaluate with AsynchronousXopt

Open ChristopherMayes opened this issue 1 year ago • 0 comments

The constants are not being passed to evaluate with AsynchronousXopt. Example:

test.py

#from xopt import Xopt # Works
from xopt import AsynchronousXopt as Xopt

def evaluate_function(inputs, kwarg1, kwarg2):
    print(f"{inputs=}")

    assert 'constant1' in inputs
    assert 'constant2' in inputs

    outputs =  {'objective1': 1, 
     'objective2': 1,
     'constraint1':1,
     'constraint2':1}

    return outputs
     
 
YAML = f"""
 
max_evaluations: 10
generator:
  name: random
evaluator:
  function: __main__.evaluate_function
  function_kwargs:
    kwarg1: "test1.in"
    kwarg2: 3
 
vocs:
  variables:
    var1:           [1  ,   2] 
    var2:           [1  ,   2]
  constants:
    constant1: 'mm'
    constant2: 2

  objectives:
    objective1:   MINIMIZE  
    objective2:   MINIMIZE    
 
  constraints:
    constraint1: [GREATER_THAN,          100]
    constraint2: [LESS_THAN,             500]
 
"""
X = Xopt(YAML)

X.run()

Running:

python test.py
inputs={'var1': array([1.29934511]), 'var2': array([1.17955349])}
...
AssertionError

ChristopherMayes avatar Feb 08 '24 19:02 ChristopherMayes