Category "optimization"

Maximization of portfolio return by implementing the portfolio variance constraint in MATLAB

I have solved the minimization of portfolio variance problem many times, using fmincon or quadprog (of course, quadprog is much faster). The formulation of the

Find pivots in tensor that maximize sum of values

Let's suppose I have a matrix like this: [[15,10,8], [11,5,8], [9,14,4]] I need to write a function that, for each row, returns the indices of the maximum valu

Baron solver and warmstart in Pyomo

I am using Baron solver and Pyomo. I would like to feed an starting point to the variable in Baron. Pyomo has an option called "warmstart=True" that allows to d

How to know if the file end with a new line character or not

I'm trying to input a line at the end of a file that has the following shape "1 :1 :1 :1" , so at some point the file may have a new line character at the end o

Branching in Pyscipopt

Branching on t_x21 led to this error [scip_branch.c:1061] ERROR: cannot branch on variable <t_x21> with fixed domain [-0,0] So, my guess as to why this

Rewriting SAS optimization in Python

I am trying to rewrite something similar to the following SAS optimization code in Python. The goal of the code is to find parameters for a continuous (in this

How to optimise a condition which checks for each object of an array of objects whether specific properties are not undefined?

I want code optimisation for an if-statement because I otherwise have to add more key-value pairs into this condition with &&. I have an array of object

Transpose an image2d_t in OpenCL

I work on an image processing code base that uses image2d_t objects everywhere. These have their shape (width and height) formally declared which enables progra

Optimizing gpu allocation/transfer of matrix tiles

I am working with very large matrices (>1GB) but imagine that I have the following matrix: A = [1 1 2 2; 1 1 2 2; 3 3 4 4; 3 3 4 4] I need to

How to Convert or Solve a Non-Linear Optimization Problem with Non-Linear Objective Function & Constraints

Overview I am working on an order allocation problem with variable and fixed costs. The initial formulation of this problem was a linear optimization, but when

How to Convert or Solve a Non-Linear Optimization Problem with Non-Linear Objective Function & Constraints

Overview I am working on an order allocation problem with variable and fixed costs. The initial formulation of this problem was a linear optimization, but when

Pyomo constraint: use continuous variable as boolean?

I am looking to use a continuous variable in a bool statement. For example, if m.N[t] is the continuous variable, I'd like to do the following: @m.Constraint(m.

efficient frontier/stock analyze

Consider the following task. Using a 10-year period I should calculate the portfolio weights in January and then use these weights in February to calculate the

Import error: 'SimpleExperiment' while running BOTORCH example code

I am trying to work with Bayesian Optimisation for my Numerical model run, Optimising its parameters. For this I am using BoTorch. Its example code is given as

How to have a single csv file after applying partitionBy in Pysark

I have to first partition by a "customer group" but I also want to make sure that I have a single csv file per "customer_group" . This is because it is timeseri

Distibuted Computing in Julia Slower than Serial

I have a julia function that seems very amenable to optimization. Each iteration only manipulates the stuff in its particular index. Yet this function, when imp

Inline index addition in gams

I want to use an index equation to iterate over a tensors, whereas I always want to extract the value at index i and index i+1. An example: Variable x; x.up = 1

How to minimize and then maxmize one function sequentially with DOcplex in python?

I want to solve a problem like this: maxy∈Y{minx∈X(y) cTx} which is to firstly minimize cTx with x in X(y), and we get the result with y still uncer

Fastest way to count event occurences in a Pandas dataframe?

I have a Pandas dataframe with ~100,000,000 rows and 3 columns (Names str, Time int, and Values float), which I compiled from ~500 CSV files using glob.glob(pat

Loading large files into memory with Python

When doing work with large files and datasets (usually 1 or 2 gb+), the process is killed do to running out of RAM. What tools and methods are available to allo