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

Fixed MLT/MST calculation code #21

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
7970c0d
WIP - Finally working MLT implementation (much work still to do)
wbinek Jan 17, 2021
3956df4
Initial source direction randomization [WIP]
wbinek Mar 25, 2021
21dceb2
Add warning about experimental code and its limitations
wbinek Oct 3, 2021
784d070
Add some comentes
wbinek Oct 14, 2021
2338654
Add new MLT parameters
wbinek Oct 14, 2021
811e2ad
Implement most of MLT parameters as variables
wbinek Oct 15, 2021
2f17eae
Rename MLT parameter
wbinek Oct 15, 2021
ab64719
Add rejection sampling and seed choice, fix progress for MLT
wbinek Oct 15, 2021
1d1ddbf
Fix very rare nan in BaseWnReflection probability calculation
wbinek Oct 16, 2021
ff94114
Fix rejection sampling parameter loading
wbinek Oct 16, 2021
7cc7989
Rename some MLT parameters
wbinek Oct 16, 2021
4eece4d
[WIP] Large step sampling
wbinek Oct 16, 2021
2f875e1
Working rejection sampling
wbinek Oct 16, 2021
c8b81f1
Remove large step warning
wbinek Oct 16, 2021
1fa254f
Increment SPPS-AGH verion number to 0.4.0
wbinek Oct 16, 2021
b8cc810
Fix MLT for 0 mutations
wbinek Oct 16, 2021
2e88a17
Increment SPPS-AGH version to 0.4.1
wbinek Oct 16, 2021
4053f31
Add separate variable for enabling seed selection
wbinek Oct 19, 2021
b282fd7
Add mutation generator parameters as input
wbinek Oct 19, 2021
e51dff7
Add initial take on weight decay compensation
wbinek Oct 19, 2021
ac5728a
Change default parameter value
wbinek Oct 19, 2021
8674edd
Fix regression, seed selection without mutations error
wbinek Oct 19, 2021
9733677
Fix very rare NaN in wDC calculation
wbinek Oct 22, 2021
1e1957c
Increment SPPS-AGH version number
wbinek Oct 22, 2021
147f93a
Potential fix for Phong normalization regression
wbinek Oct 22, 2021
b03f0fc
Release memory when seeds are selected
wbinek Oct 23, 2021
a542f17
Remove try catch clause used for debug purposes
wbinek Oct 23, 2021
64c2969
Add propability for default case in dotreflection
wbinek Oct 23, 2021
7eea9f4
Add some additional debug comunicates
wbinek Oct 23, 2021
ac27b61
Include iostream to enable cout for PARTICULE_MLT
wbinek Oct 24, 2021
9447893
Add new parameter - seed selection exponent, disable specular_refl_pr…
wbinek Oct 24, 2021
dd5f598
Fix occasional crash on visability test
wbinek Oct 26, 2021
9dfba91
Don't cast shadow rays with zero energy
wbinek Oct 28, 2021
43cfdd9
Fix rare case when the result is zeros only
wbinek Oct 28, 2021
915da61
Fix occasional crash on visability check - pt.2
wbinek Oct 28, 2021
ddfd08c
Fix info message
wbinek Nov 11, 2021
2bb67e8
Increment version
wbinek Nov 11, 2021
0cdfc3c
Make GenerateShadowRays template to accept both vector and list argument
wbinek Nov 15, 2021
3689a12
Add low memory mode for MLT algorithm
wbinek Nov 15, 2021
4c93b5e
Increment SPPS-AGH version
wbinek Nov 15, 2021
40b6eb2
Add more memory optimizations, increment SPPS-AGH version
wbinek Nov 15, 2021
949e263
MLT cast all initial rays (quality improvement), increment SPPS-AGH v…
wbinek Nov 18, 2021
e058f7c
Disable most MLT settings if no mutations is 0
wbinek Nov 18, 2021
ae5175f
MLT auto enable low memory mode and rejection sampling for 0 mutations
wbinek Nov 18, 2021
fe7775d
Add single value mutation probability parameter
wbinek Nov 23, 2021
6214444
Increment spps-agh version to 0.5.1beta
wbinek Nov 23, 2021
9dc1b3c
Fix export to core settings for MLT
wbinek Nov 23, 2021
c52b742
Change mutationProbability, reflection order dependance
wbinek Nov 23, 2021
8458910
Fix occasional NaNs in LF and LFC calculation
wbinek Jan 7, 2022
b89dd57
Add options to add 10 and 50 calculations to job_tool
wbinek Jan 7, 2022
bedb758
Add mutated particle weight parameter to MLT algorithm
wbinek Jan 8, 2022
84b3200
Increment spps-agh to 0.5.2
wbinek Jan 8, 2022
5950109
Fix for loading materials from CATT acoustics file
wbinek Aug 18, 2022
11821fb
Fixes for energy conservation issues, improved sample weighting
wbinek Apr 20, 2023
9872a21
Increment SPPS to 0.5.3
wbinek Apr 20, 2023
c991e13
Regression, MLT calculation with seed selection disabled
wbinek Apr 20, 2023
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
18 changes: 16 additions & 2 deletions currentRelease/SystemScript/job_tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import operator
import uilocale
import os
import collections
from collections.abc import Sequence

_=uilocale.InstallUiModule(ui.application.getapplicationpath()["systemscript"]+"job_tool"+os.sep,ui.application.getlocale())

Expand Down Expand Up @@ -99,7 +99,7 @@ class JobManager(object):
"""
def appendjob(self,jobname,identifier):
#if operator.isSequenceType(identifier):
if isinstance(identifier,collections.Sequence):
if isinstance(identifier,Sequence):
self.joblst.append(job_types[jobname](identifier))
else:
self.joblst.append(job_types[jobname](jobname,identifier))
Expand All @@ -118,6 +118,16 @@ def AddRun(self,idel):
self.AddOpenProjectIfChanges()
self.appendjob("RUN",idel)
self.appendjob("SAVE_PROJECT",idel)
def AddRun10(self,idel):
self.AddOpenProjectIfChanges()
for i in range(10):
self.appendjob("RUN",idel)
self.appendjob("SAVE_PROJECT",idel)
def AddRun50(self,idel):
self.AddOpenProjectIfChanges()
for i in range(50):
self.appendjob("RUN",idel)
self.appendjob("SAVE_PROJECT",idel)
def ClearJobLst(self,idel):
self.joblst=[]
self.lastprojectpath=""
Expand All @@ -134,12 +144,16 @@ class manager:
def __init__(self):
self.jmanager=JobManager()
self.addcalculation_id=ui.application.register_event(self.jmanager.AddRun)
self.addcalculation10_id=ui.application.register_event(self.jmanager.AddRun10)
self.addcalculation50_id=ui.application.register_event(self.jmanager.AddRun50)
self.clear_jobs_id=ui.application.register_event(self.jmanager.ClearJobLst)
self.execute_jobs_id=ui.application.register_event(self.jmanager.ExecJobs)
self.print_jobs_id=ui.application.register_event(self.jmanager.PrintJobLst)
def getmenu(self,typeel,idel,menu):
submenu=[]
submenu.append((_(u"Add calculation in the job list"),self.addcalculation_id))
submenu.append((_(u"Add 10 calculations to the job list"),self.addcalculation10_id))
submenu.append((_(u"Add 50 calculations to the job list"),self.addcalculation50_id))
submenu.append(())
submenu.append((_(u"Clear job list"),[(_(u"Confirmation"),self.clear_jobs_id)]))
submenu.append((_(u"Run job list"),self.execute_jobs_id))
Expand Down
16 changes: 12 additions & 4 deletions src/isimpa/data_manager/projet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,15 @@ void ProjectManager::RunCoreCalculation(Element* coreCalculation)
return;
}

if (coreCalculation->GetElementInfos().typeElement == Element::ELEMENT_TYPE_CORE_SPPSAGH)
{
E_Core_Core_Configuration* confCore = dynamic_cast<E_Core_Core_Configuration*>(coreCalculation->GetElementByType(Element::ELEMENT_TYPE_CORE_CORE_CONFIG));
int calcCode = confCore->GetListConfig("calculation_core");
if (calcCode == 2) {
wxLogWarning(_("You are using very experimantal MLT calculation code. Many things are not working!\n - only omnidirectional source supported\n - only point receivers supported"));
}
}

if (coreCalculation->GetElementInfos().typeElement != Element::ELEMENT_TYPE_CORE_SPPSAGH)
{
std::vector<Element*> lstMatRow, egroupeSurf;
Expand All @@ -720,7 +729,6 @@ void ProjectManager::RunCoreCalculation(Element* coreCalculation)
}
}
}

}

//On active l'onglet des messages
Expand Down Expand Up @@ -1046,8 +1054,8 @@ void ProjectManager::ImportMaterialCatt(wxString fromFile)
//Attention utilisations d'expressions régulières ( mal de tête en perspective ), mot clé: regex

//Fonctionne quelque soit le nombre de bande de frequence
wxRegEx generalMatHeader(wxT("(.*) = <((( ?[+-]?([0-9]*[.])?[0-9]+) ?)*)>( L )?(<((( ?[+-]?([0-9]*[.])?[0-9]+) ?)*)>)?( {([0-9]+) ([0-9]+) ([0-9]+)})?"));

//wxRegEx generalMatHeader(wxT("(.*) = <((( ?[+-]?([0-9]*[.])?[0-9]+) ?)*)>( L )?(<((( ?[+-]?([0-9]*[.])?[0-9]+) ?)*)>)?( {([0-9]+) ([0-9]+) ([0-9]+)})?"));
wxRegEx generalMatHeader(wxT("(?:ABS|abs|Abs) (.*?)[[:space:]]*=?[[:space:]]*<((( ?[+-]?([0-9]*[.])?[0-9]+) ?)*)>[[:space:]]*(L1?)?[[:space:]]*(<(((.?[+-]?([0-9]*[.])?[0-9]+) ?)*)>)?[[:space:]]*({.?([0-9]+) ([0-9]+) ([0-9]+)})?"));
wxRegEx matInfos(wxT("(.*):(.*)"));

wxString ligne=lecteur.GetLine();
Expand All @@ -1073,7 +1081,7 @@ void ProjectManager::ImportMaterialCatt(wxString fromFile)
}
wxString absName= generalMatHeader.GetMatch(ligne,1);
wxString chaineAbsorption=generalMatHeader.GetMatch(ligne,2);
wxString chaineDiffusion=generalMatHeader.GetMatch(ligne,6);
wxString chaineDiffusion=generalMatHeader.GetMatch(ligne,8);
wxString red = generalMatHeader.GetMatch(ligne, 13);
wxString green = generalMatHeader.GetMatch(ligne, 14);
wxString blue = generalMatHeader.GetMatch(ligne, 15);
Expand Down
56 changes: 53 additions & 3 deletions src/isimpa/data_manager/tree_core/e_core_spps_aghcore_advanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ class E_Core_SppsNee_AGH_advanced_MLT : public Element
if (!this->IsPropertyExist("mutationNumber")) {
InitBaseMLTProperties(this);
}
if (!this->IsPropertyExist("useRejectionSampling")) {
InitAdditionalMLTProperties(this);
}
}

E_Core_SppsNee_AGH_advanced_MLT(Element* parent)
Expand All @@ -248,6 +251,31 @@ class E_Core_SppsNee_AGH_advanced_MLT : public Element

void Modified(Element* eModif)
{
t_elementInfo filsInfo = eModif->GetElementInfos();
if (filsInfo.libelleElement == "selectSeeds") {
this->SetReadOnlyConfig("seedSampleRatio", !this->GetBoolConfig("selectSeeds"));
this->SetReadOnlyConfig("seedSelectionExponent", !this->GetBoolConfig("selectSeeds"));
}
else if (filsInfo.libelleElement == "mutationNumber") {
this->SetReadOnlyConfig("largeStepProb", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("selectSeeds", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("seedSampleRatio", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("seedSelectionExponent", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("useWeightDecayCompensation", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("mutateSource", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("reflectionPenalty", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("costMatAbsorption", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("costMatDiffusion", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("costShadowRays", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("costReflDir", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("costAirAb", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("useRejectionSampling", !(bool)this->GetIntegerConfig("mutationNumber"));
this->SetReadOnlyConfig("lowMemoryMode", !(bool)this->GetIntegerConfig("mutationNumber"));

if (this->GetIntegerConfig("mutationNumber") == 0) this->UpdateBoolConfig("useRejectionSampling", true);
if (this->GetIntegerConfig("mutationNumber") == 0) this->UpdateBoolConfig("lowMemoryMode", true);
}

Element::Modified(eModif);
}

Expand All @@ -258,16 +286,38 @@ class E_Core_SppsNee_AGH_advanced_MLT : public Element
{
InitRandomSeed(this);
InitBaseMLTProperties(this);
InitAdditionalMLTProperties(this);
}

void InitRandomSeed(Element* confCore) {
confCore->AppendPropertyInteger("random_seed", wxTRANSLATE("Random seed"), 0, true, false, true);
}

void InitBaseMLTProperties(Element* confCore) {
confCore->AppendPropertyDecimal("largeStepProb", wxTRANSLATE("Large step probability"), 0.5, false, 2, true, true, 1, 0, true);
confCore->AppendPropertyDecimal("specularReflProbabilityMulti", wxTRANSLATE("Specular reflection probability multiplier"), 0.5, false, 3, true, true, 10, 0.01, true);
confCore->AppendPropertyInteger("mutationNumber", wxTRANSLATE("Mutation number"), 25, true, false, true, 0, 0);
confCore->AppendPropertyDecimal("largeStepProb", wxTRANSLATE("Tune - Large step probability"), 0.2, false, 2, true, true, 1, 0, true);
//confCore->AppendPropertyDecimal("specularReflProbabilityMulti", wxTRANSLATE("Tune - Specular reflection probability multiplier"), 0.5, false, 3, true, true, 10, 0.01, true);
confCore->AppendPropertyInteger("mutationNumber", wxTRANSLATE("Sampling - Mutation number"), 10, true, false, true, 0, 0);
}
void InitAdditionalMLTProperties(Element* confCore) {
confCore->AppendPropertyBool("useRejectionSampling", wxTRANSLATE("Use - Rejection sampling"), true, true);
confCore->AppendPropertyBool("useWeightDecayCompensation", wxTRANSLATE("Use - Weight decay compensation"), true, true);
confCore->AppendPropertyBool("mutateSource", wxTRANSLATE("Use - Mutate source"), true, true);
confCore->AppendPropertyBool("selectSeeds", wxTRANSLATE("Use - Seed selection"), true, true);

confCore->AppendPropertyDecimal("seedSampleRatio", wxTRANSLATE("Sampling - Seed to sample ratio"), 0.1, false, 2, true, true, 1, 0.01, true);
confCore->AppendPropertyDecimal("mutatedWeight", wxTRANSLATE("Sampling - Mutated particles weight"), 1, false, 1, true, true, 20, 0.5, true);
confCore->AppendPropertyDecimal("reflectionPenalty", wxTRANSLATE("Tune - Relfection penalty multiplier"), 0.8, false, 2, true, true, 10, 0.01, true);
confCore->AppendPropertyInteger("mutationGeneratorS1", wxTRANSLATE("Tune - Mutation generator S1"), 1024, true, false, true, 0, 1);
confCore->AppendPropertyInteger("mutationGeneratorS2", wxTRANSLATE("Tune - Mutation generator S2"), 64, true, false, true, 0, 1);
confCore->AppendPropertyDecimal("mutationProbability", wxTRANSLATE("Tune - Mutation probability"), 1, false, 3, true, true, 1, 0.1, true);
confCore->AppendPropertyDecimal("seedSelectionExponent", wxTRANSLATE("Tune - Seed selection exponent"), 0.5, false, 2, true, true, 1, 0.01, true);
confCore->AppendPropertyBool("lowMemoryMode", wxTRANSLATE("Tune - Low memory mode"), true, true);

confCore->AppendPropertyBool("costMatAbsorption", wxTRANSLATE("Cost - use material absorption"), true, true);
confCore->AppendPropertyBool("costMatDiffusion", wxTRANSLATE("Cost - use material diffusion"), false, true);
confCore->AppendPropertyBool("costShadowRays", wxTRANSLATE("Cost - use shadow rays"), true, true);
confCore->AppendPropertyBool("costReflDir", wxTRANSLATE("Cost - use reflection direction"), false, true);
confCore->AppendPropertyBool("costAirAbs", wxTRANSLATE("Cost - use air absorption"), false, true);
}
};

Expand Down
5 changes: 4 additions & 1 deletion src/lib_interface/Core/mathlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ class base_vec3 {
// this < _v
bool compare(const base_vec3 &_v,base_t epsi=EPSILON) { return (fabs(this->x - _v.x) < epsi && fabs(this->y - _v.y) < epsi && fabs(this->z - _v.z) < epsi); }
base_t angle(const base_vec3 &v) const { // retourne l'angle en radians entre *this et v
base_t angle = acos(this->dot(v)/(this->length()*v.length()));
base_t dot_prod = this->dot(v) / (this->length() * v.length());
if (dot_prod > 1) dot_prod = 1;
if (dot_prod < -1) dot_prod = -1;
base_t angle = acos(dot_prod);
if(angle < EPSILON) return 0;
return angle;
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib_interface/input_output/progressionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class progressOperation
{
PushProgression(1.f);
}

void Push(float increment)
{
PushProgression(increment);
}

protected:
//friend class progressOperation;

Expand Down
2 changes: 2 additions & 0 deletions src/spps-agh/CalculationCoreAGH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ bool CalculationCoreSPPS::VisabilityTest(const CONF_PARTICULE_AGH &configuration
CONF_PARTICULE_AGH testParticle = configurationP;

testParticle.nextModelIntersection.idface = GetTetraFaceCollision(testParticle, testParticle.direction, t);
if (testParticle.nextModelIntersection.idface == -1) return false;
testParticle.nextModelIntersection.collisionPosition = testParticle.position + testParticle.direction*t;
obst_dist = configurationP.direction.length()*t;

Expand All @@ -225,6 +226,7 @@ bool CalculationCoreSPPS::VisabilityTest(const CONF_PARTICULE_AGH &configuration
{
testParticle.currentTetra = nextTetra;
testParticle.nextModelIntersection.idface = GetTetraFaceCollision(testParticle, testParticle.direction, t);
if (testParticle.nextModelIntersection.idface == -1) return false;
testParticle.nextModelIntersection.collisionPosition = testParticle.position + testParticle.direction*t;
obst_dist += testParticle.direction.length()*t;

Expand Down
Loading