dynamic change of the metric parameters

This commit is contained in:
Niko Feith 2023-06-14 15:38:32 +02:00
parent 0a83136430
commit 73d760c40c
5 changed files with 57 additions and 28 deletions

View File

@ -19,7 +19,7 @@
v-model="maxStepComp"
:step="1"
:min="10"
:max="200"
:max="500"
thumb-label
/>
<v-slider
@ -37,7 +37,7 @@
v-model="cstore.nr_episodes"
:step="1"
:min="1"
:max="200"
:max="500"
thumb-label
/>
<v-slider
@ -55,38 +55,44 @@
label="Acquisition Function"
v-model="acqSelector"
></v-select>
<v-slider
class="control-slider"
label="Metric Parameter"
v-model="cstore.metric_parameter"
:step="cstore.metric_limits[cstore.metric][2]"
:min="cstore.metric_limits[cstore.metric][0]"
:max="cstore.metric_limits[cstore.metric][1]"
thumb-label
/>
<v-slider
v-if="cstore.metric === 'improvement'"
class="control-slider"
label="Metric Parameter"
v-model="cstore.metric_parameter2"
:step="0.01"
:min="0"
:max="1"
thumb-label
/>
<v-row class="justify-space-evenly px-1 py-0">
<v-row class="flex-row px-4 py-0" style="max-height: 80px">
<v-slider
class="control-slider"
:label="cstore.metrics_label[cstore.metric]"
v-model="cstore.metric_parameter"
:step="cstore.metric_limits[cstore.metric][2]"
:min="cstore.metric_limits[cstore.metric][0]"
:max="cstore.metric_limits[cstore.metric][1]"
thumb-label
/>
<v-col class="pa-0 ba-0" cols="2">
<v-select
v-if="cstore.metric === 'improvement'"
label="nr episodes"
v-model="cstore.improvement_2"
:items="[5, 10, 15, 20, 25, 30, 35, 40, 45, 50]"
variant="outlined"
/>
</v-col>
</v-row>
<v-row class="justify-space-evenly px-1 py-0 ma-0 ba-0">
<v-checkbox
class="py-0 my-0"
v-model="cstore.fixed_seed"
label="fixed seed"
/>
<v-checkbox
class="py-0 my-0"
v-model="cstore.overwrite"
label="overwrite param"
/>
<v-checkbox
class="py-0 my-0"
v-model="cstore.save_result"
label="save_result"
/>
</v-row>
<v-row class="d-flex justify-space-evenly py-0">
<v-row class="d-flex justify-space-evenly py-0 ma-0">
<v-btn
class="py-0 my-0"
color="primary"

View File

@ -206,7 +206,9 @@ watch(
nr_runs: cstore.nr_runs,
acquisition_function: cstore.acq_fun,
metric_parameter: cstore.metric_parameter,
metric_parameter_2: cstore.improvement_2,
save_result: cstore.save_result,
overwrite: cstore.overwrite,
});
active_bo_pending.value = true;
active_bo_request.publish(request_msg);

View File

@ -4,6 +4,7 @@
<v-col v-for="(_ , idx) in weights" :key="idx">
<div class="weight-container">
<vue-slider
class="slider-margin-bottom"
v-model="weights[idx]"
@change="updateWeight(idx, $event)"
direction="btt"
@ -12,6 +13,7 @@
:max="1"
:interval="0.01"
/>
<v-checkbox class="ma-0 checkbox-bottom" />
</div>
</v-col>
</v-row>
@ -44,9 +46,18 @@ const updateWeight = (index, newValue) => {
height: 140px;
}
.weight-container {
height: 140px;
height: 180px;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
justify-content: center;
}
.slider-margin-bottom {
margin-bottom: 0; /* adjust this value as necessary */
}
.checkbox-bottom {
//position: absolute;
//bottom: 0;
padding: 5px 0 0 0;
}
</style>

View File

@ -6,12 +6,18 @@ export const useCStore = defineStore("Control Store", {
env: "Mountain Car",
envs: ["Mountain Car", "Cartpole", "Acrobot", "Pendulum"],
metric: "random",
metrics: ["random", "regular", "max_acquisition", "improvement"],
metrics: ["random", "regular", "improvement", "max_acquisition"],
metrics_label: {
random: "Probability",
regular: "Repetition",
improvement: "Improvement Threshold",
max_acquisition: "Threshold",
},
metric_limits: {
random: [0.0, 1.0, 0.01],
regular: [1, 100, 1],
improvement: [0.0, 1.0, 0.01],
max_acquisition: [1, 200, 1],
improvement: [1, 100, 1],
},
acq_fun: "Expected Improvement",
acq_funs: [
@ -22,11 +28,12 @@ export const useCStore = defineStore("Control Store", {
nr_episodes: 50,
nr_runs: 10,
metric_parameter: 0.5,
metric_parameter2: 0.5,
improvement_2: 5,
sendWeights: false,
runner: false,
fixed_seed: false,
save_result: false,
overwrite: false,
};
},
getters: {

View File

@ -6,6 +6,7 @@ export const usePStore = defineStore("Policy Store", {
policy: Array(10).fill(0),
nr_weights: 5,
weights: [0, 0, 0, 0, 0],
weights_fixed: [false, false, false, false, false],
max_steps: 100,
trigger: false,
};
@ -13,6 +14,7 @@ export const usePStore = defineStore("Policy Store", {
getters: {
getPolicy: (state) => state.policy,
getNrWeights: (state) => state.nr_weights,
getWeights_Fixed: (state) => state.weights_fixed,
getWeights: (state) => state.weights,
getMaxSteps: (state) => state.max_steps,
getTrigger: (state) => state.trigger,
@ -25,6 +27,7 @@ export const usePStore = defineStore("Policy Store", {
setNrWeights(value) {
this.nr_weights = value;
this.weights = Array(this.nr_weights).fill(0);
this.weights_fixed = Array(this.nr_weights).fill(false);
this.trigger = !this.trigger;
},
setWeights(value) {