1818
1919project = jsonToProject('{project}');
2020controls = jsonToControls('{control}');
21+ customControls = customControl();
22+ customControls.update(controls);
23+ customControls.filePath = '{ipc_path}';
2124if any(strcmpi(controls.procedure, {{procedures.DE.value, procedures.Simplex.value}}))
22- disp("hello")
2325 useLivePlot(1);
2426end
2527for i=1:project.customFile.rowCount
2628 addpath(project.customFile.varTable{{i, 5}});
2729end
28- [project, results] = RAT(project, controls );
30+ [project, results] = RAT(project, customControls );
2931
3032projectToJson(project, '{project}');
3133resultsToJson(results, '{result}');
3436"""
3537
3638
37- def run_matlab_directly (project , controls , matlab_rat_path , stdout = None , stderr = None ):
39+ CONTROL = """classdef customControl < controlsClass
40+ properties(Hidden = true)
41+ filePath = ''
42+ end
43+ methods
44+ function update(obj, controls)
45+ propNames = properties(controls);
46+ for i = 1:length(propNames)
47+ obj.(propNames{i}) = controls.(propNames{i});
48+ end
49+ end
50+ function path = getIPCFilePath(obj)
51+ path = obj.filePath;
52+ end
53+ end
54+ end
55+ """
56+
57+
58+ def run_matlab_directly (project , controls , matlab_rat_path , ipc_path = "" , stdout = None , stderr = None ):
3859 """Run User provided MATLAB RAT for the given project and controls inputs.
3960
4061 Parameters
@@ -45,6 +66,8 @@ def run_matlab_directly(project, controls, matlab_rat_path, stdout=None, stderr=
4566 The controls model (or equivalent json dict), which defines algorithmic properties.
4667 matlab_rat_path : str
4768 The path to MATLAB RAT folder.
69+ ipc_path : str, optional
70+ IPC path for MATLAB to use
4871 stdout : io.TextIOBase, optional
4972 Text stream for MATLAB console output
5073 stderr : io.TextIOBase, optional
@@ -60,10 +83,19 @@ def run_matlab_directly(project, controls, matlab_rat_path, stdout=None, stderr=
6083 control_file = Path (tmp , "controls.json" )
6184 result_file = Path (tmp , "results.json" )
6285 runner_file = Path (tmp , "executeRAT.m" )
86+ custom_controls_file = Path (tmp , "customControl.m" )
87+ with open (custom_controls_file , "w" ) as f :
88+ f .write (CONTROL )
6389
6490 with open (runner_file , "w" ) as f :
6591 f .write (
66- RUNNER .format (project = project_file , control = control_file , result = result_file , rat_path = matlab_rat_path )
92+ RUNNER .format (
93+ project = project_file ,
94+ control = control_file ,
95+ result = result_file ,
96+ rat_path = matlab_rat_path ,
97+ ipc_path = ipc_path ,
98+ )
6799 )
68100
69101 controls .save (control_file ) if not isinstance (controls , dict ) else control_file .write_text (json .dumps (controls ))
0 commit comments