gradient-descent.ts 807 B

12345678910111213141516171819202122232425262728293031
  1. import { singleVarfunctions } from '~/components/playground/gradient-descent/functions'
  2. export const state = () => ({
  3. isPlaying: false,
  4. currentFunction: Object.keys(singleVarfunctions)[0],
  5. learningRate: 0.01,
  6. choosingPoint: true
  7. })
  8. type RootState = ReturnType<typeof state>
  9. export const mutations = {
  10. setIsPlaying(state: RootState, isPlaying: boolean) {
  11. state.isPlaying = isPlaying
  12. },
  13. setCurrentFunction(state: RootState, value: string) {
  14. state.currentFunction = value
  15. },
  16. setLearningRate(state: RootState, value: number) {
  17. state.learningRate = value
  18. },
  19. setChoosingPoint(state: RootState, value: boolean) {
  20. state.choosingPoint = value
  21. }
  22. }
  23. export const getters = {
  24. getCurrentFunction(state: RootState) {
  25. return singleVarfunctions[state.currentFunction]
  26. }
  27. }