Mathematical problem

This is for discussions about news, politics, sports, other games, culture, philosophy etc.
User avatar
No Flag fightinfrenchman
Ninja
Donator 04
Posts: 23506
Joined: Oct 17, 2015
Location: Pennsylvania

Re: Mathematical problem

Post by fightinfrenchman »

Is there a way to hide threads?
Dromedary Scone Mix is not Alone Mix
Image
No Flag deleted_user0
Ninja
Posts: 13004
Joined: Apr 28, 2020

Re: Mathematical problem

Post by deleted_user0 »

musketeer925 wrote:I'm a little behind, but

Image

top line: 50 + interest on 50
bottom line: start w/ zero and gather at 0.64

the interest is always better with these numbers. With different interest rate and cost, you could see they might intersect, making gathering a good investment for a little while

I see the exponent is a problem. To make this realistic mathematical formula, you should somehow decrease the exponent over time.
any ideas?
No Flag deleted_user0
Ninja
Posts: 13004
Joined: Apr 28, 2020

Re: Mathematical problem

Post by deleted_user0 »

fightinfrenchman wrote:Is there a way to hide threads?

If there was a way to hide user, you would be on it.
User avatar
United States of America musketeer925
Retired Contributor
Donator 01
Posts: 2484
Joined: Mar 28, 2015
ESO: musketeer925

Re: Mathematical problem

Post by musketeer925 »

somppukunkku wrote:
fightinfrenchman wrote:Is there a way to hide threads?

If there was a way to hide user, you would be on it.


There is a way to hide users, in fact:
https://i.imgur.com/FqT8RCh.png
User avatar
United States of America musketeer925
Retired Contributor
Donator 01
Posts: 2484
Joined: Mar 28, 2015
ESO: musketeer925

Re: Mathematical problem

Post by musketeer925 »

somppukunkku wrote:I see the exponent is a problem. To make this realistic mathematical formula, you should somehow decrease the exponent over time.
any ideas?

That sounds like making something up to attempt to make your made-up assumption better. In other words, I think it's going to be a wild-ass guess, and not useful.

I think you instead need a more detailed model instead.
User avatar
Malaysia Aizamk
Pro Player
ESOC WarChiefs Classic 2017
Posts: 1459
Joined: Feb 26, 2015
Location: ded

Re: Mathematical problem

  • Quote

Post by Aizamk »

@deleted_user2 here is fishing boom model, figure out how to use by self thx bai. tbh @Goodspeed 's build order program would probably do the same job if not better, though.
[spoiler=R code]

Code: Select all

dock_num<- -1
dock_cost<- -1
period<- -1
boat_cost<- -1
r<- -1
i<- -1
boat_batches<- -1
max_boats<- -1
nomoreboatstime<- -1
maximumfish<- -1

max<-function(a,b){
   if(a>b){return(a)}
   return(b)
}
min<-function(a,b){
   if(a<b){return(a)}
   return(b)
}
caprevenue<-function(revenue){
   return(min(revenue,maximumfish))
}

boat_num<-function(t){
   if(t<=0){return(0)}
   if(t>nomoreboatstime){return(dock_num*floor(nomoreboatstime/period))}
   return(dock_num*floor(t/period))
}

investment_nominal<-function(t){
   if(t<=0){return(0)}
   return(dock_cost*dock_num+boat_cost*boat_num(t))
}
discount<-function(res,interestrate){
   result<-as.vector(res)
   for(i in 2:length(res)){
      result[i]<-result[i-1]+(res[i]-res[i-1])*(1+interestrate)^(1.5-i)
   }
   return(result)
}

revenue_nominal<-function(t){
   if(t<=0){return(0)}

   lastboatbatchtime<-period*floor(t/period)
   if(t==lastboatbatchtime){lastboatbatchtime<-lastboatbatchtime-period}

   return(
      revenue_nominal(lastboatbatchtime)+
      r*(t-lastboatbatchtime)*boat_num(lastboatbatchtime)
   )

}

capped_revenue_nominal<-function(t){
   rev<-revenue_nominal(t)
   if(rev<maximumfish){return(rev)}
   return(maximumfish)
}

plotstuff<-function(){

t<-seq(0,1200,1)
investment<-sapply(t,investment_nominal)
revenue<-sapply(t,revenue_nominal)
capped_revenue<-sapply(revenue,caprevenue)
profit<-revenue-investment
capped_profit<-capped_revenue-investment

breakeventime<- -1
profitpoints<-which(capped_profit>=0)
if(length(profitpoints)>1){breakeventime<-profitpoints[2]-1}

exhaustiontime<- -1
maxprofit<- -1
discounted_maxprofit<- -1
exhaustionpoints<-which(capped_revenue>=maximumfish)
if(length(exhaustionpoints)>0){
   exhaustiontime<-exhaustionpoints[1]-1
   maxprofit<- capped_profit[exhaustionpoints[1]]
}

discounted_investment<-discount(investment,i)
discounted_capped_revenue<-discount(capped_revenue,i)
discounted_capped_profit<-discount(capped_profit,i)

if(length(exhaustionpoints)>0){
   discounted_maxprofit<- discounted_capped_profit[exhaustionpoints[1]]
}

plot(t,investment, main=paste(dock_num,
   "docks, up to",max_boats,"boats\nbreak even at",breakeventime,"s\ndeplete fish at",exhaustiontime,
   "s with profit",maxprofit,"|",as.integer(discounted_maxprofit)),
   xlab="time", ylab="Resources",
   col="red", type="l", ylim=c(-2000,maximumfish*1.5))
abline(h=maximumfish, col="blue",lty=2)
abline(h=0, col="black",lty=2)

lines(t,discounted_investment, col="red", type="l", lty=2)

lines(t,capped_revenue, col="green", type="l")
lines(t,discounted_capped_revenue, col="green", type="l", lty=2)

lines(t,capped_profit, col="orange", type="l")
lines(t,discounted_capped_profit, col="orange", type="l", lty=2)

legend(1, maximumfish*1.5, legend=c("Investment", "Revenue", "Profit"),
   col=c("red", "green", "orange"), lty=c(1,1,1), cex=0.8,
   text.font=4, bg='lightblue')
}

#Just keep running this bit after changing the values
dock_num<-2
dock_cost<-225
period<-15
boat_cost<-60
r<-0.67
i<-0.005
boat_batches<-15
max_boats<-dock_num*boat_batches
nomoreboatstime<-boat_batches*period
maximumfish<-9000
plotstuff()
[/spoiler]
oranges.
User avatar
Netherlands Goodspeed
Retired Contributor
Posts: 13006
Joined: Feb 27, 2015

Re: Mathematical problem

Post by Goodspeed »

Doesn't support water I'm afraid. Not much work to add though, if you want to use it @deleted_user2
Netherlands momuuu
Ninja
Posts: 14237
Joined: Jun 7, 2015
ESO: Jerom_

Re: Mathematical problem

Post by momuuu »

somppukunkku wrote:
musketeer925 wrote:I'm a little behind, but

Image

top line: 50 + interest on 50
bottom line: start w/ zero and gather at 0.64

the interest is always better with these numbers. With different interest rate and cost, you could see they might intersect, making gathering a good investment for a little while

I see the exponent is a problem. To make this realistic mathematical formula, you should somehow decrease the exponent over time.
any ideas?

Well, you could use something scaling as for example t^2 or maybe the exponent can be the square root of t, but at this point you're just making things up until they match what you think should be true. Then you might as well remove the middle man (which in this case is the mathematical model).

One of the main problematic approximations is that we have so far assumed that any resources gathered will instantly start getting profit. So if you get a ton of boats to get 9000 res instantly, these res will all instantly start increasing your boom exponentially. While a small amount of resources could have an exponential effect, in aoe3 its impossible to instantly spend 9000 resources on economy.

So if you were to model this its probably better to use a numerical model over a mathematical model.
User avatar
Netherlands edeholland
ESOC Community Team
Donator 01
Posts: 5033
Joined: Feb 11, 2015
ESO: edeholland
GameRanger ID: 4053888
Clan: ESOC

Re: Mathematical problem

Post by edeholland »

Do we still want the solution to actually apply to AoE3? I am not convinced advanced dock is actually worth more than 1400 resources, because boats already train very quickly with the double schooners shipment. If you don't have advanced dock you can send fishing boat upgrades and you have a training time, which changes the maths around the problem.
User avatar
Malaysia Aizamk
Pro Player
ESOC WarChiefs Classic 2017
Posts: 1459
Joined: Feb 26, 2015
Location: ded

Re: Mathematical problem

Post by Aizamk »

well firstly 0.7% interest seems a bit too high, I'd go for 0.4% maximum. then 100 at time 0 is equal to 1100 at 10 minutes, which sounds more reasonable than 6600. other thing is that if you're applying an interest rate to the cost of boats, you also need to consider that the resources gathered early on are also worth more later on. just express everything in time-0 terms and solve from there.
oranges.
User avatar
Netherlands Goodspeed
Retired Contributor
Posts: 13006
Joined: Feb 27, 2015

Re: Mathematical problem

Post by Goodspeed »

Goodspeed wrote:Doesn't support water I'm afraid. Not much work to add though, if you want to use it @deleted_user2
Added it regardless. New version attached.

Added dock.
Added fishing boats.
Added shipments: Schooners, East Indiamen, Advanced dock, Rendering plant.
(so no warships)
All with EP 5 stats.

Note that to get a count of your fishing boats you can use "print fishingboatcount". Fishing boats are counted as vills in the information shown when using the "show" command.

If you want to use it, hopefully this doc will help you: https://docs.google.com/document/d/1Ny8 ... Vx0Q/edit#
If you have any questions just ask on discord or here.

Original post: https://eso-community.net/viewtopic.php ... der+tester
Attachments
BuildOrders_v1.07.zip
(62.98 KiB) Downloaded 22 times
No Flag deleted_user0
Ninja
Posts: 13004
Joined: Apr 28, 2020

Re: Mathematical problem

Post by deleted_user0 »

Nice. Will probably test this out later.
User avatar
Turkey HUMMAN
Lancer
Posts: 817
Joined: Apr 16, 2017
ESO: HUMMAN

Re: Mathematical problem

Post by HUMMAN »

I tried to solve a similar problem with an approach

Assumption1: Boats cost 50 res, they gather at 0.84 res/s

Assumption2: Boats are made instant
Assumption3: t is second starting at 0:00 and ends at 20:00. (Critical points of a fish boom beginning and end)
Assumption4: RealValue is a function of res and starts with realVal=res at t=1s and ends with realVal=11res at t=1200s with respect to realVal=[ 1/(1,002)]^t for 1<t(s)<1200. (assuming 200w at 0 min is equalivent to 2200 w at 20 min, further equalivents: 400w at 6 min, 660 w at 10 min, 1200 w at 15 min)

Assumption5: Res are in bank are applied an interest rate with respect to realValue, such that Res(t)=1,002res^t. ( If not invested in boats, invested in other boom options , map control military etc. assuming they are paying off)

Assumption6: Boats can gather only 10k res while res in bank can grow forever.
Question: Given 1000 starting res at min 0, find the optimum build of boats in order to maximaze real value at t=20 min.
Case1: make boats only at t =0s;
For 0 boats 10996 res at 20 min, for 20 boat 64024 res at 20 min.
Taking somppu's interest rate(1.007) program still favors 20 boats.
Case2
2.a :make boats only at =0s with infinite res start;
This one basically measures ideal boat count with ideal position. For boat threshold i choose 100 as a commonsense limit- and thus anything greater than 50*100 may be count as infinite, where i choose 10 k as starting res.
Program favors 44 boats for maximum growth, which is the answer somppu trying to find. with 44 boats 170 k final res seen, with 100 boats it is 153k with 0 boats it is 110k.
Further notes: If we take sommpu's interest rate(1.007) instead of default(1.002) program favors 57 boats.
If we take 1res/s as a gather rate program favors 38 boats, this shows relevance of efficiency in boats, as expected final res is greater which is 174 k.
2.b: adding whales in calculation such that only fish is gathered until it runs out. whales are gathered at 0.84 res/s same as fish:
1 whale 50 boats 180 k final res.
4 whales 69 boats 220k final res.

Code: Select all

float bank(float res, float fish_income, float rate, int time, int reserve,int whale)
{
   if (reserve < 0)
   {
      if (fish_income > whale * 4)
      {
         fish_income = whale * 4;
      }
      else
         fish_income = fish_income;
}
   reserve -= fish_income;
   time--;
   float resource = res+fish_income;
   resource = rate*resource;
   if (time <= 0)
      return resource;
   else
      return bank(resource, fish_income, rate, time, reserve,whale);
}

std::vector<float> resList(int boat_count, float res, int whale)
{   
   std::vector<float> v_out;
   int index = 0;
   while(index<=boat_count)

   {
      float result = bank(res - 50 * index, index*0.84, 1.002, 1200, 10000,whale);
      v_out.push_back(result);
      index++;
   
   }
   

   return v_out;

}

void print_v(std::vector<float> v_input)
{
   int index = 0;
   while (index < v_input.size())
   {
      std::cout << index <<" boat produces "<<v_input[index] <<" resources at the end "<< std::endl;
      index++;
   }
}

float BestBoat(std::vector<float> v_input)
{
   float maxRes = 0;
   int bestboat = 0;
   int index = 0;
   while (index < v_input.size())
   {
      if (v_input[index] > maxRes)
      {
         maxRes = v_input[index];
         bestboat = index;
      }
      index++;
      
   }
   return bestboat;
}
int main()
{
   
   std::vector<float> result_v = resList(20, 1000,0);  //case1

   print_v(result_v);
   std::cout << "Max resources are produced by " << BestBoat(result_v) << " initialized boats. "<<std::endl;

   std::vector<float> result_2 = resList(100, 10000,0);   //case2

   print_v(result_2);
   std::cout << "Max resources are produced by " << BestBoat(result_2) << " initialized boats. " << std::endl;

   std::vector<float> result_3 = resList(100, 10000, 1);   //whales

   print_v(result_3);
   std::cout << "Max resources are produced by " << BestBoat(result_3) << " initialized boats. " << std::endl;
   

    return 0;
}


Case3 :Start with 500 res. as long as you have enough res, built boats until N boats. N is from 0 to 100. 100 boats is not only the pop limit but also commonsense barrier for efficiency.
Well this one goes more realistic, further calculations would consider boat build time, dock cost... I may continue some day.
Image

Who is online

Users browsing this forum: No registered users and 2 guests

Which top 10 players do you wish to see listed?

All-time

Active last two weeks

Active last month

Supremacy

Treaty

Official

ESOC Patch

Treaty Patch

1v1 Elo

2v2 Elo

3v3 Elo

Power Rating

Which streams do you wish to see listed?

Twitch

Age of Empires III

Age of Empires IV