refactored sensing objective into domain, random inits

This commit is contained in:
2025-11-15 16:01:18 -08:00
parent e0f365b21b
commit afa5d79c1d
13 changed files with 110 additions and 51 deletions

View File

@@ -1,9 +1,11 @@
function obj = initialize(obj, bounds, tag, label)
function obj = initialize(obj, bounds, tag, label, objectiveFunction, discretizationStep)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'rectangularPrism')};
bounds (2, 3) double;
tag (1, 1) REGION_TYPE = REGION_TYPE.INVALID;
label (1, 1) string = "";
objectiveFunction (1, 1) function_handle = @(x, y) 1;
discretizationStep (1, 1) double = 1;
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'rectangularPrism')};
@@ -12,7 +14,7 @@ function obj = initialize(obj, bounds, tag, label)
obj.tag = tag;
obj.label = label;
%% Define geometry bounds by LL corner and UR corner
% Define geometry bounds by LL corner and UR corner
obj.minCorner = bounds(1, 1:3);
obj.maxCorner = bounds(2, 1:3);
@@ -37,4 +39,9 @@ function obj = initialize(obj, bounds, tag, label)
[obj.minCorner(1), obj.maxCorner(2)]; ...
[obj.maxCorner(1), obj.minCorner(2)]; ...
obj.maxCorner(1:2)];
% Instantiate sensingObjective only for DOMAIN-type regions
if tag == REGION_TYPE.DOMAIN
obj.objective = sensingObjective;
end
end

View File

@@ -0,0 +1,18 @@
function [obj] = initializeRandom(obj, minDimension, tag, label)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'rectangularPrism')};
minDimension (1, 1) double = 10;
tag (1, 1) REGION_TYPE = REGION_TYPE.INVALID;
label (1, 1) string = "";
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'rectangularPrism')};
end
% Produce random bounds
L = ceil(minDimension + rand * minDimension);
bounds = [zeros(1, 3); L * ones(1, 3)];
% Regular initialization
obj = obj.initialize(bounds, tag, label);
end

View File

@@ -21,9 +21,14 @@ classdef rectangularPrism
% Plotting
lines;
end
properties (SetAccess = public, GetAccess = public)
% Sensing objective (for DOMAIN region type only)
objective;
end
methods (Access = public)
[obj ] = initialize(obj, bounds, tag, label);
[obj ] = initialize(obj, bounds, tag, label, objectiveFunction, discretizationStep);
[obj ] = initializeRandom(obj, tag, label);
[r ] = random(obj);
[c ] = contains(obj, pos);
[d ] = distance(obj, pos);