Dosen: Prof. Dr. Suhartono, S.Si., M.Kom_196805192003121001 Fakultas: Sains dan Teknologi Program Studi: Teknik Informatika Kelas C

library(mosaicCalc)
## Loading required package: mosaic
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
## 
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
## 
##     count, tally
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D

Optimasi dalam kalkulus mosaic adalah proses menemukan nilai maksimum atau minimum dari suatu fungsi dalam beberapa variabel dengan menggunakan konsep turunan parsial. Ini dapat digunakan untuk menemukan solusi terbaik dalam berbagai masalah di dunia nyata, seperti optimasi biaya, keuntungan, atau efisiensi.

f <- rfun ( ~ x, seed =579 )
slice_plot(f(x) ~ x, bounds(x=-5:5)) %>%
  gf_hline(yintercept = ~ 0, color="red")

Fungsi R/mosaik argM() merupakan fungsi argmax dan argmin pada domain tertentu. Cara kerjanya persis sama seperti slice_plot(), namun alih-alih menggambar grafik, ia mengembalikan bingkai data yang memberikan argmax di satu baris dan argmin di baris lainnya.

h <- rfun(~ x, seed=579)
argM(h(x) ~ x, bounds(x=-5:5))
## # A tibble: 2 × 3
##       x .output. concavity
##   <dbl>    <dbl>     <dbl>
## 1  2.30    -11.6         1
## 2 -1.23     14.6        -1
## # A tibble: 2 × 3
##       x .output. concavity
##   <dbl>    <dbl>     <dbl>
## 1  2.30    -11.6         1
## 2 -1.23     14.6        -1

Kolom x menampung argmax dan argmin, .output. kolom memberikan nilai output fungsi untuk input x. Kolom tersebut concavity menunjukkan apakah kecekungan fungsi tersebut x positif atau negatif. Mendekati puncak, cekungannya akan menjadi negatif; dekat lembah, cekungannya positif. Akibatnya, Anda dapat melihat bahwa baris pertama dari bingkai data sesuai dengan minimum lokal dan baris kedua adalah maksimum lokal.

argM() diatur untuk mencari satu argmax dan satu argmin dalam interval domain yang diberikan sebagai argumen kedua. Pada Output diatas terdapat dua puncak lokal dan dua lembah lokal. argM() hanya memberikan puncak terbesar dan lembah terdalam.