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

View File

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

View File

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

View File

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

View File

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