# optimization

## Efficient algorithm to calculate the most right non-zero digit of a number's factorial in Python

Efficient algorithm to calculate the most right non-zero digit of a number's factorial in Python Question: Calculate the most right non-zero digit of n factorial efficiently I want to calculate the right most digit of a given number’s factorial and print it. What I’ve done so far is: import math n = int(input()) fact = …

## Degenerate root finding problem: get the first value for which f(x)>0

Degenerate root finding problem: get the first value for which f(x)>0 Question: Given a function f(x) that is zero for all values x less than a critical value c, and non-zero for values x>c. I want to approximate the critical value c using an optimization method. Because the function f(x) is expensive, I want to …

## Multiaxis System of Equations Optimizations in Python

Multi-axis equation optimization Question: Optimize value of O_t based on each value of L_t from 1 to 240 according to below equations: O_t = O1+O2+O3+O4 O1= LS1+3×D O2=3×LS2+4×S O3=S+3×D O4= LS4×4+7×D L_t = LS1+LS2+LS3+LS4+LS5+LS6 L_t = (S+D)/5 Desired outputs: Values of S, D, LS1, LS2, LS3, LS4, LS5 and LS6 that result in highest possible …

## Is pulp.lpDot(a,n) not equivalent to pulp.lpSum([a[i] * n[i] for i in range(N)])?

Is pulp.lpDot(a,n) not equivalent to pulp.lpSum([a[i] * n[i] for i in range(N)])? Question: I have a decision variable vector n, and a is a constant vector. What confuses me is why lpDot(a,n) is not equivalent to lpSum([a[i] * n[i] for i in range(N)]) in a constraint? Here is the code: import pulp import numpy as …

## Comparison between dataframes without loops

Comparison between dataframes without loops Question: I have 2 Data Frames structured like those: Df1: gene ids Go terms ID1 GO1 ID1 GO2 ID2 GO1 ID2 GO3 ID3 GO1 ID4 GO1 Df2: MP terms MP names gene ids MP1 Name1 ID1, ID2, ID4 MP2 Name2 ID1,ID3 MP3 Name3 ID2 Now I would like to create …

## where can I find the numpy.matmul() source code?

where can I find the numpy.matmul() source code? Question: I do not obtain the same results when I use np.matmul(A, b) in Python and when I use xtensor-blas‘s xt::linalg::dot(A, b) in C++. I am investigating the reasons, as when saved and read from disk, A and b are identical when doing np.allclose(A, b) in Python. …

## Python: Optimization with Exponential Objective Function

Python: Optimization with Exponential Objective Function Question: I am working on assignment problems. So far, I have been using Gurobi via gurobipy. In my current problem, I have an objective function with an exponential term. In gurobipy this would be m.setObjective(ratings.prod(assign) ** 0.5, sense=GRB.MAXIMIZE) but ** (or pow()) is not supported in Gurobi. What are …

## Find all possible sums of the combinations of integers from a set, efficiently

Find all possible sums of the combinations of integers from a set, efficiently Question: Given an integer n, and an array a of x random positive integers, I would like to find all possible sums of the combinations with replacement (n out of x) that can be drawn from this array. For example: n = …