Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:56:21+00:00 2026-06-05T19:56:21+00:00

I have an algorithm that finds the minimum of function/n on Rn. And I

  • 0

I have an algorithm that finds the minimum of function/n on Rn. And I have a constrain manifold, that is given in a form of singular cube image. Mapping singular cube inner space to Rn and more importantly vice versa is quite trivial and can be done with unar function from_R_to_01 applied to every coordinate.

So what I want to do is to take my target function F of some arity, and make another function of the same arity, which will be the same F, except its’ coordinates are to be mapped from Rn to a constrain manifold Man. Therefore I can give it to my minimization algorithm, get a pair of coordinates in Rn and then map them too to the same manifold to get “real world” coordinates. Therefore to reduce nonlinear programming task to unconstrained optimization.

Well, back to the question. I have this piece of code working for a 2-ar case.

minn_man2(F, Man) ->
    OnRn = fun (X, Y) ->  # this is the limiting part
        OnMan = Man( from_R_to_01( X ), from_R_to_01( Y ) ),
        apply( F, OnMan )
    end,
    [X | [ Y | []]] = minn( OnRn ),
    Man( from_R_to_01( X ), from_R_to_01( Y ) ).

How can I make it more general? The hardest part is making an anonymous function of Fs’ arity. Have no idea how to do this at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:56:22+00:00Added an answer on June 5, 2026 at 7:56 pm

    Think I’ve got it! If I need to have an explicit declaration of OnRn for each certain arity, why don’t I make them.

    First I have manually wrote two separate declarations for unar and binar Mans in a single ‘case MA of’ statement. Then I’ve got lazy and used python to generate me a whole bunch of these. Then I looked for a some kind of eval to make Erlang generate and evaluate the appropriate declaration on the run. And here it is. Works like a charm.

    minn_man(F, Man) ->
        MA = proplists:get_value( arity, erlang:fun_info( Man )),
        R1 = fun (X) -> from_R_to_01(X) end,
    
        XiStr = string:join(["X" ++ integer_to_list(I) || I <- lists:seq(1, MA)], ", "),
        RiXiStr = string:join(["R1(X" ++ integer_to_list(I) ++ ")" || I <- lists:seq(1, MA)], ", "),
        FunStr = "fun (" ++ XiStr ++ ") -> apply( F, Man(" ++ RiXiStr ++")) end.",
    
        {ok, Tokens, _} = erl_scan:string(FunStr),
        {ok, [Form]} = erl_parse:parse_exprs(Tokens),
        Binding1 = erl_eval:add_binding('F', F, erl_eval:new_bindings()), 
        Binding2 = erl_eval:add_binding('Man', Man, Binding1), 
        Binding3 = erl_eval:add_binding('R1', R1, Binding2),
        {value, OnRn, _} = erl_eval:expr(Form, Binding3),
    
        XY = minn( OnRn ),
        apply(Man, lists:map(fun from_R_to_01/1, XY ) ).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to write an algorithm that find the path in DAG with single
I have an algorithm that recursively makes change in the following manner: public static
I have this algorithm that I want to implement on VB6. Sub Main() dim
I have simple algorithm that clean the whitespace from half string until end. Here
If I have an algorithm that takes n log n steps (e.g. heapsort), where
I have a relatively simple algorithm that walks an std::vector looking for two neighbouring
We have our own data streaming algorithm that include some metadata+records+fields values. Currently we
I have a SP that has the following algorithm. IF <SomeCondition> BEGIN SELECT *
I have an assignment that wants me to write an ternary search algorithm and
i have heard from a friend of mine that the best algorithm for swapping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.