Message Boards Message Boards

0
|
6474 Views
|
6 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Using a list for possible values that a variable should have

Posted 4 years ago

Hi, I need to assign possible values for a variable and then to chose the optimal value? Like a=[1,2,5,8] and then to find the optimal value among them according to an optimization purpose.

POSTED BY: Wael Al Hajailan
6 Replies
Posted 4 years ago

There are no doubt one-line statements which can do this, but here is a hopefully understandable approach:

(* objective function *)
obj[x_] := (x - 5)^2 + 3

Plot[obj[x], {x, 0, 10}]

(* candidate values *)
xList = Range[1, 10];

(* return a trial value and its function value *)
try[x_] := {x, obj[x]}

(* try them all *)
tryList = try /@ xList

(* find the minimum *)
MinimalBy[tryList, #[[2]] &]

(* {{5,3}} *)
(* the minimizing value is x = 5 for a min of 3 *)
POSTED BY: David Keith
Posted 4 years ago

Linear programming with interval coefficients is one of the tools to tackle uncertainty in mathematical programming models. This paper presents a problem solving linear programming with interval coefficients. The problem will be solved by the algorithm general method to solve linear programming with interval coefficients. Thus, the best and the worst optimum solutions can be obtained, the upper bounds and lower bounds for the optimum value of the main problems can be determined.

POSTED BY: kritesh anand
Posted 4 years ago

It is not clear exactly what you are trying to do. Assuming your "optimization" computation can be expressed as a function f and the "optimal value" is the Max of that function for each of the values then e.g.

a = {1, 2, 5, 8};
f[x_] := x^2;
f /@ a // Max
(* 64 *)
POSTED BY: Rohit Namjoshi

The optimization is to find the lowest value for an objective function and then it should tell me which value that will do ?

POSTED BY: Wael Al Hajailan
Posted 4 years ago

Then just replace f with your objective function and Max by Min.

POSTED BY: Rohit Namjoshi

So how can I know which value of "a" is used ?

POSTED BY: Wael Al Hajailan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract