Skip to content

Instantly share code, notes, and snippets.

@ojwoodford
ojwoodford / nonzero_optimal_residual.jl
Created October 13, 2023 09:38
Experiment demonstrating the effect of a non-zero optimal residual on Levenberg-Marquardt
using StaticArrays, GLMakie, LinearAlgebra, Static
import NLLSsolver
const λ = 10.0
# Define the Rosenbrock cost function
struct RosenbrockA <: NLLSsolver.AbstractResidual
end
Base.eltype(::RosenbrockA) = Float64
NLLSsolver.ndeps(::RosenbrockA) = static(1) # Residual depends on 1 variable
@ojwoodford
ojwoodford / nlls_solvers_comparison.jl
Last active October 26, 2023 05:00
Comparison of non-linear least squares optimizers in Julia, using Rosenbrock-like functions of various dimensions
# Compare non-linear least squares solvers on the multi-dimensional Rosenbrock function
startpoint(n) = Float64[i % 2 == 0 ? 1.0 : -1.2 for i = 1:n]
const diagonal_weight_dense = 1.2
const offdiagonal_weight_dense = 1.0
const diagonal_weight_sparse = 1.0
const offdiagonal_weight_sparse = 10.0
################################################################################
# NLLS formulation
@ojwoodford
ojwoodford / nllssolver_vs_jso.jl
Last active November 5, 2023 16:57
Comparison of Bundle Adjustment optimization using JSO and NLLSsolver in Julia
# JSO
using BundleAdjustmentModels, CaNNOLeS
function jso_func()
# Dry run to do compilation
model = BundleAdjustmentModel("problem-16-22106")
stats = cannoles(model, method=:Newton_noFHess)
# Output these results
model = BundleAdjustmentModel("problem-16-22106")
@ojwoodford
ojwoodford / CalendarSync.js
Last active November 8, 2024 22:36
Sync events from a personal Google calendar to a work Google calendar
function SyncMyCal() {
var options = {
'targetEventTitle': "Busy (sync'd event)", // What event title do you want ported events to have
'daysahead': 60, // How many days ahead do you want to sync events over
'ignorealldayevents': true, // Do you want to ignore all day events in your "from" calendars
'ignorethesedays': [0, 6], // Are there days of the week you don't want to sync? 0 = Sunday
'maxhoursbetweenruns': 1, // How many hours between scheduled runs of the calendar sync (you need to set these up)
'onlybusyevents': true, // Only copy events marked 'busy'
'busyness': 1, // Should events be marked 'busy' by default (0: free, 1: busy, 2: match source event)
'visibility': 2, // Should the events be visible by default (0: private, 1: public, 2: match source event)

Keybase proof

I hereby claim:

  • I am ojwoodford on github.
  • I am ojwoodford (https://keybase.io/ojwoodford) on keybase.
  • I have a public key whose fingerprint is 86F0 089C 7FAB 4C91 9B3F E35E AED3 D386 716F 0278

To claim this, I am signing this object: