mathematical-optimization

How to disable fast math for a header file function

别说谁变了你拦得住时间么 提交于 2020-06-01 05:12:49
问题 How do I disable fast math for a function defined in header file or for the entire source file? #pragma GCC optimize ("no-fast-math") Adding the line above to both (source file and header file) doesn't seem to work in this case. 来源: https://stackoverflow.com/questions/61941592/how-to-disable-fast-math-for-a-header-file-function

Simple constraint programming solver

柔情痞子 提交于 2020-05-29 02:39:12
问题 I'm trying to get familiar with constraint programming. All documentation/videos I've seen so far just contain description of top-level concepts and code examples based on CP-libraries utilization (like Choko, Gecode, JaCoP etc). I'd like to implement at least something simple in Java without any libraries. Are there any resources where I can find working code in Java/C#/C++/Python which implements main CP ideas? (at least "send more money" problem solution). (or, maybe, if somebody can

Maximize objective function using scipy.optimize

a 夏天 提交于 2020-04-30 16:36:44
问题 The scipy.optimize module has scipy.optimize.minimize which allows to find value that minimize an objective function. But there is no scipy.optimize.maximize. Why? How do I solve a maximization problem using SciPy? 回答1: To maximize f , we minimize -f . A mini-example, maximizing f which is the sine function: from scipy.optimize import minimize import numpy as np f = lambda x: np.sin(x) # function to be MAXIMIZED res = minimize(lambda x: -f(x), 0) print('Maximum {} attained at {}'.format(-res

Minimize function with parameters

给你一囗甜甜゛ 提交于 2020-04-29 10:55:28
问题 Currently I have the following code that defines the function f . a = #something b = #something c = #something def f(x): """Evaluates some function that depends on parameters a, b, and c""" someNumber = #some calculation return someNumber Ideally I would do def f(x, a, b, c) , BUT I am minimizing f with respect to x and SciPy's optimization toolbox doesn't allow for one to minimize functions with parameters in the arguments. That said I would like to run my minimization code for multiple

What is the minimum cost to connect all the islands?

柔情痞子 提交于 2020-04-05 06:58:05
问题 There is a grid of size N x M . Some cells are islands denoted by '0' and the others are water . Each water cell has a number on it denoting the cost of a bridge made on that cell. You have to find the minimum cost for which all the islands can be connected. A cell is connected to another cell if it shares an edge or a vertex. What algorithm can be used to solve this problem? What can be used as a brute force approach if the values of N, M are very small, say NxM <= 100? Example : In the

How does the SCIP code treat SAT problems?

流过昼夜 提交于 2020-03-23 12:32:43
问题 I am trying to find out how SCIP treats SAT problems. In the SCIP website, it is recommended to type 'set emphasis cpsolver' in the command line for SAT problems after reading the cnf file. The SCIP solver would then do its own thing after typing 'optimize'. I am not particularly skilled in code tracing and would like to know the pathway the SCIP solver takes after typing the 'set emphasis cpsolver' command. Does this command take the SAT problem and simply call a SAT solver from elsewhere?

Create a fake dataset that fits the following parameters: N, mean, sd, min, and max

筅森魡賤 提交于 2020-03-19 07:50:47
问题 Is there a way to create a fake dataset that fits the following parameters: N, mean, sd, min, and max? I want to create a sample of 187 integer scale scores that have a mean of 67 and a standard deviation of 17, with observations within the range [30, 210]. I'm trying to demonstrate a conceptual lesson about statistical power, and I would like to create data with a distribution that looks like a published result. The scale score in this example is the sum of 30 items that each could range

How to set upper and lower bounds for each element in a set?

断了今生、忘了曾经 提交于 2020-02-02 13:35:06
问题 I am creating a GAMS model to solve a simple maximization problem. I have a set J with 3 elements (1,2,3) and a variable x(J) that encompasses all the elements. I am wondering if there is a way in GAMS to set a lower bound of 0 and upper bound of 3 to each element in the set without having to set each element bound individually and without using the positive variable keyword for the lower bound. I have tried using x.lo =e= 0 and x.up =e= 3 but none of these are working. I am guessing I am not

How to set upper and lower bounds for each element in a set?

纵然是瞬间 提交于 2020-02-02 13:31:37
问题 I am creating a GAMS model to solve a simple maximization problem. I have a set J with 3 elements (1,2,3) and a variable x(J) that encompasses all the elements. I am wondering if there is a way in GAMS to set a lower bound of 0 and upper bound of 3 to each element in the set without having to set each element bound individually and without using the positive variable keyword for the lower bound. I have tried using x.lo =e= 0 and x.up =e= 3 but none of these are working. I am guessing I am not

Optimize connection between nodes in a graph [duplicate]

亡梦爱人 提交于 2020-01-25 20:58:56
问题 This question already has answers here : Connect nodes to maximize total edge weight (5 answers) Closed 2 years ago . I am working on a problem which could be reduced to a graph optimization problem as below. A set of colored nodes are given. A set of rules are given about the cost contribution from the nodes. Ex. If a red node is not connected, cost is 100 If a red node connects to red node, cost is 10 If a red node connects to a blue node, cost is 20 Any node can have only 4 connections at