diff --git a/BO_hackaton_example.py b/BO_hackaton_example.py new file mode 100644 index 0000000..0e6dca8 --- /dev/null +++ b/BO_hackaton_example.py @@ -0,0 +1,97 @@ + +from baybe import Campaign +from baybe.objective import Objective +from baybe.parameters import NumericalDiscreteParameter, SubstanceParameter +from baybe.searchspace import SearchSpace +from baybe.targets import NumericalTarget +from baybe.utils.dataframe import add_fake_results + + + +### Setup + +# defining ranges of volumes v_i for each precursor +NUM_PRECURSORS = 6 + +parameters = [ + NumericalContinuousParameter( + name=f"v_{k+1}", + bounds=(0, 60), + ) + for k in range(NUM_PRECURSORS) +] + +# defining the constraint that the sum of all volumes wont exceed 60uL + +constraints = [ContinuousLinearEqualityConstraint( + parameters= [f"v_{k+1}" for k in range(NUM_PRECURSORS)], coefficients=[1.0 for k in range(NUM_PRECURSORS)], rhs=60.0 + )] + + +searchspace = SearchSpace.from_product(parameters=parameters, constraints=constraints) + + +### Defining the targets + +Target_1 = NumericalTarget( + name="G1", mode="MATCH", bounds=(900, 1100), transformation="LINEAR" +) +Target_2 = NumericalTarget( + name="G2", mode="MATCH", bounds=(400, 600), transformation="LINEAR" +) + +Target_3 = NumericalTarget( + name="relaxation_time", mode=TargetMode.MAX, +) + +# Note that the `MATCH` mode seeks to have the target at the mean between the two bounds. +# For example, choosing 95 and 105 will lead the algorithm seeking 100 as the optimal value. +# Thus, using the bounds, it is possible to control both the match target and +# the range around this target that is considered viable. + + +### Creating the objective + +# Now to work with these three targets the objective object must be properly created. +# The mode is set to `DESIRABILITY` and the targets are described in a list. + +targets = [Target_1, Target_2, Target_3] + +objective = Objective( + mode="DESIRABILITY", + targets=targets, + combine_func="MEAN", +) + +### Construct the campaign and run some iterations +campaign = Campaign( + searchspace=searchspace, + objective=objective, +) + + +### Load the existing data + +#data = pd.read_csv("./data.csv") +#campaign.add_measurements(data) + +### Generation of recommendations +batch_size=96 +rec = campaign.recommend(batch_size = batch_size) + + +### Example with fake data +N_ITERATIONS = 3 +for kIter in range(N_ITERATIONS): + print(f"\n\n#### ITERATION {kIter+1} ####") + + rec = campaign.recommend(batch_size = batch_size) + print("\nRecommended measurements:\n", rec) + + add_fake_results(rec, campaign) + print("\nRecommended measurements with fake measured results:\n", rec) + + campaign.add_measurements(rec) + + print("\n\nInternal measurement dataframe computational representation Y:\n") + print(campaign._measurements_targets_comp) \ No newline at end of file diff --git a/PROJECT_POSTER.png b/PROJECT_POSTER.png new file mode 100644 index 0000000..9daef1f Binary files /dev/null and b/PROJECT_POSTER.png differ diff --git a/Presentation_PDF.pdf b/Presentation_PDF.pdf new file mode 100644 index 0000000..e12648d Binary files /dev/null and b/Presentation_PDF.pdf differ diff --git a/README.md b/README.md index 988a477..817fb4e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,22 @@ -# +[![Open in Codespaces](https://classroom.github.com/assets/launch-codespace-7f7980b617ed060a017424585567c406b6ee15c891e84e1186181d67ecf80aa0.svg)](https://classroom.github.com/open-in-codespaces?assignment_repo_id=14512004) +# Project Optimystics - +Closed loop optimization of hydrogel formulations using dynamic light scattering ## Overview - +Hydrogels are hydrophilic crosslinked polymer networks with applications in cell cultures, drug delivery, and tissue engineering. Hydrogels' mechanical and rheological properties depend on the application and are a function of the hydrogel formulation, which consists of water, polymer, crosslinking agents, and other additives – which firmly control gelation. The convoluted interplay between the input parameters severely limits the ability to synthesise hydrogels with desired properties. Thus, a self-driving lab with machine-learning-assisted optimisation of the input parameters could optimise the gel formulation to synthesise gels with properties customised for specific applications. Unfortunately, the automated processing of soft, fragile hydrogels is challenging and further established gelation monitoring techniques are data-intensive and often unreliable. Herein, we propose using high-throughput compatible dynamic light scattering (DLS) to monitor gelation. The concentrations of various components and the crosslinking parameters can be varied using Bayesian optimisation to ‘discover’ the hydrogel formulations with the target mechanical and rheological properties using DLS. + +## Youtube Video +https://youtu.be/Qbvq7uolQr8?si=ywHLhoCG1i3bCDJO + +## Other Files +Video Script.docx - Script for the youtube video
+PROJECT_POSTER.png - Poster for the project
+hydrogel background.docx - Background research
+BO_hackathon_example.py - Example code for integration
+Presentation_PDF.pdf - The presentation slides (plus some extra) for the video + ## Setup command diff --git a/Video Script.docx b/Video Script.docx new file mode 100644 index 0000000..0fb4c26 Binary files /dev/null and b/Video Script.docx differ diff --git a/hydrogel background.docx b/hydrogel background.docx new file mode 100644 index 0000000..0c78994 Binary files /dev/null and b/hydrogel background.docx differ