Skip to content

Conversation

@javdrher
Copy link
Member

This modification to acquisition automatically delays _optimize_models and setup() until it is required for proper functionality. A decorator is provided to mark methods which should trigger the setup.

Not everything I was planning for this has already been added, but it offers some insight in what is going on. I was in doubt between a single _needs_setup to be looked after in the highest parent, or doing this on the level of each acquisition. The latter could be used to be slightly more efficient I think, but on my local copy I noticed it increases the code complexity a lot as nearly all methods were changing the status of the _needs_setup flags in the tree. The current setup is slightly simple.

The setup decorator is a class although I was aiming for a function. Unfortunately, there is some incompatibility with the AutoFlow decorator there, I'm still investigating.

@codecov-io
Copy link

codecov-io commented Aug 15, 2017

Codecov Report

Merging #68 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #68      +/-   ##
==========================================
+ Coverage   99.79%   99.79%   +<.01%     
==========================================
  Files          17       17              
  Lines         960      994      +34     
==========================================
+ Hits          958      992      +34     
  Misses          2        2
Impacted Files Coverage Δ
GPflowOpt/acquisition/hvpoi.py 100% <100%> (ø) ⬆️
GPflowOpt/scaling.py 100% <100%> (ø) ⬆️
GPflowOpt/acquisition/acquisition.py 100% <100%> (ø) ⬆️
GPflowOpt/acquisition/poi.py 100% <100%> (ø) ⬆️
GPflowOpt/bo.py 98.66% <100%> (+0.11%) ⬆️
GPflowOpt/transforms.py 100% <100%> (ø) ⬆️
GPflowOpt/acquisition/ei.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e09c78c...8b18be2. Read the comment docs.

@icouckuy icouckuy self-requested a review August 15, 2017 13:47
@icouckuy icouckuy added this to the 0.1.0 release milestone Aug 15, 2017
@javdrher
Copy link
Member Author

Solved the incompatibility, think I covered all aspects now.

# 2 - setup
# Avoid infinite loops, caused by setup() somehow invoking the evaluate on another acquisition
# e.g. through feasible_data_index.
hp._needs_setup = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be directly at the beginning of the if-clause for clarity. make sense imo

assert (optimize_restarts >= 0)
self.optimize_restarts = optimize_restarts
self._optimize_models()
self._needs_setup = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be highest_parent._needs_setup?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this happens in the constructor, under this setting highest_parent == self because its not in a hierarchy yet.

for oper in self.operands:
oper.setup()
if oper.constraint_indices().size == 0:
oper._setup_objectives() if isinstance(oper, AcquisitionAggregation) else oper.setup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no constraint idx at this level, there wont be any lower in the tree?

Perhaps it is more proper to have setup() defined in Acquisition (like below: calling constraints then objectives setup) and _setup_objectives and _setup_constraints defined as empty by default, to be overrided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would make the interface for implementing acquisition functions loaded with complexity which is only relevant to the internal functioning.

if oper.constraint_indices().size == 0:
oper._setup_objectives() if isinstance(oper, AcquisitionAggregation) else oper.setup()

def setup(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this could be in Acquisition? not overridable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, of course with separate setups no information can be easily changed between setup_constraints and setup_objectives.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we discussed this offline and I'm getting rid of the isinstance() calls

num_objectives = self.data[1].shape[1]
assert num_objectives > 1

# Keep pareto empty for now - its updated in setup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's

@javdrher javdrher mentioned this pull request Aug 22, 2017
Added missing NotImplementedError for assign method
@javdrher javdrher merged commit 6354112 into master Aug 23, 2017
@icouckuy icouckuy deleted the lazy_setup branch September 4, 2018 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants