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.11.1 #290

Merged
merged 18 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test-and-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: test and coverage
on: [pull_request]

jobs:
build:
test:
runs-on: windows-latest

steps:
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ 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.

## [v0.11.1] -2024-05-10

### Added

- Ignore duplicate sampling setting

### Changed

- Bump optuna library
- optuna 3.6.0 => 3.6.1
- optuna-dashboard 0.15.0 => 0.15.1

### Fixed

- SolutionExpire timing was wrong when using ValueList.
- FishAttribute component "Attr" input index off by one error.

## [v0.11.0] -2024-03-20

### Added
Expand Down
Binary file modified Examples/Grasshopper/Human-in-the-loop/facade.gh
Binary file not shown.
Binary file modified Examples/Grasshopper/categorical_optimization.gh
Binary file not shown.
1 change: 1 addition & 0 deletions Optuna/Optuna.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Version>0.11.1</Version>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest-recommended</AnalysisLevel>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions PYTHON_PACKAGE_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ summary
| networkx | 3.2.1 | BSD License |
| numpy | 1.26.0 | BSD License |
| opt-einsum | 3.3.0 | MIT |
| optuna | 3.6.0 | MIT License |
| optuna-dashboard | 0.15.0 | MIT License |
| optuna | 3.6.1 | MIT License |
| optuna-dashboard | 0.15.1 | MIT License |
| packaging | 23.1 | Apache Software License; BSD License |
| pip | 23.2.1 | MIT License |
| plotly | 5.16.1 | MIT License |
Expand Down
1 change: 1 addition & 0 deletions Tunny.Core/Handler/ProgressState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class ProgressState
public double[][] BestValues { get; set; }
public double HypervolumeRatio { get; set; }
public TimeSpan EstimatedTimeRemaining { get; set; }
public bool IsReportOnly { get; set; }
}
}
1 change: 1 addition & 0 deletions Tunny.Core/Settings/Optimize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class Optimize
public double Timeout { get; set; }
public GcAfterTrial GcAfterTrial { get; set; } = GcAfterTrial.HasGeometry;
public bool ShowRealtimeResult { get; set; }
public bool IgnoreDuplicateSampling { get; set; }
}
}
2 changes: 1 addition & 1 deletion Tunny.Core/Tunny.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Version>0.11.0</Version>
<Version>0.11.1</Version>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest-recommended</AnalysisLevel>
</PropertyGroup>
Expand Down
41 changes: 41 additions & 0 deletions Tunny.CoreTests/Handler/ProgressStateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections.Generic;

using Xunit;

namespace Tunny.Core.Handler.Tests
{
public class ProgressStateTests
{
[Fact]
public void ProgressStateCtorTest()
{
var progressState = new ProgressState();
Assert.NotNull(progressState);
}

[Fact]
public void ProgressStatePropertiesTest()
{
var param = new List<Input.Parameter>();
double[][] bests = new double[1][];
var progressState = new ProgressState
{
Parameter = param,
TrialNumber = 0,
ObjectiveNum = 0,
BestValues = bests,
HypervolumeRatio = 0,
EstimatedTimeRemaining = new System.TimeSpan(),
IsReportOnly = false
};

Assert.Equal(param, progressState.Parameter);
Assert.Equal(0, progressState.TrialNumber);
Assert.Equal(0, progressState.ObjectiveNum);
Assert.Equal(bests, progressState.BestValues);
Assert.Equal(0, progressState.HypervolumeRatio);
Assert.Equal(new System.TimeSpan(), progressState.EstimatedTimeRemaining);
Assert.False(progressState.IsReportOnly);
}
}
}
107 changes: 107 additions & 0 deletions Tunny/Component/Input/TunnyValueList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System;
using System.Drawing;

using Grasshopper.GUI.Canvas;
using Grasshopper.Kernel.Special;

namespace Tunny.Component.Util
{
public class TunnyValueList : GH_ValueList
{
public TunnyValueList()
{
Category = "Tunny";
SubCategory = "Input";
Name = "Tunny Value List";
NickName = "<')))<<";
Description = "Value list with Tunny styling";
ListMode = GH_ValueListMode.CheckList;
ListItems.Clear();
ListItems.Add(new GH_ValueListItem("Tuna", "1"));
ListItems.Add(new GH_ValueListItem("Salmon", "2"));
ListItems.Add(new GH_ValueListItem("Cod", "3"));
ListItems.Add(new GH_ValueListItem("Trout", "4"));
}

public override void CreateAttributes()
{
m_attributes = new TunnyValueListAttributes(this);
}

public override Guid ComponentGuid => new Guid("e29b732d-72bc-4734-a520-642bc9b518fb");

public void SelectItemUnsafe(int index)
{
if (index < 0 || index >= ListItems.Count)
{
return;
}

bool flag = false;
int num = ListItems.Count - 1;
for (int i = 0; i <= num; i++)
{
if (i == index)
{
if (!ListItems[i].Selected)
{
flag = true;
break;
}
}
else if (ListItems[i].Selected)
{
flag = true;
break;
}
}

if (flag)
{
RecordUndoEvent("Select: " + ListItems[index].Name);
int num2 = ListItems.Count - 1;
for (int j = 0; j <= num2; j++)
{
ListItems[j].Selected = j == index;
}

ExpireSolution(recompute: false);
}
}
}

internal sealed class TunnyValueListAttributes : GH_ValueListAttributes
{
public TunnyValueListAttributes(GH_ValueList owner) : base(owner)
{
}

protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
{
if (channel == GH_CanvasChannel.Objects)
{
DrawObjects(canvas, graphics, channel);
}
else
{
base.Render(canvas, graphics, channel);
}
}

private void DrawObjects(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
{
var tunnyStyle = new GH_PaletteStyle(Color.CornflowerBlue, Color.DarkBlue, Color.Black);

GH_PaletteStyle normalStyle = GH_Skin.palette_normal_standard;
GH_PaletteStyle warningStyle = GH_Skin.palette_warning_standard;
GH_PaletteStyle hiddenStyle = GH_Skin.palette_hidden_standard;
GH_Skin.palette_normal_standard = tunnyStyle;
GH_Skin.palette_warning_standard = tunnyStyle;
GH_Skin.palette_hidden_standard = tunnyStyle;
base.Render(canvas, graphics, channel);
GH_Skin.palette_normal_standard = normalStyle;
GH_Skin.palette_warning_standard = warningStyle;
GH_Skin.palette_hidden_standard = hiddenStyle;
}
}
}
32 changes: 22 additions & 10 deletions Tunny/Component/Operation/ConstructFishAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,28 @@ private bool CheckIsNicknameDuplicated()

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

private static IGH_Param SetGenericParameterInput(int index)
private static Param_GenericObject SetGenericParameterInput(int index)
{
var p = new Param_GenericObject();
p.Name = p.NickName = $"Attr{index}";
Expand All @@ -125,7 +137,7 @@ private static IGH_Param SetGenericParameterInput(int index)
return p;
}

private static IGH_Param SetNumberParameterInput()
private static Param_Number SetNumberParameterInput()
{
var p = new Param_Number();
p.Name = p.NickName = "Constraint";
Expand All @@ -136,7 +148,7 @@ private static IGH_Param SetNumberParameterInput()
return p;
}

private static IGH_Param SetGeometryParameterInput()
private static Param_Geometry SetGeometryParameterInput()
{
var p = new Param_Geometry();
p.Name = p.NickName = "Geometry";
Expand Down
8 changes: 6 additions & 2 deletions Tunny/Handler/OptimizeLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ private static Parameter[] RunOptimizationLoop(BackgroundWorker worker)
private static TrialGrasshopperItems EvaluateFunction(ProgressState pState, int progress)
{
TLog.MethodStart();
Component.GrasshopperStatus = GrasshopperStates.RequestSent;

s_worker.ReportProgress(progress, pState);
if (pState.IsReportOnly)
{
return null;
}

Component.GrasshopperStatus = GrasshopperStates.RequestSent;
while (Component.GrasshopperStatus != GrasshopperStates.RequestProcessed)
{ /*just wait*/ }

Expand Down
12 changes: 10 additions & 2 deletions Tunny/Input/Objective.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
Expand All @@ -7,8 +8,6 @@
using Grasshopper.Kernel.Parameters;
using Grasshopper.Kernel.Types;

using Python.Runtime;

using Rhino.Geometry;

using Tunny.Component.Params;
Expand All @@ -29,6 +28,15 @@ public class Objective
public int Length => Numbers.Length + Images.Length + (Geometries.Length > 0 ? 1 : 0);
public int NoNumberLength => Images.Length + (Geometries.Length > 0 ? 1 : 0);

public Objective(double[] values)
{
TLog.MethodStart();
Numbers = values;
Images = Array.Empty<Bitmap>();
Geometries = Array.Empty<GeometryBase>();
HumanInTheLoopType = HumanInTheLoopType.None;
}

public Objective(List<IGH_Param> sources)
{
TLog.MethodStart();
Expand Down
8 changes: 4 additions & 4 deletions Tunny/Lib/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fsspec==2023.12.2
gpytorch==1.11.0
greenlet==2.0.2
jaxtyping==0.2.25
Jinja2==3.1.3
Jinja2==3.1.4
joblib==1.3.2
linear-operator==0.5.1
Mako==1.2.4
Expand All @@ -19,9 +19,9 @@ multipledispatch==0.6.0
networkx==3.2.1
numpy==1.26.0
opt-einsum==3.3.0
optuna==3.6.0
optuna==3.6.1
optuna-integration==3.6.0
optuna-dashboard==0.15.0
optuna-dashboard==0.15.1
packaging==23.1
plotly==5.16.1
pyro-api==0.1.2
Expand All @@ -35,6 +35,6 @@ sympy==1.12
tenacity==8.2.3
threadpoolctl==3.2.0
torch==2.1.2
tqdm==4.66.1
tqdm==4.66.3
typeguard==2.13.3
typing_extensions==4.8.0
13 changes: 13 additions & 0 deletions Tunny/PostProcess/TrialGrasshopperItems.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;

using Tunny.Input;
Expand All @@ -10,5 +11,17 @@ public class TrialGrasshopperItems
public string[] GeometryJson { get; set; }
public Dictionary<string, List<string>> Attribute { get; set; }
public Artifact Artifacts { get; set; }

public TrialGrasshopperItems()
{
}

public TrialGrasshopperItems(double[] values)
{
Objectives = new Objective(values);
GeometryJson = Array.Empty<string>();
Attribute = new Dictionary<string, List<string>>();
Artifacts = new Artifact();
}
}
}
Loading
Loading