<jupyter_start><jupyter_text>Nonlinear Optimization Author: <NAME>There are standard algorithms and packages to handle linear optimization problems. However, the setup can get quite complication if one introduces nonlinearity into the picture. In this notebook I used the `R Optimization Infrastructure` package to solve a curated nonlinear optimization problem.<jupyter_code># Load libraries
library(ROI)
library(ROI.plugin.alabama)<jupyter_output>ROI: R Optimization Infrastructure

Registered solver plugins: nlminb, alabama.

Default solver: auto.<jupyter_text>Maximize the following nonlinear objective function with $3$ continuous variablesF_objective: $x_2x_3 - x_1x_3 + x_1x_2$ subject to $1$ constraint of nonlinear type F_constraint: $x_1 - 57x_1x_2 - 28x_2x_3 \geq 50000$ and $3$ lower and $3$ upper non-standard variable bounds1. $x_1 \in [-10, 10]$, 2. $x_2 \in [-50, 50]$ and 3. $x_3 \in [-100, 100]$.<jupyter_code># Formulate the nonlinear problem
problem <- OP(objective = F_objective(F = function(x) {prod(x[-1]) - prod(x[-2]) + prod(x[-3])}, 
                                      n = 3),
              constraints = F_constraint(F = function(x) {x[1] - 57*x[1]*x[2] - 28*x[2]*x[3]}, 
                                         dir = ">=", 
                                         rhs = 50000,
                                         J = function(x) c(1 - 57*x[2], -57*x[1] - 28*x[3], -28*x[2])), 
                                         # J = Jacobian of F_constraint
              bounds = V_bound(lb = c(-10, -50, -100), 
                               ub = c(10, 50, 100), 
                               nobj = 3L),
              maximum = TRUE)
# Solve and print result
solution <- ROI_solve(problem, solver = "alabama", start = c(0, 0, 0))
solution

print(paste(c("x1 =", "x2 =", "x3 ="), solution$solution))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12392703862660945, 'fraction_numerical': 0.05150214592274678, 'mean_word_length': 2.3422939068100357, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '458421', 'license': 'MIT', 'n_tokens_mistral': 645, 'n_tokens_neox': 564, 'n_words': 172, 'path': 'StatMathMethods/R/NonlinearOptimization.ipynb', 'repo_name': 'snigdhayan/TopologicalDataAnalysis', 'size': '1876'}