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

Release v0.5.0 #107

Merged
merged 81 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
38fb71f
Add hypervolume visualization
hrntsm Aug 5, 2022
40f5569
Update CHANGELOG
hrntsm Aug 5, 2022
ef81f03
Merge pull request #74 from hrntsm/feature/hypervolume-plot
hrntsm Aug 5, 2022
a16444f
Add BoTorch sampler
hrntsm Aug 5, 2022
a595de3
Update requirements.txt
hrntsm Aug 5, 2022
70abe4e
Update CHANGELOG
hrntsm Aug 5, 2022
608e292
Merge pull request #76 from hrntsm/feature/add-botorch-sampler
hrntsm Aug 7, 2022
db564e9
Update to use genepool nickname
hrntsm Aug 7, 2022
aa77abf
Update CHANGELOG
hrntsm Aug 7, 2022
50706af
Merge pull request #78 from hrntsm/fix/use-genepool-nickname
hrntsm Aug 7, 2022
da47195
Add Variable class to epsilon
hrntsm Aug 7, 2022
e947c95
Update suggestion to use discrete_uniform and int
hrntsm Aug 7, 2022
4971ea2
Update CHANGELOG
hrntsm Aug 7, 2022
3c74cdd
Merge pull request #80 from hrntsm/feature/support-handle-integer-sug…
hrntsm Aug 7, 2022
36cbedc
Fix python installer launch detection
hrntsm Aug 7, 2022
a1a9965
Merge pull request #83 from hrntsm/Fix/pythonInstaller-launch-everytime
hrntsm Aug 7, 2022
42fced9
Fix change study name error
hrntsm Aug 7, 2022
91d3d4a
Update CHANGELOG
hrntsm Aug 7, 2022
c57de76
Merge pull request #84 from hrntsm/Fix/change-studyname-error
hrntsm Aug 7, 2022
bccc857
Add QMC sampler
hrntsm Aug 8, 2022
f7eccff
Fix null brep handle error
hrntsm Aug 8, 2022
f887f3e
Update requirements.txt
hrntsm Aug 8, 2022
a653a53
Update MO support sampler
hrntsm Aug 8, 2022
3fa84a1
Update CHANGELOG
hrntsm Aug 8, 2022
da5a5b9
Merge pull request #85 from hrntsm/feature/update-optuna-300b1
hrntsm Aug 8, 2022
d269622
Add constraint support
hrntsm Aug 8, 2022
8a53b06
Add constructFishAttr to have constraint input
hrntsm Aug 8, 2022
f54e5cc
Add message when constraint is not supported
hrntsm Aug 8, 2022
fd68217
Update CHANGELOG
hrntsm Aug 8, 2022
e46d64b
Clean code
hrntsm Aug 9, 2022
dbf01fd
Update python packages licenses
hrntsm Aug 9, 2022
c35ac77
Merge pull request #87 from hrntsm/feature/constraints
hrntsm Aug 9, 2022
7d62a92
Add setting tabcontrol
hrntsm Aug 18, 2022
e008c39
Add sampler setting ui value initialize
hrntsm Aug 19, 2022
9dee9d6
Add sampler setting getter
hrntsm Aug 19, 2022
2f1f450
Fix constraint wrong description
hrntsm Aug 19, 2022
0b7376b
Add default value button
hrntsm Aug 19, 2022
e5d1b62
Update CHANGELOG
hrntsm Aug 19, 2022
1409c4c
Merge pull request #91 from hrntsm/feature/settings-ui
hrntsm Aug 19, 2022
1a7b652
Fix tooltip typo
hrntsm Aug 20, 2022
76b4323
Fix pareto front too long attr disp
hrntsm Aug 20, 2022
11e6ac7
Merge pull request #93 from hrntsm/Fix/pareto-front-attr
hrntsm Aug 20, 2022
610d9ec
Fix constraint input to item input
hrntsm Aug 21, 2022
df57c5f
Fix result constraint serialize error
hrntsm Aug 21, 2022
fee0572
Add TextBake
hrntsm Aug 21, 2022
be99d71
Update CHANGELOG
hrntsm Aug 21, 2022
65a98a7
Merge pull request #95 from hrntsm/feature/bake-txt-in-fishmarket
hrntsm Aug 21, 2022
29a4d17
Fix load constraint value error
hrntsm Aug 21, 2022
03d8eb3
Fix FishMarket to use text jestify
hrntsm Aug 22, 2022
9ecb997
Clean code
hrntsm Aug 22, 2022
91f0790
Add kmeans plot ui
hrntsm Aug 24, 2022
42a60b0
Update clustering to handle result with constraint
hrntsm Aug 25, 2022
e6427a7
Add save cluster number
hrntsm Aug 25, 2022
d5cca47
Update CHANGELOG
hrntsm Aug 25, 2022
82e4613
Add error msg when clustering single obj opt
hrntsm Aug 25, 2022
463366f
Fix output model number bug
hrntsm Aug 26, 2022
a729d95
Fix code climate issue
hrntsm Aug 29, 2022
4dc4352
Clean hypervolume code
hrntsm Aug 30, 2022
b20c529
Merge pull request #100 from hrntsm/feature/k-means
hrntsm Aug 30, 2022
03c682c
Add consider feasible output
hrntsm Aug 30, 2022
816b3ce
Update CHANGELOG
hrntsm Aug 30, 2022
86c23d0
Merge pull request #101 from hrntsm/feature/support-consider-feasible…
hrntsm Aug 30, 2022
eb29909
Clean CheckFeasible method
hrntsm Aug 31, 2022
4d351b7
Update optuna package
hrntsm Aug 31, 2022
9684d2c
Update trial.suggest to float
hrntsm Aug 31, 2022
57af65c
Update TPE multivariate option to true in default
hrntsm Aug 31, 2022
ffb42ee
Add nsga to crossover option
hrntsm Aug 31, 2022
87a6f9d
Add cma-es popsize setting
hrntsm Aug 31, 2022
2126f1d
Fix typo
hrntsm Aug 31, 2022
78e3bbf
Fix empty crossover input
hrntsm Aug 31, 2022
73c0ff9
Update CHANGELOG
hrntsm Aug 31, 2022
f6d3e4f
Merge pull request #103 from hrntsm/feature/update-optuna-v3
hrntsm Aug 31, 2022
16467f6
Add run gc after trial setting
hrntsm Sep 1, 2022
a3e17aa
Update CHANGELOG
hrntsm Sep 1, 2022
a530ca9
Merge pull request #105 from hrntsm/feature/run-gc-after-trial
hrntsm Sep 1, 2022
646b77e
Add license button
hrntsm Sep 3, 2022
514d48f
Update CHANGELOG
hrntsm Sep 3, 2022
b433a84
Merge pull request #106 from hrntsm/featura/add-license-button
hrntsm Sep 3, 2022
d004ca7
Fix incorrect model number input error
hrntsm Sep 3, 2022
98ca157
Update sample.gh
hrntsm Sep 3, 2022
8a9d308
Update README
hrntsm Sep 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,47 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

Please see [here](https://github.com/hrntsm/Tunny/releases) for the data released for each version.

## [0.5.0] -2022-09-03

### Added

- Hypervolume visualization
- It is useful for determining convergence in multi-objective optimization.
- Clustering visualization
- Clustering of results during multi-objective optimization makes it easier to evaluate solutions.
- BoTorch Sampler
- This sampler use Gaussian Process and support multi-objective optimization.
- Quasi-MonteCarlo Sampler
- [Detail](https://optuna.readthedocs.io/en/latest/reference/samplers/generated/optuna.samplers.QMCSampler.html) about this sampler.
- Support Constraint.
- Only TPE, GP, NSGAII can use constraint.
- Sampler detail settings UI
- Previously it was necessary to change the JSON file of the settings, but now it can be changed in the UI
- Enable Text Bake in the FishMarket component.
- Allows selection of NSGA-II crossover methods.
- `Uniform`, `BLXAlpha`, `SPX`, `SBX`, `VSBX`, `UNDX`
- Ability to set Popsize on CMA-ES restart
- Run GC after trial when has geometry attribute or setting always run.
- **This change probably make optimize slower before**
- If you want to cut this setting, set the value of "GcAfterTrial" to 2 in Settings.json.
- Show LICENSE button in Tunny UI.

### Changed

- When genepool is an input, it now creates variable names using nicknames.
- The output of the Pareto solution was made to consider the constraints.
- Multivariate in TPE sampler default option is false to true
- Updated Optuna used to v3.0.0
- Use `suggest_int` and `suggest_float` instead of `suggest_uniform` for more accurate variable generation in optimization
- Random and Grid samplers now support multi-objective optimization
- The format of the db file in which the results are saved has changed. Please note that it is not compatible with the previous one.

### Fixed

- The PythonInstaller window now has no text on the progress bar.
- When more than one Study exists, another Study Name is set and RunOpt no longer causes a Solver Error.
- The error does not occur when the Brep of Geometry of Attribute is null.

## [0.4.0] -2022-07-09

### Added
Expand Down Expand Up @@ -54,7 +95,7 @@ Please see [here](https://github.com/hrntsm/Tunny/releases) for the data release

- Use json to set sampler detail settings
- Since the settings are saved in Json, the previous values set in the UI remain saved when the window is closed and reopened.
- UI for above detail settings
- UI for above detail settings
- If input "-10" in restore model number, Tunny output all result
- Fish component
- Special GH_Param component for Tunny result to handle its result easier.
Expand Down
5,409 changes: 3,278 additions & 2,131 deletions PYTHON_PACKAGE_LICENSES

Large diffs are not rendered by default.

85 changes: 43 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Please see PYTHON_PACKAGE_LICENSE for more license information.

https://user-images.githubusercontent.com/23289252/178105107-5e9dd9f7-5680-40d4-97b0-840a4f1f329c.mp4

### :fish_cake: Select sampler flow chart

<img width="75%" alt="image" src="https://user-images.githubusercontent.com/23289252/188254450-1e718d97-f81e-49a1-949b-e158837bc44f.png">

### :anchor: Component location

Tunny can be found in the Tunny tab if it has been installed.
Expand Down Expand Up @@ -103,7 +107,10 @@ The nickname of the ConstructFishAttribute component input is stored paired with

The Geometry input has a special meaning; what is entered here will be displayed as a Geometry when the results are sorted in the FishMarket component described below.

<img width="40%" src="https://user-images.githubusercontent.com/23289252/178102569-16b64446-1a67-4eb6-80fa-a4c846c4b294.png">
Constraint inputs are also special inputs.**(new in v0.5.0)** The values entered here are the constraints in the optimization.
When this value is less than 0, the constraint is considered satisfied. Constraint conditions are supported by TPE, GP and NSGAII.

<img width="60%" alt="image" src="https://user-images.githubusercontent.com/23289252/188254609-3c8432ba-3f1c-45f4-bd2a-9e3f08271c2b.png">

### :octopus: Other components

Expand All @@ -128,24 +135,26 @@ On the other hand, it is possible to save the learning status, and even after th
On the other hand, Running the Dashboard function, which charts the results, starts a server that handles the results and allows you to see the optimization results in real time in your browser.
This feature is useful for analyzing post-optimization results, as it allows the user to not only see the results in real time, but also to view several figures at once.

It is recommended that optimization be performed a small number of times, and after completion, the results should be reviewed to determine if continued optimization should be performed.

#### :sailboat: Optimize Tab

<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/178103175-02ade5f2-fa3e-4f34-9757-1b944d699785.png">
<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/188254704-533139c7-169a-4aee-bcd5-0e98ff45f35e.png">

Values that can be set and their meanings are as follows.

- Sampler
- Sets the algorithm to perform the optimization. The following types are available.
- All are optimization algorithms provided by Optuna.
1. TPE (Bayesian optimization)
1. NSGA-II (Genetic algorithm)
1. CMA-ES (Evolution strategy)
1. Random
1. Grid
1. Bayesian optimization(TPE)
2. Bayesian optimization(GP) **(new in v0.5.0)**
3. Genetic algorithm(NSGA-II)
4. Evolution strategy(CMA-ES)
5. Quasi-MonteCarlo **(new in v0.5.0)**
6. Random
7. Grid
- Number of trial
- This number of trials will be performed.
- Bayesian optimization first performs random sampling to create a surrogate model. This is the setting for how many trials random sampling is performed.
- The original paper recommends “number of variables” \* 11-1.
- If the grid sampler is selected, the calculation is performed by dividing each entered Variable by this number.
- **Note** that the number of calculations is (Number of trial) to the power of (Number of Variable).
- Timeout(sec)
Expand All @@ -163,7 +172,7 @@ Values that can be set and their meanings are as follows.

#### :boat: Visualize Tab

<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/178103288-6e7bc0fe-f730-4e23-8159-6d43df55f1ae.png">
<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/188255757-8532948f-b784-45b7-b116-17ba79db9536.png">

Values that can be set and their meanings are as follows.

Expand All @@ -181,12 +190,15 @@ Values that can be set and their meanings are as follows.
6. param importance
7. pareto front
8. slice
- Show selected type of plots
- Show the plot selected in Visualize type above.
9. hypervolume **(new in v0.5.0)**
- Show selected type of plots
- Show the plot selected in Visualize type above.
- k-means clustering
- Cluster the results of the Pareto front when performing multi-objective optimization.Any number of clusters can be specified.

#### :fishing_pole_and_fish: Output Tab

<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/178103410-e2a589b2-ffd0-436e-b4b1-2deb4e7346ba.png">
<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/188255933-62df2324-29b0-40e2-9568-6b825ed147dd.png">

Values that can be set and their meanings are as follows.

Expand All @@ -197,11 +209,8 @@ Values that can be set and their meanings are as follows.
- All trials
- Output all trials.
- Use model number

- Multiple values can be entered separated by commas, such as "1,3,42".

- Output

- The model with the number entered here is restored from the optimization results file and is the output of the component.
- The model number can be found on each plot.
- In the example below, model number 424 with a value of -11.49 for the first objective function is selected.
Expand All @@ -213,36 +222,28 @@ Values that can be set and their meanings are as follows.

#### :droplet: Settings Tab

<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/178103758-3ca8fa88-4796-4b0c-8c17-f8a810a47caf.png">

Tunny stores the optimize settings in json.
Detailed settings in optimization can now also be configured in Json.

- **IMPORTANT**: The default hyperparameter for each optimization contain Optuna defaults.
- These are not necessarily the best values for your optimization.
- Pay particular attention to the initial population or trial.
- the recommended initial trial for TPE is "the number of Variable" x 11 - 1.
- Open API page
- Open Optuna's API page with the meaning of each value in the advanced optimization settings.
- Save settings to json
- Save the settings to Json.
- Settings are also saved when the window is closed with the X button.
- Load settings from json
- Loads a settings file.
- Open Settings.Json folder
- Open the folder where the settings files are stored.
- The file Settings.json is Tunny's settings file. Edit it with any text editor.
<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/188255969-9355c626-36d3-4d9b-8f50-0a8bda79bf8e.png">

**(new in v0.5.0)**
Allows detailed optimization settings to be performed in the UI.
See below for the meaning of each setting.

[Guideline for selecting optimization algorithms](https://graceful-stag-dae.notion.site/Guidelines-for-Selecting-a-Optimization-Algorithm-8505b2e020ee4af2a77272f25acc6094)

#### :turtle: File Tab

<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/178103993-d4448d03-5aef-45bd-a8a0-497a0cf417a4.png">
<img width="30%" alt="image" src="https://user-images.githubusercontent.com/23289252/188256059-82679c52-4909-4e29-a9ad-36b3bab5c577.png">

- Result
- Open result file folder
- Open the folder where the file containing the optimization results is located.
- Results are saved as "Tunny_Opt_Result.db" by default.
- This can be made to be anything you want by rewriting the Setting.json file.
- Clear result file
- Deletes the optimization result file.
- License **(new in v0.5.0)**
- You can check license to push each button.

- Open result file folder
- Open the folder where the file containing the optimization results is located.
- Results are saved as "Tunny_Opt_Result.db" by default.
- This can be made to be anything you want by rewriting the Setting.json file.
- Clear result file
- Deletes the optimization result file.

## :surfer: Contact information

Expand Down
Binary file modified Samples/sample.gh
Binary file not shown.
59 changes: 47 additions & 12 deletions Tunny/Component/ConstructFishAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace Tunny.Component
{
public class ConstructFishAttribute : GH_Component, IGH_VariableParameterComponent
{
private readonly string _geomDescription = "Connect model geometries here. Not required. Large size models are not recommended as it affects the speed of analysis.\"Geometry\" is a special nickname that is visualized with the optimization results. Do not change it.";
private readonly string _geomDescription = "Connect model geometries here. Not required. Large size models are not recommended as it affects the speed of analysis.";
private readonly string _constraintDescription = "A value strictly larger than 0 means that a constraints is violated. A value equal to or smaller than 0 is considered feasible. ";
private readonly string _attrDescription = "Attributes to each trial. Attribute name will be the nickname of the input, so change it to any value.";
public override GH_Exposure Exposure => GH_Exposure.secondary;

Expand All @@ -26,11 +27,13 @@ public ConstructFishAttribute()
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "Geometry", _geomDescription, GH_ParamAccess.list);
pManager.AddNumberParameter("Constraint", "Constraint", _constraintDescription, GH_ParamAccess.item);
pManager.AddGenericParameter("Attr1", "Attr1", _attrDescription, GH_ParamAccess.list);
pManager.AddGenericParameter("Attr2", "Attr2", _attrDescription, GH_ParamAccess.list);
Params.Input[0].Optional = true;
Params.Input[1].Optional = true;
Params.Input[2].Optional = true;
Params.Input[3].Optional = true;
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
Expand All @@ -49,18 +52,33 @@ protected override void SolveInstance(IGH_DataAccess DA)
return;
}

GetInputData(DA, paramCount, dict);
DA.SetData(0, dict);
}

private void GetInputData(IGH_DataAccess DA, int paramCount, Dictionary<string, object> dict)
{
for (int i = 0; i < paramCount; i++)
{
var list = new List<object>();
if (!DA.GetDataList(i, list))
string key = Params.Input[i].NickName;
if (i == 1)
{
continue;
double constraint = 0;
if (DA.GetData(i, ref constraint))
{
dict.Add(key, constraint);
}
}
else
{
var list = new List<object>();
if (!DA.GetDataList(i, list))
{
continue;
}
dict.Add(key, list);
}
string key = Params.Input[i].NickName;
dict.Add(key, list);
}

DA.SetData(0, dict);
}

//FIXME: Should be modified to capture and check for change events.
Expand All @@ -79,13 +97,19 @@ private bool CheckIsNicknameDuplicated()
return false;
}

public bool CanInsertParameter(GH_ParameterSide side, int index) => side != GH_ParameterSide.Output && (Params.Input.Count == 0 || index != 0);
public bool CanInsertParameter(GH_ParameterSide side, int index) => side != GH_ParameterSide.Output && (Params.Input.Count == 0 || index >= 2);

public bool CanRemoveParameter(GH_ParameterSide side, int index) => side != GH_ParameterSide.Output && index != 0;
public bool CanRemoveParameter(GH_ParameterSide side, int index) => side != GH_ParameterSide.Output && index >= 2;

public IGH_Param CreateParameter(GH_ParameterSide side, int index)
{
return side == GH_ParameterSide.Input ? index == 0 ? SetGeometryParameterInput() : SetGenericParameterInput(index) : null;
return side == GH_ParameterSide.Input
? index == 0
? SetGeometryParameterInput()
: index == 1
? SetNumberParameterInput()
: SetGenericParameterInput(index)
: null;
}

private IGH_Param SetGenericParameterInput(int index)
Expand All @@ -98,12 +122,23 @@ private IGH_Param SetGenericParameterInput(int index)
return p;
}

private IGH_Param SetNumberParameterInput()
{
var p = new Param_Number();
p.Name = p.NickName = $"Constraint";
p.Description = _constraintDescription;
p.Access = GH_ParamAccess.list;
p.MutableNickName = false;
p.Optional = true;
return p;
}

private IGH_Param SetGeometryParameterInput()
{
var p = new Param_Geometry();
p.Name = p.NickName = "Geometry";
p.Description = _geomDescription;
p.Access = GH_ParamAccess.list;
p.Access = GH_ParamAccess.item;
p.MutableNickName = false;
p.Optional = true;
return p;
Expand Down
27 changes: 27 additions & 0 deletions Tunny/Component/FishMarket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;

using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using Rhino;
using Rhino.Display;
using Rhino.Geometry;

Expand Down Expand Up @@ -171,6 +173,31 @@ public override void DrawViewportWires(IGH_PreviewArgs args)
}
}

public override void BakeGeometry(RhinoDoc doc, List<Guid> obj_ids)
{
base.BakeGeometry(doc, obj_ids);

for (int i = 0; i < _fishes.Count; i++)
{
doc.Objects.AddText(_fishes[i].ToString(), _tagPlanes[i], _size, "Meiryo", false, false, TextJustification.TopLeft);
}
}

public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
base.AppendAdditionalMenuItems(menu);
ToolStripMenuItem item = Menu_AppendItem(menu, "Bake with Text", BakeGeometryFromMenu);
item.ToolTipText = "Bake not only geometry, but also result texts.";
}

private void BakeGeometryFromMenu(object sender, EventArgs e)
{
RhinoDoc doc = RhinoDoc.ActiveDoc;
var objIds = new List<Guid>();
BakeGeometry(doc, objIds);
doc.Views.Redraw();
}

protected override Bitmap Icon => Resource.FishMarket;
public override Guid ComponentGuid => new Guid("46E05DFF-8EFD-418A-AC5B-7C9F24559B2E");

Expand Down
Loading