nonlinear-optimization

Maximizing nonlinear-constraints-problem using R-package “nloptr”

一笑奈何 提交于 2019-12-25 03:26:47
问题 I need to maximize the objective function for some problems using R package 'nloptr'. I tried the basic rule "Maximize f(x) <=> Minimize -f(x)" but it does not work. I am not sure what's wrong either using it or there is some other way. Here is a complete example. The current solution is just the initial vector with minimum objective value. But, I am supposed to get the solution that would maximize the objective function. Can someone please help me how to get it. Thanks! library(nloptr) X =

CasADi: Matrix function from symbolic variable

混江龙づ霸主 提交于 2019-12-25 01:19:10
问题 Somewhat related to this question (and cross-posted here), I'm trying to index a symbolic matrix variable in CasADi. I want to take a vector variable x and populate a matrix A of symbolic function expressions based on the components of x . More specifically, I hope to do something like part (c) below: from casadi import * opti = Opti() n = 3 B = np.random.normal(size=[n, n]) D = np.random.normal(size=[n, n]) D = np.dot(D.T, D) ##(a) variables and expressions x = opti.variable(n); opti.set

GAMS Display style

本秂侑毒 提交于 2019-12-24 04:51:34
问题 How do I display a text in GAMS? For example: in MATLAB I can use disp('MATLAB'), then I will get the output as MATLAB. Is it possible to have like this in GAMS. In fact, I am new with GAMS environment. Regards 回答1: display "Hi, warning message here!" ... should work. This will appear in your .LST file, which you should get familiar with reading for debugging purposes. 回答2: There are actually two ways: $log "text to display" if you want it to appear during the compilation phase (and shows

Nonlinear optimization with R for grouped variables

不打扰是莪最后的温柔 提交于 2019-12-22 14:51:47
问题 I am trying to find maximum values for below objective function: objective <-function(bid,revenue,click,cost) { revenue_2 <- sum((revenue / cost)* (bid*click*bid*(cost/click) / cost)^(-0.2*revenue/cost)* (bid*click)*bid*(cost/click)) return(-revenue_2) } subject to roas_2 <- function(bid, revenue,click,cost) { revenue_2 <- ((revenue / cost)* (bid*click*bid*(cost/click) / cost)^(-0.2*revenue/cost))* (bid*click)*bid*(cost/click) cost_2 <- (bid*click)*bid*(cost/click) roas_2 <- (sum(revenue_2)

how to solve 3 nonlinear equations in python

爱⌒轻易说出口 提交于 2019-12-22 11:12:18
问题 I have the following system of 3 nonlinear equations that I need to solve: -xyt + HF = 0 -2xzt + 4yzt - xyt + 4z^2t - M1F = 0 -2xt + 2yt + 4zt - 1 = 0 where x, HF, and M1F are known parameters. Therefore, y,z, and t are the parameters to be calculated. Attemp to solve the problem: def equations(p): y,z,t = p f1 = -x*y*t + HF f2 = -2*x*z*t + 4*y*z*t - x*y*t + 4*t*z**2 - M1F f3 = -2*x*t + 2*y*t + 4*z*t - 1 return (f1,f2,f3) y,z,t = fsolve(equations) print equations((y,z,t)) But the thing is

Convergence of a very large non-linear least squares optimization

谁说我不能喝 提交于 2019-12-22 10:52:45
问题 I'm trying to solve the following problem: I have a lot (~80000) surface patches of an organ that's growing. I measure each of its areas over time (18 time-points) and want to fit a growth curve to it (bi-logistic model, eg. just the sum of two logistic functions bcs. there are two 'growth spurts' happening in the observed period). I have box constraints to ensure that the exponential terms don't explode and a linear constraint that one growth spurt has to happen after the other. Also, in

No change to initial values using nloptr in R

岁酱吖の 提交于 2019-12-22 10:13:02
问题 I've been struggling with optimization problems in R for months now. I've finally figured out lpSolve for linear problems, thanks to examples on data for fantasy sports. However, my original and (still) current problem is trying nonlinear optimization with equality constraints using nloptr in R. What I'm trying to do is minimize the variance of a two-stock portfolio, in which the two stocks' returns are almost perfectly negatively correlated (for those that are familiar with academic finance,

Minimization with R nloptr package - multiple equality constraints

試著忘記壹切 提交于 2019-12-22 06:27:14
问题 Is it possible to specify more than one equality constraint in nloptr function in R? The code that I am trying to run is the following: eval_f <- function( x ) { return( list( "objective" = x[3]^2+x[4]^2, "gradient" = c( 0, 0, 2*x[3], 2*x[4] ) ) ) } # constraint functions # equalities eval_g_eq <- function( x ) { constr <- c( x[1] + x[2] + x[3] - 4, x[1]^2 + x[2]^2 + x[4] - 15 ) grad <- c( c(1, 1, 1, 0), c(2*x[1], 2*x[2], 0, 1) ) return( list( "constraints"=constr, "jacobian"=grad ) ) } #

Maximizing linear objective subject to quadratic constraints

冷暖自知 提交于 2019-12-20 04:37:05
问题 I have a programming formulation from a paper and want to give it a tool for solving specific problems. The authors stated it as an linear programming (LP) instance, however I am not sure. Formulation is somewhat like as follows: max x1+x2+x3... s.t. x1.x3+x4.x5 <= 10 x2.x5+x3.x7+x1.x9 <=10 ... I tried to program it through cplexqcp function (due to quadratic constraints, however constraints do not include any x_i^2 variable). However I receive CPLEX Error 5002: Q in %s is not positive semi

In R, how to do nonlinear least square optimization which involves solving differential equations?

不羁的心 提交于 2019-12-18 17:27:40
问题 Update with reproducible examples to illustrate my problem My original question was "Implementation of trust-region-reflective optimization algorithm in R". However, on the way of producing a reproducible example(thanks @Ben for his advice), I realize that my problem is that in Matlab, one function lsqnonlin is good(meaning no need to choose a good starting value, fast) enough for most cases I have, while in R, there is not such a one-for-all function. Different optmization algorithm works