[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 1a54e49 1/2: Clarify non-MEC solves

From: Greg Chicares
Subject: Re: [lmi] [lmi-commits] master 1a54e49 1/2: Clarify non-MEC solves
Date: Tue, 15 Sep 2020 00:44:58 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 2020-09-14 20:28, Vadim Zeitlin wrote:
> On Fri, 11 Sep 2020 15:43:30 -0400 (EDT) Greg Chicares 
> <gchicares@sbcglobal.net> wrote:
> GC>     Clarify non-MEC solves
> GC>     
> GC>     Changed the objective function to
> GC>       is_mec ? -1.0 : 1.0
> GC>     which expresses the intention clearly, as opposed to the old
> GC>       0.5 - is_mec
> GC>     which was just too cute. Improved documentation.
>  Oh, thanks for doing this! I remember stumbling on this expression when I
> was reading lmi code and while I think I did realize what it meant after
> thinking about it, it definitely took me some time and I was rather unhappy
> about its cuteness.

Thanks. Someday maybe I'll attack this one:

    // TODO ?? This idiom seems too cute. And it can return -0.0 .
    // Maximum repayment is total debt.
    ActualLoan = -std::min(-RequestedLoan, RegLnBal + PrfLnBal);

although it's a low priority (in the problem domain, it rarely
if ever makes sense to repay a loan against a life insurance

This is the dark side of learning APL as a first language: I
suppose that expression comes across to others as rather
precious, but to me, it looks natural, and its only real
defect is that it can return a negative zero...so I have to
ask: how could it be written so that it's clear to everyone?

We can ignore the distinction between "Reg" and "Prf", and
just consider the total "RegLnBal + PrfLnBal", which is the
loan balance. "RequestedLoan" is just whatever was entered
in the GUI: e.g., "1000" if you want to increase the loan
balance by $1000, receiving $1000 in cash; or "-1000" if
you want to pay back $1000 in cash and reduce the loan
accordingly. The expression just means that you can't
repay more than the total balance. How would you write that?
  std::max(RequestedLoan, -(RegLnBal + PrfLnBal));
be any clearer?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]